registration form not working--PHP--?

hjfxghd7

New member
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Habitual Darkness</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<center>
<div id="wrapper">
<div id="header"></div>


<?php include("menu.php"); ?>




<div id="content">


<div class="newstitle"><p class="margin"><u>Signup</u></p></div>
<div class="newscontent">
<p class="margin">


<div id="form">

<?php
include("dbsettings.php"); ?>
<?php
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// Get values from form

$charName=$_POST['charName'];
$charRace=$_POST['charRace'];
$charClass=$_POST['charClass'];
$charLvl=$_POST['charLvl'];
$prof1=$_POST['charprofession1'];
$prof2=$_POST['charprofession2'];
$email=$_POST['email'];
$password=$_POST['password'];
$pass2=$_POST['password2'];
$md5pass= md5 ('$password');

if($password!=$pass2)
{
echo "Password fields did not match. Please try again";
}

if($prof1==$prof2)
{
echo "You cannot have the same profession twice";
}



// Insert data into mysql
$sql="INSERT INTO $tbl_name(charName, charRace, charClass, charLvl, charprofession1, charprofession2, email, password)
VALUES('$charName', '$charRace', '$charClass', '$charLvl', '$prof1', '$prof2', '$email', '$md5pass')";

$result=mysql_query($sql) or die(mysql_error());

// if successfully insert data into database, displays message "Successful".
if($result){
echo "Successful";
echo "<BR>";
echo "Congratulations you are now registered with Habitual Darkness.";
echo "<BR>";
echo"You will be redirected to login form.";
}

else {
echo "There was a problem with the database. We'll fix this as soon as possible.";
}

// close connection
mysql_close();
?>



</div>

<br/>
</p>
<br/></div>




</div>



<div id="footer">Copyright (c) 2011 <a href="index.php">Habitual Darkness</a></div>
</center>
<br/>
</body>
</html>

I want the validation errors to appear on the same page as the register form

ERROR MESSAGE

field1
field2
field3
etc..
 
Back
Top