Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?php
  2. $hostname = "localhost";
  3. $username = "";
  4. $password = "";
  5. $database = "";
  6.  
  7. $con = mysql_connect($hostname, $username, $password);
  8.     if (!$con)
  9.         {
  10.         die('Could not connect: ' . mysql_error());
  11.         }
  12.        
  13. mysql_select_db("$database", $con);
  14.  
  15. $sql = "INSERT INTO blog (name, body)   VALUES  ('$_POST[name]','$_POST[body]')";
  16.  
  17.     if (!mysql_query($sql,$con))
  18.         {
  19.         die('Error: ' . mysql_error());
  20.         }
  21.     echo "1 record added";
  22.  
  23. mysql_close($con)
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement