troubleshooting Question

Post form contents to email and mysql

Avatar of guy4graphics
guy4graphics asked on
7 Comments1 Solution246 ViewsLast Modified:
This is the existing code to process a form's inputs and send an email. I want this to post to a database as well. I was thinking it would make sense to state the variables, create the mysql connection/submit and then process the email.

$to = "email";
$from = "email";
$name = $_REQUEST['name'] ;
$message = "Name: " .$name."\n\nEmail: " .$_REQUEST['email']."\n\nPhone Number: "    .$_REQUEST['phone']."\n\nMailing Address:\n" .$_REQUEST['address']."\n\nInfo. Request/Comments:\n" .$_REQUEST['comments']."\n\nPreferred Method of Contact:\n" .$_REQUEST['pref'];
$headers = "From: $from\r\nReply-To: " . $_REQUEST['email'];
$subject = "RCA Website - Contact Form";

$fields{"Name"} = "Name";
$fields{"Email"} = "Email";

if (!empty($to) && !empty($from) && !empty($message) && !empty($headers) && !empty($subject)) {
  $send = mail($to, $subject, $message, $headers);
  if($send) {
    header("Location: emailsent.asp");

header("Location: emailerror.asp");

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros