Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All I would like to do is have the same information typed into my contact form sent to my database and email.

Please see coding below

<?php
/* Database config */
$db_host        = 'localhost';
$db_user        = 'root';
$db_pass        = '';
$db_database    = 'maxipakdb'; 
/* End config */

$mysqli = new mysqli($db_host, $db_user, $db_pass, $db_database);


/* check connection */
if (mysqli_connect_errno()) {printf("Connect failed: %s\n",             
mysqli_connect_error());}

$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

// Perform queries 

mysqli_query($mysqli, "INSERT INTO maxicontact (id,name,email,message) 
VALUES (NULL,'$name','$email','$message')");

// Email 
$to = 'nadineduke28@gmail.com';
$subject = "My Subject";
$message = "Name: $name\
Email: $email\
Message:  $message";
$headers = "From: $email";

// Send the mail using PHPs mail() function
mail($to, $subject, $message, $headers);

header('Location: success.php');

?>


What I have tried:

I have tried to add it all in one PHP file
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900