reg page- retardness

06/13/2010 21:47 -Shunsui-#1
Code:
<center>
<form method="post" action="">
<tr><td>Account ID:</td><td><br />
<input maxlength="13" type="text" name="username"/>
</td></tr><br />
<tr><td>Password:</td><td><br />
<input maxlength="13" type="password" name="password"/>
</td></tr><br />
<tr><td>Confirm Password:</td><td><br />
<input maxlength="13" type="password" name="password2"/>
</td></tr><br />
<tr><td>Email:</td><td><br />
<input type="text" name="email"/>
</td></tr><br />
<tr><td>Secret #:</td><td><br />
<input maxlength="13" type="text" name="secretnumber"/>
</td></tr><br />
<tr><td>Phone #:</td><td><br />
<input maxlength="13" type="text" name="phone"/>
</td></tr><br /><br />
<tr><th colspan="2"><input type="submit" name="submit" value="Register"/></th></tr>
<br /><br />
</form>

<?php

if(isset($_POST['submit']))
{
// DataBase Information

$dbhost = "localhost";
$dbname = "new";
$dbuser = "root";
$dbpass = "984510";

// Connection

mysql_connect ($dbhost, $dbuser, $dbpass) or die("Could not connect!: ".mysql_error());
mysql_select_db($dbname) or die("Could not select database $dbname !: ".mysql_error());

// Variables

$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = $_POST['email'];
$secretnumber = $_POST['secretnumber'];
$phone = $_POST['phone'];

// Fields Check

if (!$username || !$password || !$password2 || !$email || !$secretnumber || !$phone)
{
   echo("Please fill in all the fields!");
   return;
}

// Password Check

if ($password != $password2)
{
   echo("Passwords do not match!");
   return;
}

// AccountID Length
if (strlen($username) < 3) 
echo("Your AccountID needs to be Over 3 Characters");
return;
//Password Check
if (strlen($password) < 5) 
echo("Your Password Must Be 4-13 Chars");
return;
//Secret Number Check
if (strlen($secretnumber) < 2) 
echo("Your Secret Number Must be 2 Characters Or More");
return;
//Phone Check
if (strlen($phone) < 5) 
echo("Phone Number Must be 5 Chars Above");
return;
// Insert

$newuser = "INSERT INTO cq_accounts(AccountID, Password, Email, SecretNumber, phone) VALUES ('$username', '$password', '$email', '$secretnumber', '$phone')";
mysql_query($newuser) or die("$username Already In Use");
mysql_close();

echo "Your Account $username Has Been Succesfully Registered";
}

?>
</center>
for some reason when i click register, it just reloads the page dosent do nothing @_@
06/13/2010 22:35 kinshi88#2
Add some echos to see where it stops at.
06/13/2010 23:52 -Shunsui-#3
#Close kinshi fixed it
06/14/2010 01:43 scottdavey#4
You can just use Die("Character must be longer than 3 characters.");

or Exit();

No need for all the returns.
06/14/2010 07:02 Huseby#5
#Closed