Click here to Skip to main content
13,894,773 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
Can anyone supply me with the correct coding that will allow my contact form, once filled in online, to send the data to an email as well as save on the database.

Below is my code that sends to the database, this is all I have.

<?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')");

header('Location: success.php');

?>


What I have tried:

I have tried numerous options but I am not to sure why it won't work.
Posted
Updated 28-Jun-16 17:01pm
Comments
Sergey Alexandrovich Kryukov 28-Jun-16 22:48pm
   
What have you tried so far?
Please don't be surprised with my question. Yes, you've shown mySQL statement (but did not explain what's the problem), but your question was also about mailing. What have you done to send a mail?
—SA

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Please see my comment to the question. In second thought, maybe it's only good that you did not even try to send any mail. This is a very dangerous operation. (Surprised?)

You really need to understand very well what you are doing, otherwise your host is turned into a zombie sending spam, or something like that, and it can be done without much effort in no time. Please see my past answer: unable to send mail , it showing the error in below code.
See also: In what way $('#myelement').valid(); works.

As to sending e-mail, here is a couple of options which you could easily find out in original PHP documentation:
PHP: mail — Manual,
Manual :: sends a mail,
(see also https://pear.php.net/manual/en/about-pear.php).

—SA
   

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web03 | 2.8.190306.1 | Last Updated 28 Jun 2016
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100