Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. ************************* forms.php***************************************************************
  2.  
  3.  
  4. <html>
  5. <head>
  6. <title>AirZooka ftw</title>
  7. </head>
  8. <body>
  9. <form action="test.php" method="post">
  10. Username: <input type="text" name="username1" value="" /><br />
  11. <br />
  12. Password: <input type="password" name="password1" value="" /><br />
  13. <br />
  14. Name: <input type="text" name="name" value="" /><br />
  15. <br />
  16. Address: <input type="text" name="address" value="" /><br />
  17. <br />
  18. Country: <input type="text" name="country" value="" /><br />
  19. <br />
  20. Zip Code: <input type="text" name="zip" value="" /><br />
  21. <br />
  22. Phone Number: <input type="text" name="phone" value="" /><br />
  23. <br />
  24.  
  25.  
  26. Email: <input type="text" name="email" value="" />
  27. <br />
  28. <input type="submit" />
  29. </form>
  30.  
  31.  
  32.  
  33.  
  34. </body>
  35. </html>
  36.  
  37.  
  38. *****************************************test.php******************************************************
  39.  
  40.  
  41.  
  42. <?php
  43. //defining username, password, and database variables so I can easily change them later.
  44.  
  45. $username="root";
  46. $password="tacotruck";
  47. $database="form";
  48.  
  49. $username1=$_POST['username1'];
  50. $password1=$_POST['password1'];
  51. $name=$_POST['name'];
  52. $address=$_POST['address'];
  53. $country=$_POST['country'];
  54. $zip=$_POST['zip'];
  55. $phone=$_POST['phone'];
  56. $email=$_POST['email'];
  57.  
  58. mysql_connect("localhost", $username, $password) or die("Unable to connect to MySQL.");
  59.  
  60. $query = "INSERT INTO test_table (username, password, name, address, country, zip, phone, email)
  61. VALUES ('$username1','$password1','$name','$address','$country','$zip','$phone','$email')";
  62.  
  63. $result = mysql_query($query);
  64. if (!$result) {
  65. echo 'An error occured while inserting the data.';
  66. } else {
  67. echo 'Success!';
  68. }
  69.  
  70.  
  71.  
  72.  
  73. mysql_close();
  74. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement