Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($POST["submit"])){
- $hostname='localhost';
- $username='root';
- $password='';
- try {
- $dbh = new PDO("mysql:host=$hostname;dbname=messages",$username,$password);
- $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
- $sql = "INSERT INTO contact(user_name, user_email, user_message)
- VALUES ('".$POST["user_name"]."','".$_POST["user_email"]."','".$_POST["user_message"]."')";
- if ($dbh->querty($sql)) {
- echo "<script type= 'text/javascript'>alert('New Record Inserted Succesfully');</script>";
- }
- else{
- echo "<script type= 'text/javascript'>alert('Data not succesfully Inserted.');</script>";
- }
- $dbh = null;
- }
- catch(PDOException $e)
- {
- echo $e->GetMessage();
- }
- }
- ?>
Add Comment
Please, Sign In to add comment