Advertisement
Guest User

Untitled

a guest
Jul 18th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $hostname="hostname";
  5. $username="username";
  6. $password="password";
  7. $dbname="dbname";
  8. $usertable="usertable";
  9. $yourfield = "your_field";
  10.  
  11. $conn = mysql_connect($hostname,$username, $password) or die ("<html><script language='JavaScript'>alert('Unable to connect to database! Please try again later.'),history.go(-1)</script></html>");
  12. mysql_select_db($dbname);
  13.  
  14. if(isset($_POST["send"])){
  15. $name = ($_POST['fname']);
  16. echo $name;
  17.  
  18. $query = "INSERT INTO `users` (`name`, `email`, `password`) VALUES($name, 'person@gmail.com', 'pass')";
  19.  
  20.  
  21.  
  22.  
  23.  
  24. }else{
  25.  
  26. }
  27.  
  28. $query = "UPDATE `users` SET `email` = 'john@hotmail.com' WHERE `name`='otherperson'";
  29.  
  30. if (mysql_query($query)){
  31. echo "It worked again <br>";
  32. }else{
  33. echo "nothing worked";
  34. }
  35.  
  36.  
  37. $query = "SELECT * FROM $usertable"; #retrieves
  38.  
  39. if($result = mysql_query($query)){
  40.  
  41. echo mysql_num_rows($result);
  42.  
  43. echo "It worked! <br>";
  44.  
  45. while($row = mysql_fetch_array($result)){
  46.  
  47. print_r($row);
  48.  
  49. }
  50. }else{
  51. echo "It failed!";
  52. }
  53.  
  54. ?>
  55.  
  56.  
  57.  
  58.  
  59. <html>
  60. <form method="post">
  61. <fieldset>
  62. <input type="text" placeholder="Name" id="fname" name="fname">
  63. </fieldset>
  64. <fieldset>
  65. <input type="submit" placeholder="" id="submitbuttonlast" value="Send Message" id="send" name="send">
  66. </fieldset>
  67. </form>
  68.  
  69. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement