Jump to content

aquatradehub

Members
  • Posts

    56
  • Joined

  • Last visited

Everything posted by aquatradehub

  1. 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
  2. Sorry Pikachu, I had missed your post about echoing the string
  3. Thanks Pikachu2000, I done that and got this result Resource id #3 Any idea what this means? Thanks
  4. I assign the $username variable in the form field verify part of the script $username = check_input($_POST['username'], "Enter your username"); I should have thought I would be able to use the $username variable further on in the script? Am I correct?
  5. Hi, thanks for your reply. I had to add a couple of { but it still registers the user without checking to see if there is a match. edited code mysql_select_db("zambiheadshop_c", $con); $result = mysql_query("SELECT username FROM members WHERE username = ' " . $username. " ' "); $rows = mysql_num_rows($result); if ($rows > 0) { echo "Sorry, that username is already in use"; } 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.htm'); exit(); } It still bypasses the check. Any ideas? Many Thanks
  6. Hi, I have this script to stop usernames being duplicated, but it is allowing the data to be written to the sql db even if a match occurs. Here is the selection of code that checks duplication and writes to db. $con = mysql_connect("localhost", "username", "password") or die(mysql_error()); if (!$con) { die('Could not connect: ' . mysql_error()); } else { mysql_select_db("my_db", $con); $result = mysql_query("SELECT username FROM members WHERE username = ' " . $username. " ' "); $rows = mysql_num_rows($result); if ($rows > 0) echo "Sorry, that username is already in use"; } /* 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.htm'); exit(); mysql_close($con); I have removed my database and connection settings for security Any idea how to get the duplication check to work would be much appreciated
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.