如何使用PHP将联系表单中的数据发送到数据库和电子邮件? [英] How do I send data from contact form to database and email using PHP?

查看:69
本文介绍了如何使用PHP将联系表单中的数据发送到数据库和电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以向我提供正确的编码,允许我的联系表格,一旦在线填写,将数据发送到电子邮件以及保存在数据库中。



下面是我发送到数据库的代码,这就是我的全部。



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.

推荐答案

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


db_user = ' ;
db_user = 'root';


db_pass = ' ';
db_pass = '';


这篇关于如何使用PHP将联系表单中的数据发送到数据库和电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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