Languages :: PHP :: thank you page for mutiple forms |
|||
| By: jblayney |
Date: 16/03/2003 00:00:00 |
Points: 25 | Status: Answered Quality : Excellent |
|
hello, i am creating a thank you page which will be used for all 4 forms on this website, So i want it to display a custom thank you for each page it comes from. So far i have 2 of the pages going to it, and I am getting no results (blank page) and no email. $page is a hidden field that is on both pages and it is all in a table. any help would be appreciated, remember i will need to add 2 more ifs after this <td width="335" valign="top"> <? if($page == "contact") Then // ********* reply email customer support ************ $msg = "E-Mail SEND FROM <A HREF="http://www.lccw.ca\n">http://www.lccw.ca\n</a>"; $msg .= "Dear $realname :\n\n"; $msg .= "We have received your email\n\n"; $msg .= "Thank you for your feedback\n"; $msg .= "If you require a response you will\n"; $msg .= "receive one within 2 - 3 business days"; $to = "$email"; // **** to form filler ******** $subject = "Life Choices for Women & Children: Contact Confirmation\n"; $mailheaders = "From: jplummer@lccw.ca\n"; $mailheaders .= "Reply-To: jplummer@lccw.ca"; mail($to,$subject,$msg,$mailheaders); // ****** end of reply email ********* // ******** start of email to customer support ********** $msg = "Name :$realname\n"; $msg .= "Email :$email\n"; $msg .= "Message :$message\n"; $to = "justin@justinblayney.com"; // ** this is the customer service dept. ** $subject = "Web site contact form\n"; $mailheaders = "From: $realname\n"; $mailheaders .= "Reply-To: $email"; mail($to,$subject,$msg,$mailheaders); // ********* end of customer support email ************ echo "<h1>Thank you for contacting us.</h1><p>If you require a response we will return one to you within 2 - 3 business days.</p>" Else if($page == "volunteer") Then // ********* reply email customer support ************ $msg = "E-Mail SEND FROM <A HREF="http://www.lccw.ca\n">http://www.lccw.ca\n</a>"; $msg .= "Dear $realname :\n\n"; $msg .= "We have received your email\n\n"; $msg .= "Thank you for offering to volunteer\n"; $msg .= "We will response to you\n"; $msg .= "within 2 - 3 business days"; $to = "$email"; // **** to form filler ******** $subject = "Life Choices for Women & Children: Volunteer Confirmation\n"; $mailheaders = "From: jplummer@lccw.ca\n"; $mailheaders .= "Reply-To: jplummer@lccw.ca"; mail($to,$subject,$msg,$mailheaders); // ****** end of reply email ********* // ******** start of email to customer support ********** $msg = "Name :$realname\n"; $msg .= "Email :$email\n"; $msg .= "Phone :$phone\n"; $msg .= "Best time to call :$time\n"; $msg .= "Workshops :$workshops\n"; $msg .= "Mentorship :$mentorship\n"; $msg .= "Training :$Training\n"; $msg .= "Job :$job\n"; $msg .= "Message :$message\n"; $to = "justin@justinblayney.com"; // ** this is the customer service dept. ** $subject = "Web site Volunteer form\n"; $mailheaders = "From: $realname\n"; $mailheaders .= "Reply-To: $email"; mail($to,$subject,$msg,$mailheaders); // ********* end of customer support email ************ echo "<h1>Thank you for volunteering.</h1><p>We will try to response to you within 2 - 3 business days.</p>" End If ?> </td> |
|||
| By: jblayney | Date: 16/03/2003 04:58:00 | Type : Comment |
|
| I just tried <?php and had no luck i also tried if($page == "contact") Then { bla } else { bla bla } end if (added braces) that didn't help either |
|||
| By: jblayney | Date: 16/03/2003 05:00:00 | Type : Comment |
|
| this too if($page == "contact") Then { bla } else { if($page == "volunteer") Then { bla bla } } end if (added braces) |
|||
| By: jblayney | Date: 16/03/2003 05:08:00 | Type : Comment |
|
| should I stick these in functions at the top if($page == "contact") Then { function ("contact") } else { if($page == "volunteer") Then { function ("volunteer") } } |
|||
| By: jblayney | Date: 16/03/2003 05:12:00 | Type : Comment |
|
| Ok, Sorry about this, I just changed more, ths is the code now <?php if($_REQUEST['page'] == "contact") Then { // ********* reply email customer support ************ $msg = "E-Mail SEND FROM <A HREF="http://www.lccw.ca\n">http://www.lccw.ca\n</a>"; $msg .= "Dear $realname :\n\n"; $msg .= "We have received your email\n\n"; $msg .= "Thank you for your feedback\n"; $msg .= "If you require a response you will\n"; $msg .= "receive one within 2 - 3 business days"; $to = "$email"; // **** to form filler ******** $subject = "Life Choices for Women & Children: Contact Confirmation\n"; $mailheaders = "From: jplummer@lccw.ca\n"; $mailheaders .= "Reply-To: jplummer@lccw.ca"; mail($to,$subject,$msg,$mailheaders); // ****** end of reply email ********* // ******** start of email to customer support ********** $msg = "Name :$realname\n"; $msg .= "Email :$email\n"; $msg .= "Message :$message\n"; $to = "justin@justinblayney.com"; // ** this is the customer service dept. ** $subject = "Web site contact form\n"; $mailheaders = "From: $realname\n"; $mailheaders .= "Reply-To: $email"; mail($to,$subject,$msg,$mailheaders); // ********* end of customer support email ************ echo "<h1>Thank you for contacting us.</h1><p>If you require a response we will return one to you within 2 - 3 business days.</p>" } Else { if($_REQUEST['page'] == "volunteer") Then { // ********* reply email customer support ************ $msg = "E-Mail SEND FROM <A HREF="http://www.lccw.ca\n">http://www.lccw.ca\n</a>"; $msg .= "Dear $realname :\n\n"; $msg .= "We have received your email\n\n"; $msg .= "Thank you for offering to volunteer\n"; $msg .= "We will response to you\n"; $msg .= "within 2 - 3 business days"; $to = "$email"; // **** to form filler ******** $subject = "Life Choices for Women & Children: Volunteer Confirmation\n"; $mailheaders = "From: jplummer@lccw.ca\n"; $mailheaders .= "Reply-To: jplummer@lccw.ca"; mail($to,$subject,$msg,$mailheaders); // ****** end of reply email ********* // ******** start of email to customer support ********** $msg = "Name :$realname\n"; $msg .= "Email :$email\n"; $msg .= "Phone :$phone\n"; $msg .= "Best time to call :$time\n"; $msg .= "Workshops :$workshops\n"; $msg .= "Mentorship :$mentorship\n"; $msg .= "Training :$Training\n"; $msg .= "Job :$job\n"; $msg .= "Message :$message\n"; $to = "justin@justinblayney.com"; // ** this is the customer service dept. ** $subject = "Web site Volunteer form\n"; $mailheaders = "From: $realname\n"; $mailheaders .= "Reply-To: $email"; mail($to,$subject,$msg,$mailheaders); // ********* end of customer support email ************ echo "<h1>Thank you for volunteering.</h1><p>We will try to response to you within 2 - 3 business days.</p>" }} End If ?> |
|||
| By: jblayney | Date: 16/03/2003 06:35:00 | Type : Comment |
|
| no comments, is this really that hard, or is everyone out enjoying the good weather ? |
|||
| By: VGR | Date: 16/03/2003 19:03:00 | Type : Answer |
|
| it's Sunday, you know ? :D Well, if you have to email sent, it's either your [email] section of php.ini is wrong, or that $_REQUEST['page'] is NEVER set to what you expect. Could you try this : -first tell me what is the Register_globals setting you have (php.ini or phpinfo() call ) -try this to check transmission : <?php echo $_REQUEST['page']." "; exit; if($_REQUEST['page'] == "contact") Then { etc etc ?> this way you'll know if you really have the $page variable set up. personally, I think that the hidden field comes from a FORM in action=GET or POST, so I would in stead use $_GET['page'] or $_POST['page'] regards |
|||
| By: jblayney | Date: 16/03/2003 19:21:00 | Type : Comment |
|
| Thanks VGR I tried , request, get and post with this echo $_POST['page']." "; exit; I'm still gettiing the same result, a blank page, after a bit of thinking |
|||
| By: jblayney | Date: 16/03/2003 19:27:00 | Type : Comment |
|
| and register globals is on, I have many sites hosted on this server that use php, and the $_REQUEST works with them ???? |
|||
| By: jblayney | Date: 16/03/2003 19:28:00 | Type : Comment |
|
| and you right about it being sunady, and a beautiful one at that, Ihave watched a foot of snow melt off my back porch today, What am i doing inside ??? |
|||
| By: VGR | Date: 16/03/2003 20:14:00 | Type : Comment |
|
| if register_global in On (good :D ) and your calling FORM has a hidden field names 'page', just use $page in the receiving script... Anyway, trying your script with "echo $_POST['page']." "; exit;" SHOULD HAVE DISPLAYED SOMETHING ( at least the ;-) Try with $page echo "page received is '$page' "; exit; |
|||
| By: jblayney | Date: 16/03/2003 21:11:00 | Type : Comment |
|
| ok i stripped out all php except echo $page, and it displayed the correct word, so the varable is getting passed, what do you think, Is it some stupid syntax error or somerthing ? I can't find any. |
|||
| By: jblayney | Date: 16/03/2003 21:21:00 | Type : Comment |
|
| ok, i stripped out the if staement, and have it just for the contact page, And it works and the emails are sent, so the proble is the "IF" statement, any advice on a better way to write it? |
|||
| By: jblayney | Date: 16/03/2003 21:25:00 | Type : Comment |
|
| What about if I named the form itself. I've never done that before, how would that work ? Of course what I can do , is make 4 copies of the thank you page, one for each form. but..... i was hoping to do something more elegant. |
|||
| By: jblayney | Date: 16/03/2003 21:43:00 | Type : Comment |
|
| Im trying to put this whole thing in a function, and put it in an include file, but its not working. function contact() { $msg = "E-Mail SEND FROM <A HREF="http://www.lccw.ca\n">http://www.lccw.ca\n</a>"; $msg .= "Dear $realname :\n\n"; $msg .= "We have received your email\n\n"; bla bla bla send email code } that seems straight forward, but in the other page when I call it, it doesn't work <?php include("mail.php"); ?> <? contact(): ?> this is what I'm doing. I'm then hoping to use this with my "IF" statement, if($_REQUEST['page'] == "contact") Then { contact(): } else { and so on, I know this is getting bigger, but i really dont want to have 4 separate pages. |
|||
| By: jblayney | Date: 16/03/2003 21:44:00 | Type : Comment |
|
| can anyone at least tell me if I'm on the right track, this all seems straight forward, but my "IF"'s and functions just wont work |
|||
| By: VGR | Date: 16/03/2003 21:53:00 | Type : Comment |
|
| NO IT'S WORSE FOR YOU WHY ? Because globals are to be re-declared as GLOBAL in a function scope... Stick with your first code, the echo $page worked (normal) so now you know how to access your variables. I'll help you. ANYWAY, WHEN I SAY "echo "$page "; exit;" I DON'T UNDERSTAND WHY YOU "strip everything but echo $page" : WHAT is the EXIT; for in your opinion ??? |
|||
| By: VGR | Date: 16/03/2003 22:01:00 | Type : Comment |
|
| here is your code. I added some //### comments <?php session_start(); //#don't forget this //## remember that even with register_globals=On, it should be better to use $page=$_GET['page'] if the calling FORM is in method=GET, etc if($page=="contact") Then { // ********* reply email customer support ************ $msg = "E-Mail SEND FROM <A HREF="http://www.lccw.ca\n">http://www.lccw.ca\n</a>"; $msg .= "Dear $realname :\n\n"; $msg .= "We have received your email\n\n"; $msg .= "Thank you for your feedback\n"; $msg .= "If you require a response you will\n"; $msg .= "receive one within 2 - 3 business days"; $to = "$email"; // **** to form filler ******** $subject = "Life Choices for Women & Children: Contact Confirmation\n"; $mailheaders = "From: jplummer@lccw.ca\n"; $mailheaders .= "Reply-To: jplummer@lccw.ca"; mail($to,$subject,$msg,$mailheaders); // ****** end of reply email ********* // ******** start of email to customer support ********** $msg = "Name :$realname\n"; $msg .= "Email :$email\n"; $msg .= "Message :$message\n"; $to = "justin@justinblayney.com"; // ** this is the customer service dept. ** $subject = "Web site contact form\n"; $mailheaders = "From: $realname\n"; $mailheaders .= "Reply-To: $email"; mail($to,$subject,$msg,$mailheaders); // ********* end of customer support email ************ echo "<h1>Thank you for contacting us.</h1><p>If you require a response we will return one to you within 2 - 3 business days.</p>" } else if ($page=="volunteer") Then { // ********* reply email customer support ************ $msg = "E-Mail SEND FROM <A HREF="http://www.lccw.ca\n">http://www.lccw.ca\n</a>"; $msg .= "Dear $realname :\n\n"; $msg .= "We have received your email\n\n"; $msg .= "Thank you for offering to volunteer\n"; $msg .= "We will response to you\n"; $msg .= "within 2 - 3 business days"; $to = "$email"; // **** to form filler ******** $subject = "Life Choices for Women & Children: Volunteer Confirmation\n"; $mailheaders = "From: jplummer@lccw.ca\n"; $mailheaders .= "Reply-To: jplummer@lccw.ca"; mail($to,$subject,$msg,$mailheaders); // ****** end of reply email ********* // ******** start of email to customer support ********** $msg = "Name :$realname\n"; $msg .= "Email :$email\n"; $msg .= "Phone :$phone\n"; $msg .= "Best time to call :$time\n"; $msg .= "Workshops :$workshops\n"; $msg .= "Mentorship :$mentorship\n"; $msg .= "Training :$Training\n"; $msg .= "Job :$job\n"; $msg .= "Message :$message\n"; $to = "justin@justinblayney.com"; // ** this is the customer service dept. ** $subject = "Web site Volunteer form\n"; $mailheaders = "From: $realname\n"; $mailheaders .= "Reply-To: $email"; mail($to,$subject,$msg,$mailheaders); // ********* end of customer support email ************ echo "<h1>Thank you for volunteering.</h1><p>We will try to response to you within 2 - 3 business days.</p>" } // else case not covered //# I would recommend : //- a switch($page) statement //- to check that the calling FORM is in a script with session_start(); at the beginning //- to generate proper HTML (HTML,HEAD,TITLE,/TITLE,/HEAD,BODY,/BODY,/HTML etc) //- to put the mailing calls in a function to clear&simplify a bit the code 8-) ?> |
|||
| By: jblayney | Date: 17/03/2003 00:06:00 | Type : Comment |
|
| "ANYWAY, WHEN I SAY "echo "$page "; exit;" I DON'T UNDERSTAND WHY YOU "strip everything but echo $page" : WHAT is the EXIT; for in your opirnion ???" unfortunatly, I had to do that, I know what exit means, but for some reason the If after it was messing it up. ????? I dont know why ?????? but when I have a problem , one of the ways I troubleshoot it is too keep stripping code until it works. so I can see where the problem starts |
|||
| By: VGR | Date: 17/03/2003 05:00:00 | Type : Comment |
|
| yes. Why not :D I'll recommend building your script from control structures up ; this way you'll never have "an if messing [things] up" have you tried my humble suggestion ? |
|||
| By: TheFalklands | Date: 18/03/2003 20:25:00 | Type : Comment |
|
| Have u ever seen THEN in if statement in PHP? I didn't and it gives me a parse error. U should put THEN after if away. |
|||
| By: VGR | Date: 18/03/2003 20:34:00 | Type : Comment |
|
| oh yes, true 8-) I missed that one 8-) |
|||
| By: jblayney | Date: 18/03/2003 20:34:00 | Type : Comment |
|
| "Have u ever seen THEN in if statement in PHP? I didn't and it gives me a parse error. U should put THEN after if away" HUH ????? Anyways, I'm sorry I'm taking so long with this. for a quick fix I made a different thank you/email send page. I will be coming back to this, But right now i am too busy. So please be patient. |
|||
| By: VGR | Date: 18/03/2003 20:48:00 | Type : Comment |
|
| he wrote that the syntax in PHP ressembles the C one : if (test) { // start then case } else { // start else case } // end of if or if (test) { // start then case } else { // start else case } // end of if And not like this (in Pascal) if test then begin // then case end else begin // else case end; // end of if test Except that the parentheses are mandatory around a logical test in PHP, whereas they shouldn't in a real language (like Pascal) |
|||
| By: TheFalklands | Date: 18/03/2003 20:57:00 | Type : Comment |
|
| Sorry for that short bad-looking answer. But I had my keyboard broken and wrote it through Windows Character Map. So it should be short and exact. Anyway, this is what I mean: bad code = if(something happens) then {do something}; good one = if(something happens) {do something}; ... so no THEN should be written after "if". Hope u understand now ;o) regards |
|||
|
Do register to be able to answer |
|||
©2012 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








