Guest User

Untitled

a guest
Jan 10th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in /mnt/web411/c2/96/59561596/htdocs/boazvlogs/maintenance/process.php on line 34 Hello Marc Molenaar!, your message has been saved!
  2.  
  3. <?php
  4. if ($_SERVER["REQUEST_METHOD"] == "POST") {//Check it is comming from a form
  5.  
  6. error_reporting(E_ALL);
  7. ini_set('display_errors', 'On');
  8.  
  9. //mysql credentials
  10. $mysql_host = "example.com";
  11. $mysql_username = "example";
  12. $mysql_password = "example";
  13. $mysql_database = "example";
  14.  
  15. $name = filter_var($_POST["name"], FILTER_SANITIZE_STRING); //set PHP variables like this so we can use them anywhere in code below
  16. $email = filter_var($_POST["email"], FILTER_SANITIZE_EMAIL);
  17.  
  18. if (empty($name)){
  19. die("Please enter your name");
  20. }
  21. if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)){
  22. die("Please enter valid email address");
  23. }
  24.  
  25. //Open a new connection to the MySQL server
  26. //see https://www.sanwebe.com/2013/03/basic-php-mysqli-usage for more info
  27. $mysqli = new mysqli($mysql_host, $mysql_username, $mysql_password, $mysql_database);
  28.  
  29. //Output any connection error
  30. if ($mysqli->connect_error) {
  31. die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
  32. }
  33.  
  34. $statement = $mysqli->prepare("INSERT INTO form (name, email) VALUES(name, email)"); //prepare sql insert query
  35. //bind parameters for markers, where (s = string, i = integer, d = double, b = blob)
  36. $statement->bind_param("sss", $name, $email); //bind values and execute insert query
  37.  
  38. if($statement->execute()){
  39. print "Hello " . $name . "!, your message has been saved!";
  40. }else{
  41. print $mysqli->error; //show mysql error if any
  42. }
  43. }
  44. ?>
Add Comment
Please, Sign In to add comment