Hello, I'm trying to run the following mysql query. Basically, the user fills out a registration form which then gets forwarded to this script. However, the data isn't being stored.
Can someone please help?
PHP:
$name=$_POST['name'];
$email=$_POST['email'];
$username=$_POST['username'];
$password=$_POST['password'];
$confirm=$_POST['confirm'];
mysql_connect(localhost,$db_username,$db_password);
@mysql_select_db($database) or die( "Unable to select database");
if ( $_POST['password'] == $_POST['confirm'] )
{}else{
echo '<script>alert("Your passwords were not the same, please enter the same password in each field.");</script>';
echo '<script>history.back(1);</script>';
exit;
}
if (((( empty($name) ) || ( empty($username) ) || ( empty($email) ) || ( empty($password) ))))
{
echo '<script>alert("One or more fields were left empty, please try again.");</script>';
echo '<script>history.back(1);</script>';
exit;
}
if((!strstr($email , "@")) || (!strstr($email , ".")))
{
echo '<script>alert("You entered an invalid email address. Please try again.");</script>';
echo '<script>history.back(1);</script>';
exit;
}
$q = mysql_query("SELECT * FROM users WHERE email = '$email'") or die(mysql_error());
if(mysql_num_rows($q) > 0)
{
echo '<script>alert("The email you entered is already in use, please try again.");</script>';
echo '<script>history.back(1);</script>';
exit;
}
$e = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
if(mysql_num_rows($e) > 0)
{
echo '<script>alert("The username you entered is already in use, please try again.");</script>';
echo '<script>history.back(1);</script>';
exit;
}
$query = "INSERT INTO users VALUES ('$name,'$email','$username','$password')";
mysql_query($query);
$i=0;
while ($i < $num) {
$name=mysql_result($result,$i,"name");
$email=mysql_result($result,$i,"email");
$username=mysql_result($result,$i,"username");
$password=mysql_result($result,$i,"password");
echo "<b>$name</b><br>Email: $email<br>Username: $username<br>Password: $password<br><hr><br>";
$i++;
}
$yoursite = 'The Flavell Studio';
$sitename = 'The Flavell Studio';
$webmaster = 'Simon King';
$youremail = '[email protected]';
$subject = "You have successfully registered at $sitename...";
$message = "Dear $name,
You are now registered at our web site. To login, simply go to the website and enter in the following details in the login form:
.........................................
Username: $username
Password: $password
..........................................
Please remember these details for future use.
Thanks,
$webmaster
$yoursite";
mail($email, $subject, $message, "From: $yoursite <$youremail>\nX-Mailer:PHP/" . phpversion());
include("head.php");
echo "<h1>Congratulations</h1><p>Your information has been stored in our database and mailed to your email address.</p>";
include("foot.php");
mysql_close();
Can someone please help?






