I have a very simple table which, when all fields are entered correctly, will email both the user and the site owner.
Now the following (not yet completed still testing) sets the values for the first forms fields to "empty" or " ". then displays the form via the default value.
Code: Select all
<?php
session_start();
include("db.inc");
$addressA="";
$nameA="";
$telephoneA="";
$postcodeA="";
$emailA="";
$connection = mysqli_connect($hostname, $username, $password, $database)
or die ("Could not connect to server");
switch(@$_GET['do'])
{
case "house";
$addressA="$_POST[addressA]";
$nameA="$_POST[nameA]";
$telephoneA="$_POST[telephoneA]";
$postcodeA="$_POST[postcodeA]";
$emailA="$_POST[emailA]";
foreach($_POST as $field => $value)
{
if ($value == "")
{
unset($_GET['do']);
$message_house = "Required information is missing. Please try again.";
include("quotes.inc");
exit();
}
} // end foreach
if (!ereg("^[A-Za-z' -]{1,50}$",$_POST['nameA']))
{
unset($_GET['do']);
$message_house = "$_POST[nameA] is not a valid name please amend.";
include("quotes.inc");
exit();
}
$sql1 = "SELECT * FROM Prices
WHERE Item='$_POST[HouseType]'";
$result1 = mysqli_query($connection,$sql1)
or die ("Could not execute query1");
$row1 = mysqli_fetch_array($result1,MYSQLI_ASSOC);
extract($row1);
$fprice = number_format($Price,2);
/* send email to customer */
$emesscust = "BLAH BLAH BLAH";
$emesscust.= "\n\n\t Full House Cleaning Quote";
$emesscust.= "\n\n\t $Item £$fprice";
$emesscust.= "\n\n\t For any further information please email";
$emesscust.= "\n\t info@EMAIL HERE";
$emesscust.= "\n\n\t No hidden charges whatsoever - The price you see is the price you pay*";
$emesscust.= "\n\n\n\t *available at extra cost Scotchguard Carpet Protection";
$eheadcust = "From: donotreply@EMAIL HERE";
$subjcust = "BLAH BLAH BLAH";
$mailsendcust = mail($_POST['email'],$subjcust,$emesscust,$eheadcust);
/* send email to office */
$emessoff = "A new quote has been created";
$emessoff.= "\n\t $_POST[name]";
$emessoff.= "\n\t $_POST[address]";
$emessoff.= "\n\t $_POST[postcode]";
$emessoff.= "\n\t $_POST[telephone]";
$emessoff.= "\n\t $_POST[email]";
$emessoff.= "\n\t $Item £$fprice";
$eheadoff = "From: EMAIL HERE";
$subjoff = "Quote generated by $_POST[name]";
$office = 'NAME <EMAIL HERE>';
$mailsendoff = mail($office,$subjoff,$emessoff,$eheadoff);
include("success.htm");
break;
case "other";
default:
include("quotes.inc");
}
?>
Code: Select all
<tr>
<td rowspan="3"><textarea name="addressA" id="addressA" cols="45" rows="4" value"<?php print @$addressA ?>"></textarea></td>
<td> </td>
<td><input name="nameA" type="text" id="nameA" size="25" maxlength="50" value="<?php print @$nameA ?>"></td>
</tr>
<tr>
<td> </td>
<td>Telephone</td>
</tr>
<tr>
<td> </td>
<td><input name="telephoneA" type="text" id="telephoneA" size="25" maxlength="25" value"<?php print @$telephoneA ?>"></td>
</tr>
<tr>
<td>Postcode</td>
<td> </td>
<td>Email</td>
</tr>
<tr>
<td><input name="postcodeA" type="text" id="postcodeA" size="13" maxlength="13" value"<?php print @$postcodeA ?>"> <input name="test" type="button" value="Check" onclick="testPostCode();"></td>
<td> </td>
<td><input name="emailA" type="text" id="emailA" size="50" maxlength="67" value"<?php print @$emailA ?>"></td>
</tr>When redirected to the form after say leaving a blank field, the only displayed value is "nameA", displayed being the only visible value on screen. Although according to the "view source" option of IE all the fields have values.
[text]<tr>
<td rowspan="3"><textarea name="addressA" id="addressA" cols="45" rows="4" value"aaa"></textarea></td>
<td> </td>
<td><input name="nameA" type="text" id="nameA" size="25" maxlength="50" value="nnn"></td>((This is the only visible field))
</tr>
<tr>
<td> </td>
<td>Telephone</td>
</tr>
<tr>
<td> </td>
<td><input name="telephoneA" type="text" id="telephoneA" size="25" maxlength="25" value"ttt"></td>
</tr>
<tr>
<td>Postcode</td>
<td> </td>
<td>Email</td>
</tr>
<tr>
<td><input name="postcodeA" type="text" id="postcodeA" size="13" maxlength="13" value"ppp"> <input name="test" type="button" value="Check" onclick="testPostCode();"></td>
<td> </td>
<td><input name="emailA" type="text" id="emailA" size="50" maxlength="67" value"eee"></td>
</tr>
[/text]
So I'm not at all sure how or why this is happening.
Please note some of the values in the email section have not been editted to their latest counterparts.
Any help would be, as always, greatly appreciated.
Arnora