Hello!
Sweden here.
Shouldnt validation page be something like this
if this is the page that specified in
<form action="validate.php" method="POST">
and also shouldnt we first test if Submit
and then get user/pass from POST variables,
if something was actually submitted
Not like in code you have posted here, where $user / $pass comes out of nothing
and after this is tested ... if $_POST[ 'Submit' ]
<?PHP // form input 'validation.php'
if ( isset($_POST[ 'Submit' ]) ) {
// submit was pressed
// get user pass
$user=$_POST[ 'username' ];
$pass=$_POST[ 'pass' ];
// process and test if valid submission
$user=strip_tags($user);
$pass=strip_tags($pass);
$user=str_replace(" ","",$user);
$pass=str_replace(" ","",$pass);
$user=str_replace("%20", "",$user);
$pass=str_replace("%20", "",$pass);
$user=addslashes($user);
$pass=addslashes($pass);
$min_length=7;
if( (strlen($user) < $min_len) || (strlen($pass) < $min_len) ) {
die("Your username and/or password must have a minimum of 7 characters.");
}
// user / pass entered correctly - now add to database
$dbaseuser="user";
$dbasepassword="password";
$dbasename="dbasename";
$connection=mysql_connect("localhost",$dbaseuser,$dbasepassword);
$db=mysql_select_db($dbasename);
$pass=md5($pass);
$request="INSERT INTO login values(0, '".$user.",'".$pass."')";
$results=mysql_query($request, $connection);
if ( $results ) {
// success
echo "Your account has successfully been created<br><br>
<a href='home.php'>Back Home</a>";
exit;
}
else {
// could not add to database
echo "There was an error creating your account.<br>
Please retry or contact the webmaster.<br>
<a href='contact.php'>Contact webmaster</a>";
mysql_error();
exit;
}
} // end submit was pressed
else {
// As not $_POST[ 'Submit' ] this user did not come from <FORM>
// and should be redirected to FORMpage
}
?>
/halojoy - did not quite get your code
sorry
.