Ok dont worry about that but unfortunatly again when i click the submit button it basically refreshes the page, doesnt add anyone to the database, doesnt say whether that username has been registered, HELP
Here is the code :
<html>
<body>
<?php
$submit = $POST['submit'];
//form data
$firstname = strip_tags($POST['firstname']);
$secondname = strip_tags($POST['secondname']);
$username = strip_tags($POST['username']);
$password = strip_tags($POST['password']);
$repeatpassword = strip_tags($POST['repeatpassword']);
$emailadress = strip_tags($POST['emailaddress']);
$repeatemailaddress = strip_tags($POST['repeatemailaddress']);
$postcode = strip_tags($_POST['postcode']);
$date = date("Y-m-d");
if ($submit)
{
//open database
$connect = mysql_connect ("","","");
mysql_select_db (""); //select database
$namecheck = mysql_query("SELECT username FROM users WHERE username='$username'");
$count = mysql_num_rows($namecheck);
$errors=0;
//test the posted value
if(empty($POST['somefieldname'])){
$messages[$errors]="Has Not Been Filled In !";
$errors++;
}
else{
$somefieldname=$POST['somefieldname'];
}
//continue until all fields have been validated
//check the value of $errors. If it's greater than zero, you know there's a problem
if($errors>0){
//loop through your array of error messages and output each message
for($counter=0;$counter<$errors;$counter++){
echo $messages[$counter];
}
if ($count!=1)
{
die("Username Already Exists <a href='login session\register.php'>CLICK HERE</a> to go back");
}
//check for existance
if
($firstname&&$secondname&&$username&&$password&&$repeatpassword)
{
if($password!=$repeatpassword){
echo "Your Passwords Do Not Match";
}else{
//check char length of username and first name
if (strlen($username)>40)
{
echo "Length of username is to long, Please make your username shorter";
}
//check password length
if (strlen($password)>40||strlen($password)<4)
{
echo " Password Must Be Between 4 and 40 Characters";
}
else
{
//register the user
$queryreg = mysql_query("
INSERT INTO users VALUES
('','$firstname','$secondname','$username','$password','$emailaddress','$postcode','$date')
");
die("Success, You Have Registered, <a href='index.html'>CLICK HERE TO GO TO LOGIN PAGE</a>");
}
}
}else{
echo "Your Passwords Do Not Match";
}
}else{
echo "Please Fill In <b>All</b> Info Needed";
}
}
else{
?>
<form action="register.php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr>
<td>First Name:</td>
<td><input type="text" name="firstname" maxlength="40">
</tr>
<tr>
<td>Second Name:</td>
<td><input type="text" name="secondname" maxlength="40">
</tr>
<tr>
<td>Username:</td>
<td><input type="text" name="username" maxlength="40">
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" maxlength="40">
<tr>
<td>Repeat Password</td>
<td><input type="password" name="repeatpassword" maxlength="40">
</tr>
<tr>
<td>Email Address:</td>
<td><input type="text" name="emailaddress" maxlength="40">
</tr>
<tr>
<td>Repeat Email Address:</td>
<td><input type="text" name="repeatemailaddress" maxlength="40">
</tr>
<tr>
<td>Postcode</td>
<td><input type="text" name="postcode" maxlength="40">
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" value="Join YPS"></td>
</tr>
<br>
<tr>
<td colspan="2" align="right"><a href="index.html">Go Back To Home Page</a></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
?