我對HTML和CSS有相當的基本知識,從頭開始構建我的網站。 我在iFrame中使用JotForm作爲我的聯繫表單,但希望將其更改爲PHP表單,所以我不依賴這些人員,並且我對錶單的外觀有更多的控制權。PHP聯繫表格的麻煩
我也初步具備形式發送一封電子郵件,空白字段 - 我試圖解決這個問題,現在已完全搞砸了。
任何幫助,非常感謝。
這裏是我的這是載於表格形式HTML;
<table width="400" border="0" align="left" cellpadding="5" id="form">
<tr>
<th width="134" scope="row" align="right">NAME</th>
<th width="240" scope="row">
<form name="name" method="post" action="contact.php">
<span id="sprytextfield1">
<input type="text" name="name" id="name" value="<?php print "$nameField"; ?>">
<span class="textfieldRequiredMsg">A value is required.</span><spanclass="textfieldInvalidFormatMsg">Invalid format.</span></span>
</form></th>
</tr>
<tr>
<th scope="row"> </th>
<th scope="row"> </th>
</tr>
<tr>
<th scope="row" align="right">EMAIL</th>
<th scope="row">
<form name="email" method="post" action="contact.php">
<span id="sprytextfield2">
<input type="text" name="email" id="email" value="<?php print "$emailField"; ?>">
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
</form></th>
</tr>
<tr>
<th scope="row"> </th>
<th scope="row"> </th>
</tr>
<tr>
<th height="128" scope="row" align="right">MESSAGE</th>
<th scope="row">
<form name="message" method="post" action="contact.php">
<span id="sprytextarea1">
<textarea name="message" id="message" cols="45" rows="5"><?php print "$messageField"; ?></textarea>
<span class="textareaRequiredMsg"><br>
A value is required.</span></span>
</form></th>
</tr>
<tr>
<th scope="row"> </th>
<th scope="row"> </th>
</tr>
<tr>
<th scope="row"> </th>
<th scope="row"><form name="submit" method="post" action="contact.php">
<input type="hidden" name="parse_var" id="parse_var" value="contactform">
<input type="submit" name="submit" id="submit" value="SEND MESSAGE">
</form></th>
</tr>
<tr>
<th scope="row"> </th>
<th scope="row"><?php print "$sent"; ?></th>
</tr>
</table>
和我的PHP:
<?php
if ($_POST['parse_var'] == "form") {
$emailTitle = 'New Contact Form Message';
$yourEmail = '[email protected]';
$emailField = $_POST['email'];
$nameField = $_POST['name'];
$messageField = $_POST['message'];
$body = <<<EOD
<br><hr><br>
Email: $emailField <br />
Name: $nameField <br />
Message: $messageField <br />
EOD;
$headers = "From: $emailField\r\n";
$headers .= "content-type: text/html\r\n";
$success = mail("$yourEmail", "$emailTitle", "$body", "$headers");
$sent = "thankyou, your message has been successfully sent x";
}
?>
請不要使用,許多表,就這樣90 ... – jycr753
只是刪除了'「' '郵件($ yourEmail,$ emailTitle,$機構,$頭);' 你逝去的變量。 – jycr753
而且,編輯後的代碼 - 主要問題,從我所能看到的 - 多個表單標籤...你應該有一個,正確地打開和關閉。+ html中的parse_var被命名爲'contactform',而不是'form'。 – sinisake