CyberWrek Posted February 23, 2007 Share Posted February 23, 2007 Hi there, I apologize ahead of time for what is going to seem absolutely noob-ish. I'm having some trouble with my multipage PHP scripts and need some assistance. If you are responding to this, please bear in mind that, up until Feb 20th, I had never knowingly used PHP before, only HMTL. I copied some pre-fab PHP scripts for a multipage PHP form a few days ago and wanted to have the form not only bring up a confirmation page (for my clients to see what they entered), but also a thank you page that would open after the SUBMIT button was pressed on the confirmation page. So far, I've kept the data flowing through the forms, right up until the client presses the SUBMIT button. No data gets sent in the email. I've spent the past three days messing with the script on my Final.php and Thanks.php pages that I fear I've messed it up beyond salvaging. :'( Can anyone have a look at these pages and let me know what I should be doing differently? The main part of my site isn't up yet, so this link will take you to the first page of the test form I'm working with. www.directbc.ca/form1.php Any help would be phenomenal. Cheers Quote Link to comment Share on other sites More sharing options...
JBS103 Posted February 23, 2007 Share Posted February 23, 2007 Well everything seems to run through fine up to the submission point. However, you need to post code (most importantly, the last page), otherwise, we can't really help you out. Quote Link to comment Share on other sites More sharing options...
paul2463 Posted February 23, 2007 Share Posted February 23, 2007 there seems to be nothing being posted into the final page just text, which if i am not mistaken wont be posted as it is not held in a variable that can be posted Quote Link to comment Share on other sites More sharing options...
CyberWrek Posted February 23, 2007 Author Share Posted February 23, 2007 <?php include ('fieldforwarder.php'); $cust_name = htmlentities($_POST['cust_name']); $cust_email = htmlentities($_POST['cust_email']); $cust_address = htmlentities($_POST['cust_address']); $cust_phone = htmlentities($_POST['cust_phone']); ?> <HTML> <HEAD> <TITLE>Multi-page Form - Final</TITLE> </HEAD> <BODY> <form action="thanks.php" method="post"> <p>You filled in:</p> Name: <?php echo $cust_name; ?><BR> Email: <?php echo $cust_email; ?>"<BR> Address: <?php echo $cust_address; ?><BR> Phone: <?php echo $cust_phone; ?><BR> <input type="submit" value="Submit"> </form> </BODY> </HTML> Quote Link to comment Share on other sites More sharing options...
CyberWrek Posted February 23, 2007 Author Share Posted February 23, 2007 <?php include ('fieldforwarder.php'); $cust_name = htmlentities($_POST['cust_name']); $cust_email = htmlentities($_POST['cust_email']); $cust_address = htmlentities($_POST['cust_address']); $cust_phone = htmlentities($_POST['cust_phone']); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page 1</title> </head> <body> <p> Thank you for your submission </p> <script language="php"> $email = $HTTP_POST_VARS; $mailto = "clientcare@directbc.ca"; $mailsubj = "Application for Basic Listing"; $mailhead = "From: $cust_email\n"; reset ($HTTP_POST_VARS); $mailbody = "Name: <?php echo $cust_name; ?><BR> Email: <?php echo $cust_email; ?><BR> Address: <?php echo $cust_address; ?><BR> Phone: <?php echo $cust_phone; ?>\n"; while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; } if (!eregi("\n",$HTTP_POST_VARS)) { mail($mailto, $mailsubj, $mailbody, $mailhead); } </script> </body> </html> Quote Link to comment Share on other sites More sharing options...
CyberWrek Posted February 23, 2007 Author Share Posted February 23, 2007 If someone can help with this, I'd be most appreciative. It's the only thing standing in the way of getting my site up and running for business. If someone can solve the problem to get me going, I'll be sure to make a regular contribution to the phpfreaks.com cause once I get some revenue going. Also, if you need my Form1.php and Form2.php scripts posted, I can do that, I just didn't want to post it unnecessarily. Cheers. Quote Link to comment Share on other sites More sharing options...
Archadian Posted February 23, 2007 Share Posted February 23, 2007 try this: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page 1</title> </head> <?php echo "Thank you for your submission"; include ('fieldforwarder.php'); $cust_name = htmlentities($_POST['cust_name']); $cust_email = htmlentities($_POST['cust_email']); $cust_address = htmlentities($_POST['cust_address']); $cust_phone = htmlentities($_POST['cust_phone']); $email = $HTTP_POST_VARS; $mailto = "clientcare@directbc.ca"; $mailsubj = "Application for Basic Listing"; $mailhead = "From: " . $cust_email . "\n"; reset ($HTTP_POST_VARS); $mailbody = "Name: " . $cust_name . "<BR>"; echo "Email: " . $cust_email . "<BR>"; echo "Address: " . $cust_address . "<BR>"; echo "Phone: " . $cust_phone . "\n"; while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; } if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); } ?> </html> Quote Link to comment Share on other sites More sharing options...
CyberWrek Posted February 24, 2007 Author Share Posted February 24, 2007 Hi Archadian, I appreciate the code. I replaced my old Thanks.php script with it and tried it, but it produced this on the actual page: Thank you for your submission Email: Address: Phone: The email was received, so at least I know that portion is still working and this time, rather than getting nothing at all, the name: <BR> (from line 23) showed up in the message. lol. I think this is a step closer than what I had before. I tried tinkering with the code to see if I could manipulate it, but just kept coming up with error messages. I left your code in place for now. Any other ideas? Quote Link to comment Share on other sites More sharing options...
CyberWrek Posted February 24, 2007 Author Share Posted February 24, 2007 I also forgot to mention that neither my script nor the new one produced a "FROM" email address. I've had other scripts that look similar work just fine over the past day or so. This baffles me. Ah, but most things will when you're running on fumes. Need sleep. zzzzzzzzzz Quote Link to comment Share on other sites More sharing options...
Archadian Posted February 24, 2007 Share Posted February 24, 2007 echo "Address: " . $cust_address . "<BR>"; echo "Phone: " . $cust_phone . "\n"; maybe your variables here aren't being set somehow also maybe ur putting $mailhead in the wrong part of the mail() function? Unless ur trying to put it INSIDE the email with $mailbody then take out the , after $mailbody Quote Link to comment Share on other sites More sharing options...
CyberWrek Posted February 24, 2007 Author Share Posted February 24, 2007 Hi again, I looked at the script and changed a couple of things around. In the mail() function, I switched the $mailhead and $mailbody around. Now I receive a FROM email address where it's supposed to be, but the address is that of my server, not the person sending the email. On top of that, now the "From" appears in the body of the email. Weird. I'm not sure what you meant by removing the , from $mailbody. I assume you meant in the mail() function. Now that I switched the $mailhead and $mailbody around, there is no comma after $mailbody, so that kind of solves that issue. But I actual need all of the data that a user enters when using my form pages. So, when I receive the email, I need the name, address, phone number, etc, in the body of the email. I'll keep staring at the code. Maybe something will jump out at me. Maybe not. If you can help any further, great. If not, no worries. Thanks for the effort you put into this. It is much appreciated. Quote Link to comment Share on other sites More sharing options...
Archadian Posted February 24, 2007 Share Posted February 24, 2007 give me your code of the form they actually fill out the info in Quote Link to comment Share on other sites More sharing options...
Archadian Posted February 24, 2007 Share Posted February 24, 2007 still post the code from the form you are using but i just saw something. try this on this part of the code: $mailbody = "From: " . $cust_email . "<br>Name: " . $cust_name . "<br>Email: " . $cust_email . "<br>Address: " . $cust_address . "<br>Phone: " . $cust_phone . "\n"; and just delete the $mailhead altogether, that and the info its set to. Quote Link to comment Share on other sites More sharing options...
CyberWrek Posted February 24, 2007 Author Share Posted February 24, 2007 <HTML> <HEAD> <TITLE>Multi-page Form - Page One</TITLE> </HEAD> <BODY> <p>Please fill in the following information</p> <FORM METHOD="POST" ACTION="form2.php"> Name: <INPUT TYPE="text" SIZE="40" name="cust_name"><BR> Email: <INPUT TYPE="text" SIZE="40" name="cust_email"><BR> <INPUT TYPE="submit" name="submit1" value="Proceed"> </FORM> </BODY> </HTML> Quote Link to comment Share on other sites More sharing options...
CyberWrek Posted February 24, 2007 Author Share Posted February 24, 2007 <?php include ('fieldforwarder.php'); ?> <HTML> <HEAD> <TITLE>Multi-page Form - Page Two</TITLE> </HEAD> <BODY> <p>Please fill in the following information</p> <FORM METHOD="POST" ACTION="final.php"> Address: <INPUT TYPE="text" SIZE="50" name="cust_address"><BR> Phone: <INPUT TYPE="text" SIZE="20" name="cust_phone"><BR> <?php echo field_forwarder(); ?> <INPUT TYPE="submit" name="submit2" value="Proceed"> </FORM> </BODY> </HTML> Quote Link to comment Share on other sites More sharing options...
CyberWrek Posted February 24, 2007 Author Share Posted February 24, 2007 <?php function field_forwarder() { global $_POST, $rEM979, $FFoutputType; $fieldForwarder = ''; /* get the arguments passed */ $argList = func_get_args (); /* globalize any other set of instructions */ if (count ($argList)) { eval ('global $' . $argList[count($argList)-1] . ';'); } /* set the default set of values to convert */ if(count($argList)==0) { /* if the function is initially passed without parameter we're looking in $_POST */ $argList[0] = '_POST'; $startValue = $_POST; if (sizeof ($startValue) == 0) { return false; } } elseif (count ($argList) == 1) { eval ('$rEM979["' . $argList[0] . '"] = $' . $argList[0] . ';'); $argList[0] = 'rEM979'; $startValue = $rEM979; } elseif (count ($argList) == 2) { eval ('$startValue = $' . $argList[1] . '["' . $argList[0] . '"];'); } else { for($e = count($argList) - 2; $e >= 0; $e--) { $intersperse .= '["' . $argList[$e] . '"]'; } eval ('$startValue = $' . $argList[count($argList)-1] . $intersperse . ';'); } foreach($startValue as $n => $v) { if (is_array ($v)) { /* call the function again */ $shiftArguments = ''; for($w = 0; $w <= count ($argList) - 1; $w++) { $shiftArguments .= '"' . $argList[$w] . '", '; } $shiftArguments = substr ($shiftArguments, 0, strlen ($shiftArguments) - 2); eval ('$fieldForwarder .= field_forwarder("' . $n . '"' . substr(',',0,strlen($shiftArguments)) . ' ' . $shiftArguments . ');'); } else { /* we have an root value finally */ if (count ($argList) == 1) { /* actual output */ flush(); if ($FFoutputType == 'print') { $fieldForwarder .= "\$$n = '$v';\n"; } else { $fieldForwarder .= "<input type=\"hidden\" " . "name=\"$n\" value=\"" . htmlentities(stripslashes($v)) . "\">\n"; } } elseif (count ($argList) >1 ) { $indexString = ''; for($g = count ($argList) - 3; $g >= 0; $g--) { $indexString .= '[' . ((!is_numeric ($argList[$g]) and $FFoutputType == 'print') ? "'" : '') . $argList[$g] . ((!is_numeric ($argList[$g]) and $FFoutputType == 'print') ? "'" : '') . ']'; } $indexString .= '[' . ((!is_numeric ($n) and $FFoutputType == 'print') ? "'" : '') . $n . ((!is_numeric ($n) and $FFoutputType == 'print') ? "'" : '') . ']'; /* actual output */ flush(); if ($FFoutputType == 'print') { $fieldForwarder .= "\${$argList[count($argList)-2]}" . "$indexString = '$v';\n"; } else { $fieldForwarder .= "<input type=\"hidden\" name=\"" . "{$argList[count($argList)-2]}" . "$indexString\" value=\"" . htmlentities(stripslashes($v)) . "\">\n"; } } } } return $fieldForwarder; } ?> Quote Link to comment Share on other sites More sharing options...
CyberWrek Posted February 24, 2007 Author Share Posted February 24, 2007 I did what you suggested and now all I get in the From part of the email is br Nothing else comes up in the body of the email. I'm almost thinking I botched the code up so badly that I need to start from scratch. If you can suggest otherwise, I'm all ears. :-\ Quote Link to comment Share on other sites More sharing options...
Archadian Posted February 24, 2007 Share Posted February 24, 2007 try combining the 2 forms into 1 and see if that has anything to do with it because ur not passing the info from the first form through the 2nd form and onto the page that reads all of it. 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.