具有邮件功能并在数据库中存储数据的联系表
应用介绍
此项目是具有邮件功能和将数据存储在数据库中的联系表。也具有两个模块:用户模块和管理模块。从下面几个方面运行此项目:1.下载zip文件。2.解压缩文件并复制contactform文件夹。3.在根目录下粘贴(对于xampp xamp / htdocs,对于wamp wampp / www,对于灯var / www / html)。4.打开PHPMyAdmin(http:// localhost / phpmyadmin)。5.创建一个名称为contactdb的数据库。6.导入newsportal.sql文件(在sql文件夹的zip包中提供)。7.运行脚本http:// localhost / contactform(前端)。8.对于管理面板http:// localhost / contactform / admin。本人只展示了一小部分知识点,想了解更多请下载附件。
现在为用户输入创建一个HTML。 index.php
<form name="ContactForm" method="post">
<h4>your name</h4>
<input type="text" name="name" class="user" placeholder="Johne" autocomplete="off" required>
<h4>your phone number</h4>
<input type="text" name="phonenumber" class="phone" placeholder="0900.234.145678" maxlength="10" required autocomplete="off">
<h4>your email address</h4>
<input type="email" name="emailaddres" class="email" placeholder="[email protected]" required autocomplete="off">
<h4>your subject</h4>
<input type="text" name="subject" class="email" placeholder="Subject" autocomplete="off">
<h4>your message</h4>
<textarea class="mess" name="message" placeholder="Message" required></textarea>
<input type="submit" value="send your message" name="submit">
</form>
MYSql数据库连接:
<?php
// DB credentials.
define('DB_HOST','localhost');
define('DB_USER','root');
define('DB_PASS','');
define('DB_NAME','contactdb');
// Establish database connection.
try
{
$dbh = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME,DB_USER, DB_PASS,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
}
catch (PDOException $e)
{
exit("Error: " . $e->getMessage());
}
?>
将数据插入数据库
include('config.php');
if(isset($_POST['submit']))
{
// getting Post values
$name=$_POST['name'];
$phoneno=$_POST['phonenumber'];
$email=$_POST['emailaddres'];
$subject=$_POST['subject'];
$message=$_POST['message'];
$uip = $_SERVER ['REMOTE_ADDR'];
$isread=0;
// Insert quaery
$sql="INSERT INTO tblcontactdata(FullName,PhoneNumber,EmailId,Subject,Message,UserIp,Is_Read) VALUES(:fname,:phone,:email,:subject,:message,:uip,:isread)";
$query = $dbh->prepare($sql);
// Bind parameters
$query->bindParam(':fname',$name,PDO::PARAM_STR);
$query->bindParam(':phone',$phoneno,PDO::PARAM_STR);
$query->bindParam(':email',$email,PDO::PARAM_STR);
$query->bindParam(':subject',$subject,PDO::PARAM_STR);
$query->bindParam(':message',$message,PDO::PARAM_STR);
$query->bindParam(':uip',$uip,PDO::PARAM_STR);
$query->bindParam(':isread',$isread,PDO::PARAM_STR);
$query->execute();
$lastInsertId = $dbh->lastInsertId();
if($lastInsertId)
{
//mail function for sending mail
$to=$email;
$headers .= "MIME-Version: 1.0"."\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
$headers .= 'From:PHPGurukul Contact Form Demo<[email protected]>'."\r\n";
$ms.="<html></body><div>
<div><b>Name:</b> $name,</div>
<div><b>Phone Number:</b> $phoneno,</div>
<div><b>Email Id:</b> $email,</div>";
$ms.="<div style='padding-top:8px;'><b>Message : </b>$message</div><div></div></body></html>";
mail($to,$subject,$ms,$headers);
echo "<script>alert('Your info submitted successfully.');</script>";
}
else
{
echo "<script>alert('Something went wrong. Please try again');</script>";
}
}
©版权声明:本文内容由互联网用户自发贡献,版权归原创作者所有,本站不拥有所有权,也不承担相关法律责任。如果您发现本站中有涉嫌抄袭的内容,欢迎发送邮件至: [email protected] 进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。
转载请注明出处: apollocode » 具有邮件功能并在数据库中存储数据的联系表
文件列表(部分)
名称 | 大小 | 修改日期 |
---|---|---|
ContactForm Mini Project | 0.00 KB | 2018-08-40 |
contactform | 0.00 KB | 2018-08-04 |
admin | 0.00 KB | 2018-08-02 |
all-contacts.php | 5.39 KB | 2018-08-00 |
app-assets | 0.00 KB | 2018-08-40 |
.DS_Store | 6.00 KB | 2018-03-12 |
css | 0.00 KB | 2018-08-56 |
app.css | 0.09 KB | 2018-03-12 |
app.min.css | 406.38 KB | 2018-03-12 |
bootstrap-extended.css | 62.75 KB | 2018-03-12 |
bootstrap-extended.min.css | 51.67 KB | 2018-03-12 |
bootstrap.css | 147.57 KB | 2018-03-12 |
bootstrap.min.css | 165.13 KB | 2018-03-12 |
colors.css | 311.31 KB | 2018-03-12 |
colors.min.css | 250.03 KB | 2018-03-12 |
components.css | 118.20 KB | 2018-03-12 |
components.min.css | 104.98 KB | 2018-03-12 |
core | 0.00 KB | 2018-08-54 |
colors | 0.00 KB | 2018-08-54 |
palette-callout.css | 38.01 KB | 2018-03-12 |
palette-callout.min.css | 32.33 KB | 2018-03-12 |
palette-climacon.css | 17.59 KB | 2018-03-12 |
palette-climacon.min.css | 15.63 KB | 2018-03-12 |
palette-gradient.css | 23.76 KB | 2018-03-12 |
palette-gradient.min.css | 50.90 KB | 2018-03-12 |
palette-loader.css | 29.74 KB | 2018-03-12 |
palette-loader.min.css | 29.75 KB | 2018-03-12 |
palette-noui.css | 5.29 KB | 2018-03-12 |
palette-noui.min.css | 3.64 KB | 2018-03-12 |
palette-switch.css | 4.50 KB | 2018-03-12 |
palette-switch.min.css | 8.47 KB | 2018-03-12 |
palette-tooltip.css | 3.56 KB | 2018-03-12 |
发表评论 取消回复