I am trying to perfect my registration script (basic, just places variables into a mySQL database) and would like to make it so someone simply can't go to register.php directly and see the registration confirmation (this stops people from entering blanks).
Here is what I'm trying to do:
<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
$tbl_name="members"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$name=stripslashes($_POST['name']);
$email=stripslashes($_POST['email']);
$username=stripslashes($_POST['username']);
//Check to see if there are duplicates
$query = "SELECT COUNT(*) AS count FROM $tbl_name WHERE username='$username'";
$results = mysql_query($query) or die ("Error reading from database");
$existingEmails = mysql_fetch_array($results);
// Insert data into mysql
$sql="INSERT INTO $tbl_name(name, email, username)VALUES('$name', '$email', '$username')";
$result=mysql_query($sql);
if($_SERVER['REQUEST_METHOD'] == "POST") {
if ($existingEmails['count'] > 0) {
echo "<div style=\"color: #FFFFFF; font-family:'Macondo Swash Caps';\"></div>";
} else {
mysql_query($sql);
//Send mail
$to="$email";
$subject="";
$headers = '' . "\r\n";
$headers .= 'Bcc: ' . "\r\n";
$message="
";
mail($to, $subject, $message, $hearders);
echo "<div style=\"font-family: 'Macondo Swash Caps'; color: #FFFFFF;\">T</a>";
}
} else {
print You did not fill out the form!;
}
// close connection
mysql_close();
?>
I'm getting this error: Parse error: syntax error, unexpected T_STRING in register.php on line 68.
Thanks for the help!

New Topic/Question
Reply



MultiQuote




|