Guest User

Untitled

a guest
May 22nd, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. <?php
  2. $host = "localhost";
  3. $user = "user";
  4. $db_name= "dbname";
  5. $pass= "PASSWORD";
  6.  
  7. $con = mysql_connect($host, $user, $pass);
  8.  
  9. if (!$con)
  10. {
  11. die('Could not connect: ' . mysql_error());
  12. }
  13. mysql_select_db("dbname", $con); //Replace with your MySQL DB Name
  14. $name=mysql_real_escape_string($_POST['name']); //This value has to be the same as in the HTML form file
  15. $email=mysql_real_escape_string($_POST['email']); //This value has to be the same as in the HTML form file
  16. $sql="INSERT INTO Mailing_list (name,email) VALUES ('$name','$email')"; /*form_data is the name of the MySQL table where the form data will be saved.
  17. name and email are the respective table fields*/
  18. if (!mysql_query($sql,$con)) {
  19. die('Error: ' . mysql_error());
  20. }
  21. echo "The form data was successfully added to your database.";
  22. mysql_close($con);
  23. ?>
Add Comment
Please, Sign In to add comment