ここでいくつか質問をして、多くの助けを得たので、次の質問を前もって感謝します. スカウト グループ (キャンプへの登録) の登録システムを作成しようとしてきましたが、フォームからデータベースにデータを送信できず、次を使用して確認メールを送信できないところまで行き詰まりました。 PHP メール機能。
以下は私のフォームコードです:
<form action="include/spud/registration.php">
<h2>Group Information:</h2>
<table width="100%" border="0" cellspacing="10">
<tr>
<td>Group Name (# & Name):
<br />
<div class="input-control text">
<input type="text" name="group_name" />
<button class="btn-clear"></button>
</div>
</td>
</tr>
<tr>
<td>Group Location (City it is located in: e.g. Mississauga):
<br />
<div class="input-control text">
<input type="text" name="group_location" />
<button class="btn-clear"></button>
</div>
</td>
</tr>
<tr>
<td>Number of Youth Attending:
<br />
<div class="input-control text">
<input type="text" name="group_attending" />
<button class="btn-clear"></button>
</div>
</td>
</tr>
</table>
<h2>Contact Information:</h2>
<table width="100%" border="0" cellspacing="10">
<tr>
<td width="50%">First Name:
<br />
<div class="input-control text">
<input type="text" name="name_first" />
<button class="btn-clear"></button>
</div>
</td>
<td>Last Name:
<br />
<div class="input-control text">
<input type="text" name="name_last" />
<button class="btn-clear"></button>
</div>
</td>
</tr>
<tr>
<td>Address:
<br />
<div class="input-control text">
<input type="text" name="address" />
<button class="btn-clear"></button>
</div>
</td>
<td>Address 2 (Optional):
<br />
<div class="input-control text">
<input type="text" name="address2" />
<button class="btn-clear"></button>
</div>
</td>
</tr>
<tr>
<td>City:
<br />
<div class="input-control text">
<input type="text" name="city" />
<button class="btn-clear"></button>
</div>
</td>
<td>Province or State:
<br />
<div class="input-control text">
<input type="text" name="prov_state" />
<button class="btn-clear"></button>
</div>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="10">
<tr>
<td>Country:
<br/>
<div class="input-control select">
<select>
<option selected>Choose...</option>
<option name="country">Canada</option>
<option name="country">United States</option>
<option name="country">Scotland</option>
<option name="country">Another Country</option>
</select>
</div>
</td>
</tr>
<tr>
<td>Postal Code (ZIP):
<br />
<div class="input-control text">
<input type="text" name="zip_code" />
<button class="btn-clear"></button>
</div>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="10">
<tr>
<td width="50%">Telephone:
<br />
<div class="input-control text">
<input type="text" name="telephone" />
<button class="btn-clear"></button>
</div>
</td>
<td>Telephone (Residential or Business: Optional):
<br />
<div class="input-control text">
<input type="text" name="telephone2" />
<button class="btn-clear"></button>
</div>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="10">
<tr>
<td>Email:
<br />
<div class="input-control text">
<input type="text" name="email" />
<button class="btn-clear"></button>
</div>
</td>
</tr>
</table>
<div class="place-left">
<button type="submit">Submit</button>
<button type="reset">Reset</button>
</div>
<div class="place-right">
<a href="#info" class="button">Spud Camp Information</a>
</div>
</form>
次に、それをデータベース ステージに送信します。
<?php
require_once('../database.php');
/*
* Insert the data into the Database
*/
$qry=mysql_query("INSERT INTO
spudcamp(group_name,group_location,group_attending,name_first,name_last,address,address2,city,prov_state,country,zip_code,telephone,telephone2,email)
VALUES('$_POST[group_name]','$_POST[group_location]','$_POST[group_attending]','$_POST[name_first]','$_POST[name_last]','$_POST[address]','$_POST[address2]','$_POST[city]','$_POST[prov_state]','$_POST[country]','$_POST[zip_code]','$_POST[telephone]','$_POST[telephone2]','$_POST[email]', NOW() )
", $con);
if(!$qry)
{
die("Query Failed: ". mysql_error());
}
else
{
header('location:../../spud-camp.php');
}
/*
* Send an Email to Administration and to the Signed up person
*/
include('receipt_email.php');
?>
次に、recipe_email.php ステージ:
<?php
/*
* Receipt Emailer
*/
$message = '
<html>
<body style="color: #000;font-family:arial;">
<p>Thank you, <b>';
$message .= $_POST[name_first] . ' ';
$message .= $_POST[name_last];
$message .= '</b>, for your submission.<br>';
$message .= 'We hope that the <b>';
$message .= $_POST[group_name];
$message .= '</b><br>
<b>Please print this page for your records.</b><br><BR>
Your registration submitted on ';
$message .= date('l jS \of F Y h:i:s A');
$message .= ' is as follows:<br><br>
Registration #: <B>';
$message .= '</B><br>
Group Name: <B>';
$message .= $_POST[group_name];
$message .= '</B><br>
First Name: <B>';
$message .= $_POST[name_first];
$message .= '</B> <br>
Last Name: <B>';
$message .= $_POST[name_last];
$message .= '</B><br>
Address 1: <B>';
$message .= $_POST[address1];
$message .= '</B><br>
Address 2: <B>';
$message .= $_POST[address2];
$message .= '</B><br>
City: <B>';
$message .= $_POST[city];
$message .= '</B><br>
Prov/State: <B>';
$message .= $_POST[prov_state];
$message .= '</B><br>
Postal Code: <B>';
$message .= $_POST[zip_code];
$message .= '</B><br>
Country: <B>';
$message .= $_POST[country];
$message .= '</B><br>
Telephone #: <B>';
$message .= $_POST[telephone];
$message .= '</B><br>
Business Phone #: <B>';
$message .= $_POST[telephone2];
$message .= '</B><br>
E-mail: <B>';
$message .= $_POST[email];
$message .= '</B><br>
# Attending: <B>';
$message .= $_POST[group_attending];
$message .= '</B></p>';
$message .= '
</body>
</html>
';
// multiple recipients
$to = $_POST[email] . ", "; // note the comma
$to .= '';
// subject
$subject = '';
// To send HTML mail, the Content-type header must be set
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Registrant <' . $_POST[email] . ">\n";
$headers .= ' <>' . "\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
いくつかの場所を削除したので、スパマーのページに私のメールアドレスが表示されなくなりました。とにかく、事前に感謝します。本当に感謝します:D