Sydcomebak Posted May 9, 2011 Share Posted May 9, 2011 I am on a GoDaddy hosted site trying to process a form. First off, the gdform.php: <?php $request_method = $_SERVER["REQUEST_METHOD"]; if($request_method == "GET"){ $query_vars = $_GET; } elseif ($request_method == "POST"){ $query_vars = $_POST; } reset($query_vars); $t = date("U"); $file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t; $fp = fopen($file,"w"); while (list ($key, $val) = each ($query_vars)) { fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n"); fputs($fp,"$val\n"); fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n"); if ($key == "redirect") { $landing_page = $val;} } fclose($fp); if ($landing_page != ""){ header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page"); } else { header("Location: http://".$_SERVER["HTTP_HOST"]."/"); } ?> Looks to me like a recursive function that spits out all data in no particular order. My variables: "Name" - Type: Text "City" - Type: Text "Email" - Type: Text etc... Instrumentalist - Type: Checkbox - Returns "on" if checked Vocalist - Type: Checkbox - Returns "on" if checked etc... What I want is to be able to receive an email that says: Hello, you have received a response from your web form! Bob Smith of Jonesville is a - Vocalist - Instrumentalist - Harmonist ... I assume that this will be accomplished through if and echo statements like: echo $Name; echo " of "; echo $City; echo " is a<br>" if $vocalist == "on" then echo " - Vocalist<br>" ... Am I on the right track? All attempts thus far have failed. Once I get down the right path, I'm sure that I can find the rest of the way. Thanks so much, experts! Quote Link to comment Share on other sites More sharing options...
jonsjava Posted May 9, 2011 Share Posted May 9, 2011 You will need to modify it to handle more variables, but here's a start. Hope this helps you out. <?php $request_method = $_SERVER['REQUEST_METHOD']; $is_a = ""; if ($request_method == "GET"){ $vars = $_GET; } elseif ($request_method == "POST"){ $vars = $_POST; } function cleanInput($vars){ foreach ($vars as $key->$val){ $out[$key] = htmlspecialchars($val); } } $vars = cleanInput($vars); $name = $vars['Name']; $city = $vars['City']; $Email = $vars['Email']; if ($vars['Vocalist'] == "on"){ $is_a .= "\t-Vocalist\r\n"; } if ($vars['Instrumentalist'] == "on"){ $is_a .= "\t-Instrumentalist\r\n"; } $msg_body = "Hello, you have received a response from your web form!\r\n\r\n$name of $city is a\r\n$is_a\r\n\r\nTheir E-mail Address is $Email\r\n"; $your_email = "Sydcomebak@somedomain.com"; $your_name = "Sydcomebak"; $headers = "To: $your_name <$your_email>\r\n"; $headers = "From: Form Submission Alert <$your_email>\r\n"; mail($your_email,"Someone posted to your web form",$msg_body,$headers); ?> Quote Link to comment Share on other sites More sharing options...
Sydcomebak Posted May 9, 2011 Author Share Posted May 9, 2011 Fatal error: Cannot access empty property in gdform.php on line 20 Line 20 reads: foreach ($vars as $key->$val){ I think that I see where you are going with this, though... -Dave Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.