I have a form that I want to be inserted into a database and also e-mailed to me so I know there was a submittion to the database
Problems is that I get the email when the page loads but it supossed to be sent when the form is submitted...
Heres my code:
<?php
if ($submit) {
// Form excist so updating
if ($id) {
$sql = "UPDATE conti SET
occ='$occ',
date6='$date6',
occnote='$occnote',
tenown1='$tenown1',
tenown2='$tenown2',
tenown3='$tenown3',
tenownphone1='$tenownphone1',
tenownphone2='$tenownphone2',
tenownphone3='$tenownphone3'
WHERE id=$id";
}
// run SQL against the DB
$result = mysql_query($sql);
print mysql_error();
echo "<center><FONT SIZE=2 COLOR=\"#00FF00\" FACE=\"Arial\">You have submitted the occupancy status as $occ.</FONT>";
$result = mysql_query("SELECT FROM conti, agents WHERE conti.id = $id and agents.aid = $aid",$db);
while ($myrow = mysql_fetch_array($result)) {
printf("<A HREF=\"index.%s?lnum=%s&aid=%s\"><center>Back to main</center></A></FONT> \n", php3, $myrow["lnum"], $myrow["aid"]);
}
if (isset($submit)} {
// Send E-mail
$sql = "SELECT FROM conti, agents, manage WHERE conti.id = $id and agents.aid = $aid and manage.mid = $mid";
print mysql_error();
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$occ = $myrow["occ"];
$date6 = $myrow["date6"];
$paddress = $myrow["paddress"];
$pcity = $myrow["pcity"];
$pst = $myrow["pst"];
$pzip = $myrow["pzip"];
$occnote = $myrow["occnote"];
$tenown1 = $myrow["tenown1"];
$tenown2 = $myrow["tenown2"];
$tenown3 = $myrow["tenown3"];
$tenownphone1 = $myrow["tenownphone1"];
$tenownphone2 = $myrow["tenownphone2"];
$tenownphone3 = $myrow["tenownphone3"];
$email = $myrow["email"];
$memail = $myrow["memail"];
$agent = $myrow["agent"];
$lnum = $myrow["lnum"];
$sendto = "$email";
$subject = "Occpupancy Status Submitted for Loan #$lnum [$paddress, $pcity, $pst, $pzip]";
$message = "REO Factory Virtual Office\n\n
Occupancy Status for Loan #$lnum [$paddress, $pcity, $pst, $pzip]
$agent has verified that property address $paddress is $occ
Property Address:
$paddress
$pcity $pst $pzip
REO Factory Virtual Office
REO Factory Virtual Office
\n";
$from = "$memail";
mail("$sendto","$subject","$message","from: $from");
?>
<?php } ?>
Thanks for any help