Guest User

PHP code.

a guest
Jan 2nd, 2013
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. <?php
  2.  
  3. //connect
  4.  
  5. include('connect.php');
  6.  
  7. //define variables
  8.  
  9. $Firstname = $_POST['FirstName'];
  10. $Surname = $POST['Surname'];
  11. $EmailAddress = $POST['EmailAddress'];
  12. $Username = $POST['Username'];
  13. $Password = $POST['Password'];
  14. $ConfirmPassword = $POST['ConfirmPassword'];
  15.  
  16. echo $Firstname;
  17. echo "<br />";
  18. echo $Surname;
  19. echo "<br />";
  20. echo $EmailAddress;
  21. echo "<br />";
  22. echo $Username;
  23. echo "<br />";
  24. echo $Password;
  25. echo "<br />";
  26. echo $ConfirmPassword;
  27.  
  28. //secure variables by sanitization.
  29.  
  30. $Firstname = (strip_tags($Firstname));
  31. $Surname = (strip_tags($Surname));
  32. $EmailAddress = (strip_tags($EmailAddress));
  33. $Username = (strip_tags($Username));
  34. $Password = (strip_tags($Password));
  35. $ConfirmPassword = (strip_tags($ConfirmPassword));
  36.  
  37. //ensure form has been completed
  38.  
  39. if ($Firstname&&$Surname&&$EmailAddress&&$Username&&$Password&&$ConfirmPassword) {
  40.  
  41. // ensure both passwords match.
  42.  
  43. if($Password==$ConfirmPassword) {
  44.  
  45.  
  46. echo $Firstname;
  47. echo "<br />";
  48. echo $Surname;
  49. echo "<br />";
  50. echo $EmailAddress;
  51. echo "<br />";
  52. echo $Username;
  53. echo "<br />";
  54. echo $Password;
  55. echo "<br />";
  56. echo $ConfirmPassword;
  57. echo "<br />";
  58.  
  59.  
  60. //check to see if username entered already exists.
  61.  
  62. $sql = "SELECT username FROM users WHERE username = '$Username'";
  63. $check = mysql_query($sql);
  64.  
  65. //count rows to ensure that username entered returns 0 rows.
  66.  
  67. $rows = mysql_num_rows($check);
  68. $rowscheck = mysql_query($rows);
  69.  
  70. if($rowscheck==0) {
  71.  
  72. //check the email address is not already in use
  73.  
  74. $sql2 = "SELECT Email_Address FROM users WHERE Email_Address = '$EmailAddress'";
  75. $check2 = mysql_query($sql2);
  76.  
  77. //count rows to ensure that the email address entered does not already exist, rows should equal 0.
  78.  
  79. $rows2 = mysql_num_rows($check2);
  80. $rowscheck2 = mysql_query($rows2);
  81.  
  82.  
  83. if($rowscheck2==0) {
  84.  
  85.  
  86. //register the user and insert details into database
  87.  
  88. $register_sql = "INSERT INTO `billyboy_users`.`users` (`ID`,`First_Name`,`Surname`,`Email_Address`,`Username`,`Password`)
  89. VALUES ('$FirstName','$Surname','$Email_Address','$Username','$Password')";
  90.  
  91. // display successful registration message.
  92.  
  93. echo "You have successfully registered, please login";
  94.  
  95.  
  96.  
  97.  
  98. } else {
  99.  
  100. echo "That Email Address has already been Registered, please wait while you are Redirected to the login page";
  101.  
  102.  
  103.  
  104. }
  105.  
  106.  
  107. } else {
  108.  
  109.  
  110. echo "Sorry, that username is already in use, please try again";
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117. }
  118.  
  119.  
  120.  
  121.  
  122. }
  123.  
  124. echo "The two passwords you entered did not match";
  125.  
  126. } else {
  127.  
  128. echo "You did not complete all fields, please try again";
  129.  
  130.  
  131. }
  132.  
  133. ?>
Advertisement
Add Comment
Please, Sign In to add comment