我最近为一位朋友创建了一个网站。他们需要一个表格或其他东西,所以我为他们编写了页面。今天另一位朋友让我用表格建立一个类似的网站。所以我只是将代码从一个网站复制并粘贴到另一个网站。但是,一旦我这样做,表格就停止发送到电子邮件。这是我正在使用的代码:
<?php
$to = 'commodorePicmin@gmail.com';
$subject = 'JOB REQUEST';
$name = $_POST['name'];
$address = $_POST['address'];
$job = $_POST['job'];
$message = <<<EMAIL
Hi, my ign is $name. I want the rank $address and I would be good at this because: $job
EMAIL;
$header = '$name';
if($_POST){
mail($to, $subject, $message, $header);
}
?>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="wrapper">
<div class="header">
<center>
Apply for staff
</center>
</div>
<div id="menu">
<ul>
<center>
<li><a href="index.html">HOME</a></li>
<li><a href="stafflist.html">STAFF</a></li>
<li><a href="contact.html">CONTACT</a></li>
<li><a href="apply.php">APPLY</a></li>
<li><a href="donate.html">DONATE</a></li>
</center>
</ul>
</div><br>
<div class="info">
<center>Want a way to get a fast in game $1,000 Click <a href="info.php">Here</a></center>
<center><form action="?" method="post">
<ul>
<li>
<label for="name">In game name</label><br>
<input type="text" name="name" id="name" /><br>
</li>
<li>
<label for="name">Rank that I am Applying for</label><br>
<select>
<option value="Admin">Admin</option>
<option value="HeadMod">Head Mod</option>
<option value="HeadAdmin">Head Admin</option>
<option value="Builder">Builder</option>
<option value="Mod">Mod</option>
<option value="helper">Helper</option>
<option value="coowner">Co-Owner</option>
</select><br>
</li>
<li>
<label for="name">Why Would you be a good fit?</label><br>
<textarea rows="9" cols="50" name="job" id="job"></textarea>
</li>
<li>
<input type="submit" name="Submit" id="submit" value="submit">
</li>
</ul>
</form></center>
</div>
</div>
</body>
</html>
&#13;
答案 0 :(得分:0)
尝试添加
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
在表单的操作中。这将确保表单回复自身。
答案 1 :(得分:0)
某些服务器不接受来自其服务器的默认邮件。您只需使用SMTP设置尝试邮件。