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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

1 quick one slep 1

Status
Not open for further replies.

deecee

Technical User
Aug 25, 2001
1,678
US
<html>
<head>
<link href=&quot;main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>
<meta content=&quot;text/html; charset=iso-8859-1&quot; http-equiv=&quot;Content-Type&quot;><title>EMAIL</title></head>
<body>
<?php
if (array_key_exists('firstName', $_POST) || array_key_exists('lastName', $_POST) || array_key_exists('email', $_POST) ||array_key_exists('accountNumber', $_POST) || array_key_exists('question', $_POST))
{
mail(&quot;darryn@cascadecorp.com&quot;, &quot;Feedback&quot;, $msg, &quot;From: $email&quot;);
}
else
{
header(&quot;Location: }
?>
</body>
</html>

is my script right now

it was working until i put in my mail funtion and now it wont parse, also if i dont put in any value for either of the fields the header wont work and the browser wont redirect.

is my syntax right? [soapbox]
sleep is good
 
1. You cannot output a header after you have output content. This is built into the HTTP specification. If you use PHP's output buffering, you can get around it, but you do take a performance hit. It's easier to do your checks and output redirection headers first.

2. If you are getting a &quot;Parse error in line....&quot; error, start with the line reported by PHP and go back up the script, looking for missing semicolons, quotes, doublequotes, paretheses, brackets, and braces. Want the best answers? Ask the best questions: TANSTAAFL!
 
actually i just got my page loaded but nothing worked, why does the form not get mailed to me? isn't that how the mail function would work?

then how would i send the user back to the form if the keys do not exist? [soapbox]
sleep is good
 
Does mail() work in a simpler script?

mail() does not send the email to your home POP3 server itself. It expects to have an SMTP server through which it can deliver mail. Most *nix OSes come bundled with this feature, commonly sendmail or qmail. If you're running PHP on Win32, there are some configuration tweaks you have to perform in php.ini.


Redirecting:
You can have code before your use of header(), you just can't output anything. Including error messages or warnings generated by PHP. But your logic and redirection at the top of the script.


I strongly recommend that you test all the features you're using separately before trying to use them together. It makes it a lot easier to debug your code. Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top