Hi,
I am struggling with two parts of a registration tutorial which I found on YouTube. I have edited it to suit my login form and it is all working and registering to the database correctly - but two things I cannot seem to do.
1) Instead of killing the script when a duplicate user is entered, I would like an echo just like the other statements. I have tried moving the script around but it still isn't working.
2) Instead of killing the script when the registration is complete, I would just like it to redirect to a page of my choice, I have tried to replace the die part of the script with a header but no joy.
Could someone help me out and show me where the echo is supposed to go and also how to redirect, thanks.
<?php
if($submit)
{
$connect = mysql_connect("*****","*****","*****") or die ("Couldn't connect!");
mysql_select_db("*****") or die ("Couldn't find a db!");
$namecheck = mysql_query("SELECT username FROM users WHERE username = '$username'");
$count = mysql_num_rows($namecheck);
if($count!=0)
{
die ("Username already taken!");
}
if ($username&&$password&&$repeatpassword&&$redirect)
{
if($password==$repeatpassword)
{
if(strlen($password)<8)
{
echo "Password must be at least 8 characters!";
}
else
{
$password = md5($password);
$repeatpassword = md5($repeatpassword);
$queryreg = mysql_query("
INSERT INTO users VALUES ('','$username','$password','$date','$redirect')
");
die ("You have been successfully registered!");
}
}
else
echo "Your password do not match!";
}
else
echo "Enter all the details";
}
?>