I have been try now for the past 6 hours, hundreds of different conotation to get some form data to be sent to 2 emails and also be submitted to a mysql database.
The form originally sent an email message to a client and also to us (admin) then returned a thank you page to the form user.
I have created the mysql database with all required fields for the form data to be inserted in but can't get it to work.
Here is the form page as it stands at the moment starting from the main php part as there is a lot of html stuff before the form:
<?
if (isset($action)) {
$arrival_date = $_REQUEST["arrival_day"] . "/" . $_REQUEST["arrival_month"] . "/" . $_REQUEST["arrival_year"];
$to = $USERS["email"];
$mailheader = "From: $email\r\n";
$mailheader .= "Reply-To: $email\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$msg =
"
Message to client here.
<br>
Enquirer details:<br><br>
Name: $name<br>
Country Code: $country, Phone Number: $phone<br>
Mobile/Cell phone number: $cell_phone<br>
E-mail address: $email<br>
Date of arrival: $arrival_day<br>
Duration: $duration day(s)<br>
Comments: ".strip_tags($info)."<br><br>
This enquiry was generated from: [
".$_SERVER['HTTP_HOST']."...]
Thank you<br><br>
<br><br>Enquiry IP/ISP: ".$content .= "\n\nIP:" . getEnv( "REMOTE_ADDR" )." - ".@gethostbyaddr($_SERVER["REMOTE_ADDR"]).".
";
mail($to, "Enquiry", $msg, $mailheader) or die ("Failure");
mail("admin@oursite.co.uk", "Enquiry", $msg, $mailheader) or die ("Failure");
echo
"<br /><br /><font size=2>
<strong><center>Thank you!</center><br />
Your Enquiry has been sent to:</center><br />
".$USERS["name"]." Tel: ".$USERS["phone"]."<br /><br />
For : ".stripslashes($ACC["name"])." <br />
Ref No: (".stripslashes($ACC["acc_ref"]).") <br /><br />
Please make note of owners details above for future reference.<br /><br /><br /></strong>
Enquiry details entered were: <br /><br />
Name: $name<br />
Country Code: $country, Phone Number: $phone<br />
Mobile/Cell phone number: $cell_phone<br />
E-mail address: $email<br />
Date of arrival: $arrival_day<br />
Duration: $duration day(s)<br /><br />
<br /><br />
";
};
if (!isset($action)) {
}
?>
<form action="enq.php" method="post" style="margin-bottom:0px" name="cform" onsubmit="return check(this);">
<input type="hidden" name="action" value="0">
<input type="hidden" name="id" value="<?php echo $_REQUEST["id"]; ?>">
<table width="420px" valign="top" cellspacing="2" cellpadding="2">
<tr>
<td class="bodytext"><strong><font size="3">E-mail enquiry form to:</font> </strong></td>
</tr>
<tr>
<td align="left" class="bodytext"><strong>Name:</strong> <?php echo $USERS["name"]; ?><br />
<strong>For property:</strong> <?php echo $ACC["name"]; ?></td>
</tr>
<tr>
<td align="left" class="bodytext"><strong>Your name:</strong><br /><input name="name" type="text" id="name" size="58"></td>
</tr>
<tr>
<td align="left" class="bodytext"><strong>Country Code: Phone Number: (inc area code)</strong><br />
<input name="country" type="text" id="country" size="10"> <input name="phone" type="text" id="phone" size="40"></td>
</tr>
<tr>
</tr>
<tr>
<td align="left" class="bodytext"><strong>Mobile/Cell phone number:</strong><br /><input name="cell_phone" type="text" id="cell_phone" size="58"></td>
</tr>
<tr>
<td align="left" class="bodytext"><strong>Your E-mail Address:</strong><br /><input name="email" type="text" id="email" size="58"></td>
</tr>
<tr>
<td align="left" class="bodytext"><strong>Date of arrival & Duration:</strong><br />
<input name="arrival_day" type="text" id="arrival_day" size="10" maxlength="10" readOnly="true" />
<A HREF="#" onClick="cal1x.select(document.forms['cform'].arrival_day,'anchor1x_in','dd-MM-yyyy'); return false;" NAME="anchor1x_in" ID="anchor1x_in">Pick a date</A>
for <input name="duration" type="text" id="duration" size="10"> nights</td>
</tr>
<tr>
<td align="left" valign="top" class="bodytext"><strong>Comments:</strong><br />
<textarea name="info" cols="60" rows="6" id="info" class="bodytext"></textarea></td>
</tr></table>
<table width="100%"><tr>
<td align="center" valign="top"> <input type="submit" name="Submit" value="Send"></td>
</tr><tr><td></td></tr></table>
<table width="100%">
<tr><td>some text
<br />
<br />
</center></td></tr></table>
</form><?php } ?>
<div id="divHint"></div>
</table>
<?php
};
} else {
?>
<td width="500" align="left" valign="top"><p><strong>No such properties</strong></p></td>
<?php
}
?>
------------------------------------------------------
I'VE TRIED PLACING THE CODE BELOW ALL OVER THE PAGE AS WELL AS CHOPPING AND CHANGING IT - BUT STILL NO JOY!
<?php
if (isset($_REQUEST['Submit'])) {
$sql = "INSERT INTO ".$TABLES["enquiries"]." SET
p_id='".mysql_escape_string($ACC["ref"])."',
p_name='".mysql_escape_string($ACC["name"])."',
enquirer_name='".mysql_escape_string($_REQUEST["name"])."',
country_code='".mysql_escape_string($_REQUEST["country"])."',
phone_number='".mysql_escape_string($_REQUEST["phone"])."',
mobile_number='".mysql_escape_string($_REQUEST["cell_phone"])."',
email='".mysql_escape_string($_REQUEST["email"])."',
arrival='".$_REQUEST["arrival_day"]."',
duration='".$_REQUEST["duration"]."',
comments='".$_REQUEST["info"]."',
website='".$_REQUEST["info"]."', (want to generate which website form came from but can be left out)
date=now()";
$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
{
?>