# Problem with PHP and HTML Form



## rankbeginner (Jun 24, 2004)

Hello, and as always, thanks in advance.

I am new to PHP and forms, but I've managed to get something going at this URL:

http://www.youthtopia.com/zphp/reportawork.php

The form works OK -- the information is delivered (emailed) to my boss. But after the user presses the SUBMIT button, the user is supposed to see a message that says "Thank you."

The code I used for that, is this:

<?php
if (isset($sent)) {
echo "

Thank you. Your information has been sent to Youthtopia.

";
}
?>

It's not working at all: after clicking the submit button, the user sees the same web page of the form -- no thank you message.

Ideas? Suggestions? ... Thanks again ... RB


----------



## Elvandil (Aug 1, 2003)

Moved per request.


----------



## bassetman (Jun 7, 2001)

That is easy to do with HTML !


----------



## rankbeginner (Jun 24, 2004)

Trial and error -- lots of error -- solved this problem. The snipped of code had to be moved up. The message "Thank you" now displays at the top of the web page after the forrm is SUBMITted.

A new question: After the form is submitted, how can I get the "Thank you" message to land on a new web page? (Not, as now, at the top of the same page as the form.)

Thanks again ... RB


----------



## Rockn (Jul 29, 2001)

YOu need to use a redirect to a "thank you" page if the email is sent instead of just displaying the message.


----------



## cj_white (Oct 28, 2001)

you can use the header("Location:whatever.html") to redirect to the page after they submit


----------



## rankbeginner (Jun 24, 2004)

Hello and thanks ... Could someone please show me that solution in detail:

Here is a snip from my current code:

$message .= "Question_12: " . $_POST['terms12'] . "\n";

if (mail($to,$subject,$message)) {
echo "
*Thank you. Your information has been sent to Youthtopia.*
";
} else {
echo "
*Sorry. Your comments were not sent.*
";
}

How should this code above be changed to redirect the user after the submit button is hit?

Thanks again, everyone,

RB


----------



## cj_white (Oct 28, 2001)

i would go ahead and create a thank you page and you can redirect to it. the code for that would be as follows

$message .= "Question_12: " . $_POST['terms12'] . "\n";

if (mail($to,$subject,$message)) {
Header("Location:thank_you.html");
else {
echo "
*Sorry. Your comments were not sent.*
";
}


----------



## rankbeginner (Jun 24, 2004)

That snippet works! ... Problem solved ... 

Thank you cj, and everyone. ...

I've just made a link to Tech Support Guy on my Youthtopia.com home page.

Best wishes ... RB


----------



## bassetman (Jun 7, 2001)

rankbeginner said:


> That snippet works! ... Problem solved ...
> 
> Thank you cj, and everyone. ...
> 
> ...


 :up:


----------

