Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- Problem sending form data to email and insert in database


rocknbil - 6:17 pm on Jul 29, 2010 (gmt 0)


Yeah that may be valid, it's just not the way it's **normally* done.

insert into table ([field list]) values ([values list]);

Anyway, did you try this? If $action is set, it sends the email, if not, displays the form. so

if (isset($action)) {
// other code
mail($to, "Enquiry", $msg, $mailheader) or die ("Failure");
mail("admin@oursite.co.uk", "Enquiry", $msg, $mailheader) or die ("Failure");

Do your insert right here

// more code
} //end isset($action)

else {
// Should really use else, but in the context of this
// script, if (!isset($action)) { is *almost* the same thing

// display form code
}

See that? It should work right there. Not sure what the purpose of the else is after the !isset($action), seems trivial.

if ($action) {
// process form, send email, insert to db, display response
}
else {
// display form
}

Poor error handling, but should work, most of the time . . . .


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/4177620.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com