Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title></title>
  5. </head>
  6. <body style="background-color: rgb(229,243,247);">
  7. <?php
  8. /* This page receives and handles the data generated by "MovieForm.html". */
  9. // Trim the incoming data.
  10. $username = trim($_POST['username']);
  11. $password = trim($_POST['password']);
  12.  
  13.  
  14. // to prevent mysql injection
  15. $username = stripcslashes($username);
  16. $password = stripcslashes($password);
  17. $username = mysql_real_escape_string($username);
  18. $password = mysql_real_escape_string($password);
  19.  
  20.  
  21. // Set the variables for the database access:
  22.  
  23. $servername = "localhost";
  24. $uname = "root";
  25. $pw = "";
  26. $dbname = "login";
  27.  
  28. // connect
  29. $connection = new mysqli($servername, $uname, $pw, $dbname);
  30.  
  31. if($connection->connect_error){
  32.     die("Connect failed: " . $conn->connect_error);
  33. }
  34.  
  35. $sql = "INSERT INTO $dbname (username,password) VALUES ('$username','$password')";
  36.  
  37. if($connection->query($sql) === TRUE){
  38.     echo "New record created successfully";
  39. }else{
  40.     echo "Sucks to suck " . $sql . "<br>" . $connection->error;
  41. }
  42.  
  43. $connection->close();
  44.  
  45. ?>
  46.  
  47. </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement