Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "";
- $password = "";
- try{
- $conn = new PDO("mysql:host=$servername;dbname=iltcis_People_email_address", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- echo "Connected successfully</br>";
- $firstname = $_REQUEST['firstName'];
- $email = $_REQUEST['email'];
- $gender = $_REQUEST['gender'];
- $age =$_REQUEST['age'];
- $lastName = $_REQUEST['lastName'];
- $comments = $_REQUEST['comments'];
- $id=$_REQUEST['id'];
- echo "User: $firstName ($gender), with following email: $email, $age y.o., wrote $comments";
- $sql = "INSERT INTO People (id,age, comments, email, firstName, gender,lastName)";
- VALUES ('$id', '$name', '$gender','$email','$age','$comments', '$lastName');
- //use exec() because no results are returned
- $conn->exec($sql);
- }
- catch(PDOException $e)
- {
- echo "Connection failed: " . $e->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement