首先,我想说这是我第一次在阅读之外使用 PHP。
我只是想创建一个简单的联系表格来收集信息并向我发送包含信息的电子邮件。目前我的联系页面已关闭,任何帮助都可以将其恢复。
这是我的代码:
<?php
if(isset($_POST['Submit'])) {
if(!empty($_POST['CompanyName'])){
if(!empty($_POST['Email']){
$CompanyName = $_POST['CompanyName'];
$PhoneNumber = $_POST['PhoneNumber'];
$Email = $_POST['Email'];
$IndustryType = $_POST['IndustryType'];
$Website = $_POST['Website'];
$Other = $_POST['Other'];
$Comments =$_POST['comments'];
$formcontent ="From: $CompanyName \n Message: \n Point of Contact: $NameInput \n Email: $Email \n Industry: $IndustryType $Other \n Website: $Website \n Comments: $Comments";
$recipient = "keeano@doodleinc.co";
$subject = "Website Contact\ $IndustryType";
$mailHeader = "From $Email \r\n";
echo '<p class="collapse">Thank you for contacting <font color="#709900">Doodle Inc.</font>, someone will contact you within 48 hours.</p>';
mail($Email, $subject, $formcontent);
}
else {
echo 'Please Check required fields with an <font color="#FF0000">* </font>.\n If you are exsperiancing any technical issues or have not heard back from us please contact us at <a href="">Techsupport@doodleinc.co</a>';
}
}
}?>
<div class="article">
<h2><span>send us an</span> email ...</h2><div class="clr"></div>
<form name="contact_form" method="post" action="mail.php" onSubmit="return evalid()">
<table border="0">
<tbody class="Form">
<tr>
<td>
<label for="NameInput">Your Name:<font color="#FF0000">*</font></label>
<input id="NameInput" name="NameInput"/>
</td>
</tr>
<tr>
<td>
<label for="CompanyName">Your Company:<font color="#FF0000">*</font></label>
<input id="CompanyName" name="CompanyName"/>
</td>
</tr>
<tr>
<td>
<label id="PhoneNumber" name="PhoneNumber">Phone: </label>
<input id="PhoneNumber" name="PhoneNumber"/>
</td>
</tr>
<tr>
<td>
<label id="Email" name="Email">Email:<font color="#FF0000">*</font></label>
<input id="Email" name="Email" type="email"/>
</td>
</tr>
<tr>
<td>
<label for="Website">Website: </label>
<input id="Website" name="Website"/>
</td>
</tr>
<tr>
<td>
<label for="IndustryType" name="IndustryType">Industrey: </label>
<Select>
.....
<option>Other</option>
</select>
</td>
<?php
if($IndustryType == "Other")
echo '<div id="Other">
<td>
<label for="=Other" class="collapse">Other: </label><input id="Other" name="Other" class="collapse"/>
</div>
<br/>
<br/>
</td>
?>
</tr>
<br/>
<br/>
<br/>
<br/>
<tr>
<th><p><b>What interests you, broadly speaking?</b></p></th>
</tr>
<tr><td>
<input type="checkbox">Web Design/Development</input>
</td></tr>
<tr><td>
<input type="checkbox">Social Media</input>
</td></tr>
<tr><td>
<input type="checkbox">Mobile Presence</input>
</td></tr>
<tr><td>
<input type="checkbox">Online Advertising</input>
</td></tr>
<tr><td>
<input type="checkbox">Search Engine Optamization</input>
</td></tr>
<tr><td>
<input type="checkbox">eCommerce</input>
</td></td>
<tr>
<th><div class="spacer"></div></th>
</tr>
<tr><td>
<label for="comments"><b>Your Ideas to Life? (How can we help you?)</b></label><br/>
<textarea id="comments" name="comments" style="margin: 2px; height: 137px; width: 437px;"></textarea></td></tr><br/>
<tr>
<td><input type="button" name="Submit" value="Submit" align="middle" /></td>
</tr>
</tbody>
</table>
</form>
我尝试将电子邮件功能放在一个名为 mail.php 的单独文件中,但这不起作用,所以我将它内联到 HTML 中,页面加载失败。
我也未能成功让 XAMPP 在本地工作。
我知道它的某些东西甚至可能很小,但我希望弄清楚它是什么并在此过程中学习。您喜欢帮助我的任何文档或网站也会很棒。
任何帮助表示赞赏!