【问题标题】:html form entry data to my email [duplicate]html表单输入数据到我的电子邮件[重复]
【发布时间】:2016-05-20 19:26:42
【问题描述】:

我的网站上有一个表格供人们填写,我只想在他们按下提交按钮时通过电子邮件将信息发送给我,但我正在努力使用 PHP。

下面是我的表格

<form action="senddata.php">
    <label for="fullname"> full name:</label><br>
    <input type="text" name="fullname" id="fullname"><br><br>
    <label for="psn">PSN</label><br>
    <input type="text" name="psn" id="psn"><br>
    <label for="email">Email:</label><br>
    <input type="text" name="email" id="email"><br>
    <label for="contact"> Contact number</label><br>
    <input type="text" name="contact" id="contact"><br>
    <label for="team">Team supported</label><br>
    <input type="text" name="team" id="team"><br>
    <input type="submit" value="SUBMIT FORM">
</form>

【问题讨论】:

  • 你在苦苦挣扎吗?用谷歌有那么难吗?
  • 代码是文本,复制粘贴并不难...

标签: php html forms email


【解决方案1】:

这就是你应该如何实现它。

<?php
if(isset($_POST['submit']))
{
$msg = "Full Name:".$_POST['fullname']."\n PSN:".$_POST['psn']."\n Email:".$_POST['email']."\n contact:".$_POST['contact']."\n Team:".$_POST['team'];
$msg = wordwrap($msg,70);
    $header = 'From: yourmail@yourmail.com>' . "\n";
    // send email
    mail("'".$_POST['email']."'","Your mail subject goes here",$msg,$header);
}
?>

<form action="senddata.php" method="post">
    <label for="fullname"> full name:</label><br>
    <input type="text" name="fullname" id="fullname"><br><br>
    <label for="psn">PSN</label><br>
    <input type="text" name="psn" id="psn"><br>
    <label for="email">Email:</label><br>
    <input type="text" name="email" id="email"><br>
    <label for="contact"> Contact number</label><br>
    <input type="text" name="contact" id="contact"><br>
    <label for="team">Team supported</label><br>
    <input type="text" name="team" id="team"><br>
    <input type="submit" name="submit" value="SUBMIT FORM">
</form>

您应该添加发送数据的方法。 method="post"你应该为你的提交按钮使用一个名字来检查你的表单是否被提交name="submit"

参考这个:php.net

【讨论】:

    猜你喜欢
    • 2015-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-06
    • 2015-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多