Advertisement
Guest User

Untitled

a guest
Apr 7th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. <HTML START ------------------------------------------------------------------------------------------------------->>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  5.  
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8. <title>Computer World Customer Information</title>
  9. </head>
  10.  
  11. <body>
  12.  
  13. <form action="sql_script.php" method="post">
  14.  
  15. <fieldset>
  16. <legend>Enter your information in the form below:</legend>
  17.  
  18. <p><label>First Name: <input type="text" name="firstname" size="20" maxlength="40" /></label></p>
  19. <p><label>Last Name: <input type="text" name="lastname" size="20" maxlength="40" /></label></p>
  20. <p><label>Address: <input type="text" name="address" size="20" maxlength="40" /></label></p>
  21. <p><label>City: <input type="text" name="city" size="20" maxlength="40" /></label></p>
  22. <p><label>State: <input type="text" name="state" size="20" maxlength="40" /></label></p>
  23. <p><label>Zip Code: <input type="text" name="zip" size="20" maxlength="40" /></label></p>
  24. <p><label>Phone Number: <input type="text" name="phone" size="20" maxlength="40" /></label></p>
  25. <p><label>Email Address: <input type="text" name="email" size="40" maxlength="60" /></label></p>
  26.  
  27. </fieldset>
  28.  
  29. <p align="center"><input type="submit" name="submit" value="Submit My Information" /></p>
  30.  
  31. </form>
  32.  
  33. </body>
  34.  
  35. </html>
  36.  
  37.  
  38. <PHP START ------------------------------------------------------------------------------------------------------->>
  39.  
  40. <?php
  41. $servername = "localhost";
  42. $username = "";
  43. $password = "";
  44. try {
  45. $conn = new PDO("mysql:host=$servername;dbname=rlbrown1_computerworld",$username, $password);
  46. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  47. echo "Connected successfully </br>";
  48. $firstname = $_REQUEST['firstname'];
  49. $lastname = $_REQUEST['lastname'];
  50. $address = $_REQUEST['address'];
  51. $city = $_REQUEST['city'];
  52. $state = $_REQUEST['state'];
  53. $zip = $_REQUEST['zip'];
  54. $phone = $_REQUEST['phone'];
  55. $email = $_REQUEST['email'];
  56.  
  57. echo "Thank you for submitting your information ";
  58. echo $firstname;
  59. echo $lastname;
  60. echo ", we have recived the following data from you...";
  61. echo $firstname;
  62. echo $lastname;
  63. echo $address;
  64. echo $city;
  65. echo $state;
  66. echo $zip;
  67. echo $phone;
  68. echo $email;
  69.  
  70. $sql = "INSERT INTO customers (firstname, lastname, address, city, state, phone, email)";
  71. VALUES ($firstname, $lastname, $address, $city, $state, $zip, $phone, $email);
  72.  
  73. $conn->exec($sql);
  74. }
  75. catch (PDOException $e)
  76. {
  77. echo "Connection Closed: " . $e->getMessage();
  78. }
  79. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement