A
Anonymous
Guest
Hi all
I have a problem with the following code:
I have a problem with it where everytime i run the script even if it finds an error it will run the query and insert the info into the database.
I cant seem to find a way to stop it doing this and it is a real pain!
Hope someone can help me!
Cheers!
I have a problem with the following code:
Code:
<?
//error checking
if (empty($username) || empty($name) || empty($email) || empty($email1)) {
$message = "You did not fill in all the correct fields please try again!";
include "index.php";
}
elseif
(
$tos != "yes"
)
{
$message = "You must agree to the Terms and Conditions!";
include "index.php";
}
elseif
(
$email != $email1
)
{
$message = "You email addresses didnt match! Please try again!";
include "index.php";
}
include "../../connections/connect.php";
include "../../connections/select_db_members.php";
$query = "SELECT * FROM members WHERE username = '$username'";
$result = mysql_query($query)
or die (mysql_error());
$num = mysql_num_rows($result);
if ($num > 0)
{
$message = "The username you have chosen is already in use, please try again!";
include "index.php";
}
else
{
include "../../connections/connect.php";
include "../../connections/select_db_members.php";
$pass=date("m-i").time();
$password = md5($pass);
$ip = $_SERVER['REMOTE_ADDR'];
$dob = "dob_day - $dob_month - $dob_year";
$query = "INSERT INTO members(username,password,name,email,dob,ip,status,last_login) VALUES('$username','$password','$name','$email','$dob','$ip','user',NOW())";
$result = mysql_query($query);
$to = $email;
$from = "From: Dance-Nation";
$subject = "Application To Dance Nation!";
$message = "
Dear $name
Thankyou for your application to dance-nation.co.uk
Your details are as follows:
Username = $username
Password = $pass
Your password has been automatically generated and we recommend you change this password on your first login!
Welcome to Dance-Nation!
If you have nany problems please email support@dance-nation.co.uk
Cheers!
Dan (Dance-nation owner!)
dan@dance-nation.co.uk";
mail($to,$subject,$message,$from);
$message = "Your registration was successful! You will recieve your password shorty and will then be able to login!";
include "../login.php";
}
?>
I have a problem with it where everytime i run the script even if it finds an error it will run the query and insert the info into the database.
I cant seem to find a way to stop it doing this and it is a real pain!
Hope someone can help me!
Cheers!