Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. //REGISTER.PHP
  2.  
  3. <form name="login" method="post" action="registernext.php">
  4. <p>Username: <input type ="text" name="useregister" size = "15" maxlength = "25" value = ""/></p>
  5. <p>Password: <input type = "password" name="passwordregister" size = "15" maxlength = "25" value =""/></p>
  6. <p>Confirm Password:
  7. <input type = "password" name="pass2" size = "15" maxlength = "25" value =""/></p>
  8. <p>
  9. <input type ="submit" name ="submit" value="Register"/>
  10. </p>
  11. </form>
  12.  
  13.  
  14. //REGISTERNEXT.PHP
  15.  
  16. <?php
  17.  
  18. include('config.php');
  19. include('register.php');
  20.  
  21. //test to see if username is alphannumberic
  22. $user=$_REQUEST['useregister'];
  23. $pass=$_REQUEST['passwordregister'];
  24. $conf=$_REQUEST['pass2'];
  25.  
  26. if ($pass != $conf) {
  27. //pass and confirm don't equal each other
  28. }
  29. if(!preg_match('/[^A-Za-z0-9]/ i' , $test)){
  30.  
  31. //test for duplicate names
  32. $query="SELECT * FROM usernames WHERE username ='$user'";
  33. $result=mysql_query($query);
  34. $num=mysql_num_rows($result);
  35.  
  36. if ($num == 0){
  37.  
  38. //insert users into table
  39. $sql="INSERT INTO users SET useregister = '$user', passwordregister = '$pass'";
  40. $result=mysql_query($sql);
  41.  
  42. //Shows "Thanks for registering" page
  43. header("Location:thanksreg.html");
  44.  
  45.  
  46. }else{
  47. header("Location:nameinuse.html");
  48. }
  49.  
  50. }else{
  51. header("Location:invalidname.html");
  52. }
  53. ?>
  54.  
  55.  
  56.  
  57.  
  58. //CONFIG.PHP
  59.  
  60. <?php
  61.  
  62. $host="localhost";//hostname
  63. $usernamesql="HIDDEN";//username
  64. $passwordsql="HIDDEN";//database password
  65. $db_name="fronkcra_users";//database name
  66.  
  67. //connect to database
  68. mysql_connect("$host","$usernamesql","$passwordsql")or die("cannot connect to server");
  69. mysql_select_db("$db_name")or die("cannot select DB");
  70. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement