?
Solved

thank you page for mutiple forms

Posted on 2003-03-16
24
Medium Priority
?
211 Views
Last Modified: 2008-07-03
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 http://www.lccw.ca\n";
$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 http://www.lccw.ca\n";
$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>
0
Comment
Question by:jblayney
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 15
  • 7
  • 2
24 Comments
 
LVL 1

Author Comment

by:jblayney
ID: 8146931
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
0
 
LVL 1

Author Comment

by:jblayney
ID: 8146944
this too

if($page == "contact") Then {
bla
} else {
if($page == "volunteer") Then {
bla bla
} }
end if
(added braces)
0
 
LVL 1

Author Comment

by:jblayney
ID: 8146972
should I stick these in functions at the top

if($page == "contact") Then {
function ("contact")
} else {
if($page == "volunteer") Then {
function ("volunteer")
} }
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:jblayney
ID: 8146986
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 http://www.lccw.ca\n";
$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 http://www.lccw.ca\n";
$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
?>
0
 
LVL 1

Author Comment

by:jblayney
ID: 8147230
no comments,
is this really that hard, or is everyone out enjoying the good weather ?
0
 
LVL 15

Accepted Solution

by:
VGR earned 100 total points
ID: 8147313
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']."<BR>"; 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
0
 
LVL 1

Author Comment

by:jblayney
ID: 8147363
Thanks VGR
I tried , request, get and post with this

echo $_POST['page']."<BR>"; exit;

I'm still gettiing the same result, a blank page, after a bit of thinking
0
 
LVL 1

Author Comment

by:jblayney
ID: 8147384
and register globals is on,
I have many sites hosted on this server that use php, and the $_REQUEST works with them ????
0
 
LVL 1

Author Comment

by:jblayney
ID: 8147392
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 ???
0
 
LVL 15

Expert Comment

by:VGR
ID: 8147552
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']."<BR>"; exit;" SHOULD HAVE DISPLAYED SOMETHING ( at least the <BR> ;-)

Try with $page

echo "page received is '$page'<BR>"; exit;
0
 
LVL 1

Author Comment

by:jblayney
ID: 8147701
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.
0
 
LVL 1

Author Comment

by:jblayney
ID: 8147736
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?
0
 
LVL 1

Author Comment

by:jblayney
ID: 8147745
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.
0
 
LVL 1

Author Comment

by:jblayney
ID: 8148930
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 http://www.lccw.ca\n";
$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.

 
0
 
LVL 1

Author Comment

by:jblayney
ID: 8148937
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
0
 
LVL 15

Expert Comment

by:VGR
ID: 8149639
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<BR>"; exit;" I DON'T UNDERSTAND WHY YOU "strip everything but echo $page" : WHAT is the EXIT; for in your opirnion ???
0
 
LVL 15

Expert Comment

by:VGR
ID: 8149675
here is you 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 http://www.lccw.ca\n";
  $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 http://www.lccw.ca\n";
  $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-)
?>
0
 
LVL 1

Author Comment

by:jblayney
ID: 8151378
"ANYWAY, WHEN I SAY "echo "$page<BR>"; 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
0
 
LVL 15

Expert Comment

by:VGR
ID: 8153519
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 ?
0
 
LVL 6

Expert Comment

by:CyberGhost
ID: 8157842
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.
0
 
LVL 15

Expert Comment

by:VGR
ID: 8157868
oh yes, true 8-)

I missed that one 8-)
0
 
LVL 1

Author Comment

by:jblayney
ID: 8161000
"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.
0
 
LVL 15

Expert Comment

by:VGR
ID: 8161083
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)
0
 
LVL 6

Expert Comment

by:CyberGhost
ID: 8164881
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
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question