Advertisement
Guest User

create

a guest
Mar 13th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. // Only process the form if $_POST isn't empty
  2. if ( ! empty( $_POST ) ) {
  3.  
  4. // Connect to MySQL
  5. $mysqli = new mysqli( 'localhost', 'numebazadate', 'parola', 'numeutilizator' );
  6.  
  7. // Check our connection
  8. if ( $mysqli->connect_error ) {
  9. die( 'Connect Error: ' . $mysqli->connect_errno . ': ' . $mysqli->connect_error );
  10. }
  11.  
  12. // Insert our data
  13. $sql = "INSERT INTO pages ( title, slug, pagetext ) VALUES ( '{$mysqli->real_escape_string($_POST['title'])}', '{$mysqli->real_escape_string($_POST['slug'])}', '{$mysqli->real_escape_string($_POST['pagetext'])}' )";
  14.  
  15. $insert = $mysqli->query($sql);
  16.  
  17. // Print response from MySQL
  18.  
  19. if ( $insert ) {
  20. $message = "<h3>Page added! Row ID: {$mysqli->insert_id}</h3>";
  21. } else {
  22. die("Error: {$mysqli->errno} : {$mysqli->error}");
  23. }
  24.  
  25. // Close our connection
  26. $mysqli->close();
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement