SHARE
TWEET

Untitled

a guest Oct 3rd, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $con = mysql_connect("localhost","peter","abc123");
  3. if (!$con)
  4.   {
  5.   die('Could not connect: ' . mysql_error());
  6.   }
  7.  
  8. mysql_select_db("my_db", $con);
  9.  
  10. $sql="INSERT INTO Persons (username, password, first_name, last_name, email)
  11. VALUES
  12. ('$_POST["username"]','$_POST["password"]','$_POST["first_name"]','$_POST["last_name"]','$_POST["email"]')";
  13.  
  14. if (!mysql_query($sql,$con))
  15.   {
  16.   die('Error: ' . mysql_error());
  17.   }
  18. echo "1 record added";
  19.  
  20. mysql_close($con)
  21. ?>
  22.  
  23.  
  24. <html>
  25. <body>
  26.  
  27. <form action="insert.php" method="post">
  28. username: <input type="text" name="username" /> <br />
  29. password: <input type="password" name="password" /> <br />
  30. Firstname: <input type="text" name="firstname" /> <br />
  31. Lastname: <input type="text" name="lastname" /> <br />
  32. email: <input type="text" name="email" /> <br />
  33. <input type="submit" />
  34. </form>
  35.  
  36. </body>
  37. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top