0

我一直在处理这个表格。看了各种视频教程和博客,填完提交的时候还是不能让我的表格e-mail给我。

有人可以为此提供解决方案吗?

索引.HTML

<html>
<head>
 <title>Application</title>

</head>

 <body>

<form action="submit.php" method="POST">

<h3>Please fill out the following form:</h3>

<div id="form">
<table cellpadding="10">
<tr>
<td>Full Name:<br><input type="text" name="fullname">
<td>Title:<br><input type="text" name="title">
</tr>   
<tr>
<td>Company Name:<br><input type="text" name="company">
<td>Website:<br><input type="text" name="website">
</tr>
<tr>
    <td>Email Address:<br><input type="text" name="email">
    <td>Telephone:<br><input type="text" name="telephone">
</tr>
<tr>
    <td>Street Address:<br><input type="text" name="address">
    <td>City:<br><input type="text" name="city">
</tr>
<tr>
    <td>State:<br><input type="text" name="state">
    <td>Zip Code:<br><input type="text" name="zipcode">
</tr>
</table>
</div>

<input type="submit" value="Submit">

</form>
</body>
</html>

提交.PHP

<html>
<head>
<title>Application Submitted</title>

<?php

if (isset($_POST['fullname']) && isset($_POST['title']) && isset($_POST['company'])      && isset($_POST['website']) && isset($_POST['email']) && isset($_POST['address']) && isset($_POST['city']) && isset($_POST['state']) && isset($_POST['zipcode']) && isset($_POST['telephone'])) {

    $fullname = $_POST['fullname'];
    $title = $_POST['title'];
    $company = $_POST['company'];
    $website = $_POST['website'];
    $email = $_POST['email'];
    $address = $_POST['address'];
    $city = $_POST['city'];
    $state = $_POST['state'];
    $zipcode = $_POST['zipcode'];
    $telephone = $_POST['telephone'];

if (!empty($fullname) && !empty($title) && !empty($company) && !empty($website) && !empty($email) && !empty($address) && !empty($city) && !empty($state) && !empty($zipcode) && !empty($telephone)) {
    $to = 'myemail@mail.com';
    $subject = 'Application Submitted...';
    $body = $fullname "\n" $title "\n" $company "\n" $website "\n" $email "\n" $address "\n" $city "\n" $state "\n" $zipcode "\n" $telephone;
    $headers = 'From: '$email;
if (mail($to, $subject, $body, $headers))
    echo 'Thank you for your interest!';
} else {
    echo 'All fields are required!';
}
}

?>

</head>
<body>
</body>
</html>
4

1 回答 1

2

为了在 PHP 中附加一个字符串,您需要.操作符。

所以,

$body = $fullname . "\n" . $title . "\n" . $company . "\n" . $website . "\n" . $email . "\n" . $address . "\n" . $city . "\n" . $state . "\n" . $zipcode . "\n" . $telephone;

和,

$headers = 'From: ' . $email;

试试看,如果您仍然有问题,请告诉我们。

于 2013-11-08T20:18:45.577 回答