Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host = "localhost";
- $user = "user";
- $db_name= "dbname";
- $pass= "PASSWORD";
- $con = mysql_connect($host, $user, $pass);
- if (!$con)
- {
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db("dbname", $con); //Replace with your MySQL DB Name
- $name=mysql_real_escape_string($_POST['name']); //This value has to be the same as in the HTML form file
- $email=mysql_real_escape_string($_POST['email']); //This value has to be the same as in the HTML form file
- $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.
- name and email are the respective table fields*/
- if (!mysql_query($sql,$con)) {
- die('Error: ' . mysql_error());
- }
- echo "The form data was successfully added to your database.";
- mysql_close($con);
- ?>
Add Comment
Please, Sign In to add comment