如何在数据库中存储数据并将数据发送到contact.php的特定电子邮件 [英] How do I store data on database and send data to specific email from contact.php

查看:93
本文介绍了如何在数据库中存储数据并将数据发送到contact.php的特定电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b我想要的是将相同的信息输入我的联系表格,发送到我的数据库和电子邮件。



请参阅编码下面



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

?>





我的尝试:



我试图将它全部添加到一个PHP文件中



What I have tried:

I have tried to add it all in one PHP file

推荐答案

db_host ='localhost';
db_host = 'localhost';


db_user ='root';
db_user = 'root';


db_pass ='';
db_pass = '';


这篇关于如何在数据库中存储数据并将数据发送到contact.php的特定电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆