Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>PHP Form</title>
  5. </head>
  6. <body>
  7. <form action="" method="post" name="form1">
  8. Name: <input type="text" name="username" placeholder="Your name">
  9. Password: <input type="password" name="password" placeholder="Your password">
  10. Email: <input type="email" name="email" placeholder="Your email">
  11. <input type="submit" name="submit" value="Submit!">
  12. </form>
  13. <?php
  14. $dbName="myTest";
  15. $user="root";
  16. $pass="";
  17. $host="localhost";
  18. $link = mysql_connect($host, $user, $pass);
  19. if(!$link){
  20. die('Could not connect: ' . mysql_error());
  21. }
  22. $dbselected = mysql_select_db($dbName, $link);
  23. if(!dbselected){
  24. die('Can\'t use ' . $dbName . ":" . mysql_error());
  25. } else{
  26. echo "Connected successfully";
  27. }
  28. 29 $username=$_POST['username'];
  29. 30 $password=$_POST['password'];
  30. 31 $email=$_POST['email'];
  31. $sql = "INSERT INTO myTable (username, password, email) VALUES ('$username', '$password', '$email')";
  32. if(!mysql_query($sql)){
  33. die("Error: " . mysql_error());
  34. }
  35. ?>
  36. </body>
  37. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement