Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Question

Status
Not open for further replies.

howardMP

Technical User
Sep 26, 2002
9
GB
Hello Folks,
I am using PHP code for a mail form which seems to work. Problem is when the confirmation message is displayed it doesn't go to my "body frame", but instead take up the whole browser window including the frame for my navigation bar. Is there a way of directing this echo to only the one frame ?
Code I'm using for the confirmation is;
echo ("Thank you. Your comments will be viewed shortly.");
I have no coding experience so any help greatly received.
Thanks
Howard
 
Some more details would be handy, like where the code is in the page, where the page is loaded (in a frame, straight into the browser window), etc.
 
Hello,
Thanks for your response.
The code is placed in the page just infront of the FORM tag and is loaded in the body frame.
Howard
Rest of the code as follows;
<?PHP

if ($submit) { // If they've submitted the form...

if ($customerName <= &quot;&quot;)
$message = &quot;Please enter your name.&quot;;
else if ($customerEmail <= &quot;&quot;)
$message = &quot;Please enter your email address.&quot;;

if ($message) // If we've set a message with a warning about their form entry...
echo ($message);
else {
mail(&quot;you@yourdomain.com&quot;,
&quot;Form Results&quot;,
&quot;From: $customerName
tel:$phonenumber
Comments:$comments”
&quot;From: $customerName <$customerEmail>&quot;);

echo (&quot;Thank you. Your comments will be viewed shortly.);
die(); // We can stop if the form's been submitted and we've thanked them.
} // end if we're sending the email

} // end if they hit &quot;Submit&quot;

?>
 
Ok, so the image I have in my head right now is:

[PAGE]

--The code you posted above

--Form (with 'action' set to this page)

[END OF PAGE]

This page is loaded into your body frame, but when you click submit on the form the frames disappear and you just have the output from the script.

I threw something together to test it and the output was displayed in the body frame where it's meant to be.

Couple of things to note about your code though:

Code:
echo (&quot;Thank you. Your comments will be viewed shortly.);

This is missing the quotation marks at the end.

Code:
die();

Don't use this, you don't need it and it reeks of bad practice, if you don't want the rest of the page to be processed then put it in the 'else' part of the 'if' statement.

I only used a simple version of what you used and it worked, so the problem must be in your code somewhere. First thing I would suggest is to take out the die() statement, simpler things than that have messed up how a page is displayed.
 
Sorry I haven't replied earlier - on hols for a week. I'll tidy up as you suggest and try again
thanks
Howard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top