Hi guys, thanks for your reply. I altered the script to this and it works
/* Check no duplicate usernames */
$con = mysql_connect("zambiheadshop.com.mysql", "zambiheadshop_c", "Ozzie200407") or die(mysql_error());
$query = "SELECT COUNT(*) AS count FROM members WHERE username='$username'";
@mysql_select_db('zambiheadshop_c') or die( "Unable to select database");
$results = mysql_query($query) or die ("Error reading from database");
$existingUsernames = mysql_fetch_array($results);
if ($existingUsernames['count'] > 0) {
header('Location: usererror.php');
} else {
/* Write to MySQL database */
$sql="INSERT INTO members (username, hash, firstname, surname, email, address1, address2, town, county, postcode, birthday, birthmonth, birthyear, paypalemail, terms)
VALUES
('$_POST[username]','$hash','$_POST[firstname]','$_POST[surname]','$_POST[email]','$_POST[address1]','$_POST[address2]','$_POST[town]','$_POST[county]','$_POST[postcode]','$_POST[birthday]','$_POST[birthmonth]','$_POST[birthyear]','$_POST[paypalemail]','$_POST[terms]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
/* Redirect visitor to the thank you page */
header('Location: thanks.php');
exit();
}
But when I tried to add in a duplicate email check, so the code reads this:
/* Check no duplicate usernames */
$con = mysql_connect("zambiheadshop.com.mysql", "zambiheadshop_c", "Ozzie200407") or die(mysql_error());
$query = "SELECT COUNT(*) AS count FROM members WHERE username='$username'";
@mysql_select_db('zambiheadshop_c') or die( "Unable to select database");
$results = mysql_query($query) or die ("Error reading from database");
$existingUsernames = mysql_fetch_array($results);
if ($existingUsernames['count'] > 0) {
header('Location: usererror.php');
} else {
$con = mysql_connect("zambiheadshop.com.mysql", "zambiheadshop_c", "Ozzie200407") or die(mysql_error());
$query1 = "SELECT COUNT(*) AS count FROM members WHERE email='$email'";
@mysql_select_db('zambiheadshop_c') or die( "Unable to select database");
$results1 = mysql_query($query1) or die ("Error reading from database");
$existingEmails = mysql_fetch_array($results1);
if ($existingEmails['count'] > 0) {
header('Location: emailerror.php');
} else {
/* Write to MySQL database */
$sql="INSERT INTO members (username, hash, firstname, surname, email, address1, address2, town, county, postcode, birthday, birthmonth, birthyear, paypalemail, terms)
VALUES
('$_POST[username]','$hash','$_POST[firstname]','$_POST[surname]','$_POST[email]','$_POST[address1]','$_POST[address2]','$_POST[town]','$_POST[county]','$_POST[postcode]','$_POST[birthday]','$_POST[birthmonth]','$_POST[birthyear]','$_POST[paypalemail]','$_POST[terms]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
/* Redirect visitor to the thank you page */
header('Location: thanks.php');
exit();
}
and I get a
Parse error: syntax error, unexpected $end in /customers/4/0/d/zambiheadshop.com/httpd.www/registration/processRegister.php on line 357
Anyone know how to fix this?
Many Thanks