Guest User

Untitled

a guest
Jan 19th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. <?php
  2. $con=mysqli_connect("localhost","root","","mycontacts");
  3.  
  4. if (mysqli_connect_errno()) {
  5. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  6. }
  7. $name = mysqli_real_escape_string($con, $_POST['name']);
  8. $address = mysqli_real_escape_string($con, $_POST['address']);
  9. $city = mysqli_real_escape_string($con, $_POST['city']);
  10. $state = mysqli_real_escape_string($con, $_POST['state']);
  11. $zip = mysqli_real_escape_string($con, $_POST['zip']);
  12. $phone = mysqli_real_escape_string($con, $_POST['phone'])
  13.  
  14. $sql="INSERT INTO Contacts (contac_id, contact_name, contact_address, contact_city,
  15. contact_state, contact_zip_code, contact_phones, contact_website)
  16. VALUES ('', '$name', '$address', '$city', '$state', '$zip',
  17. '$phone', '')";
  18.  
  19. if (!mysqli_query($con,$sql)) {
  20. die('Error: ' . mysqli_error($con));
  21. }
  22. header('Location:mainmenu.php');
  23. session_start();
  24. $_SESSION['loggedIn'] = true;
  25.  
  26. mysqli_close($con);
  27.  
  28.  
  29. ?>
  30.  
  31. <form action="insert.php" method='post'>
  32. <table width="250">
  33. <tr>
  34. <p>
  35. <td align="right" valign="middle">
  36. Name:
  37. </td>
  38. <td align="right" valign="middle">
  39. <input type="text" class= "textbox" name="name" />
  40. </td>
  41. </p>
  42. </tr>
  43. <tr>
  44. <p>
  45. <td align="right" valign="middle">
  46. Address:
  47. </td>
  48. <td align="right" valign="middle">
  49. <input type="text" class= "textbox" name="address" />
  50. </td>
  51. </p>
  52. </tr>
  53. <tr>
  54. <p>
  55. <td align="right" valign="middle">
  56. City:
  57. </td>
  58. <td align="right" valign="middle">
  59. <input type="text" class= "textbox" name="city" />
  60. </td>
  61. </p>
  62. </tr>
  63. <tr>
  64. <p>
  65. <td align="right" valign="middle">
  66. State:
  67. </td>
  68. <td align="right" valign="middle">
  69. <input type="text" class= "textbox" name="state" />
  70. </td>
  71. </p>
  72. <tr>
  73. <p>
  74. <td align="right" valign="middle">
  75. Zip:
  76. </td>
  77. <td align="right" valign="middle">
  78. <input type="text" class= "textbox" name="zip" maxlength='10'/>
  79. </td>
  80. </p>
  81. </tr>
  82. <tr>
  83. <p>
  84. <td align="right" valign="middle">
  85. Phone
  86. </td>
  87. <td align="right" valign="middle">
  88. <input type="text" class= "textbox" name="phone" />
  89. </td>
  90. </p>
  91. </tr>
  92. <tr>
  93. <td colspan="2">
  94. <center>
  95. <br>
  96. <input type='submit' class= "submitbutton" value="Submit"/>
  97.  
  98. ( ! ) Notice: Undefined index: name in D:wampwwwit665insert.php on line 7
  99.  
  100.  
  101. ( ! ) Notice: Undefined index: address in D:wampwwwit665insert.php on line 8
  102.  
  103.  
  104. ( ! ) Notice: Undefined index: city in D:wampwwwit665insert.php on line 9
  105.  
  106.  
  107. ( ! ) Notice: Undefined index: state in D:wampwwwit665insert.php on line 10
  108.  
  109.  
  110. ( ! ) Notice: Undefined index: zip in D:wampwwwit665insert.php on line 11
  111.  
  112.  
  113. ( ! ) Notice: Undefined index: phone in D:wampwwwit665insert.php on line 12
  114.  
  115. INSERT INTO Contacts (contac_id, contact_name, contact_address, contact_city,
  116. contact_state, contact_zip_code, contact_phones, contact_website) VALUES ('', '', '',
  117. '', '', '', '', '')
Add Comment
Please, Sign In to add comment