Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.57 KB | None | 0 0
  1. index.php -
  2.  
  3. <html>
  4.  
  5. <form action="add.php">
  6.    
  7.     </table><input type="submit"/>
  8. </form>
  9.  
  10. <table border="1">
  11. <tr>
  12.     <th>Website</th>
  13.     <th>PayPal Email</th>
  14.     <th>Username</th>
  15.     <th>Paid Amount</th>
  16.     </tr>
  17. <tr>
  18.     <td></td>
  19.     <td></td>
  20.     <td></td>
  21.     <td></td>
  22. </tr>
  23.  
  24. </html>
  25.  
  26.  
  27. --------------------------------------------------------------
  28.  
  29. add.php -
  30.  
  31. <html>
  32. <body>
  33.  
  34.  
  35. <form name="add" method="post" action="confirm.php">
  36. Username:<input type="text" name="username"/><br/>
  37. Password:<input type="password" name="password"/><br/>
  38. Email:<input type="text" name="email"/><br/>
  39. Website:<input type="text" name="website"/><br/>
  40. Paid Amount:<input type="text" name="paid"/><br/>
  41. <input type="submit" name="submit"/>
  42. </form>
  43. </body>
  44. </html>
  45.  
  46. --------------------------------------------------------------
  47.  
  48. config.php -
  49.  
  50. <?php
  51.  
  52. //Variables
  53. $host = "localhost";
  54. $username = "root";
  55. $password = "";
  56. $db_name = "list";
  57.  
  58. //connection
  59. mysql_connect("$host", "$username", "$password")or die("<b>CONNECTION ERROR: </b>".mysql_error());
  60. mysql_select_db("$db_name")or die("Cannot select DB!");
  61. ?>
  62.  
  63. --------------------------------------------------------------
  64.  
  65. Confirm.php
  66.  
  67. <?php
  68.  
  69. include('config.php');
  70.  
  71. $testname = $_POST['username'];
  72. //Test
  73. if(explode("([^A-Za-z0-9])", $testname)){
  74.     //test for duplicate names
  75.     $query = "SELECT * FROM info WHERE username = ".$_POST['username'];
  76.     $result = mysql_query($query);
  77.     $num = mysql_num_rows($result);
  78.     if($num == 0) {
  79.     $query = "SE
  80.     } else {
  81.         echo "Name in use!";
  82. } else {
  83. echo "Invalid name!";
  84. }
  85.  
  86. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement