Forum Moderators: coopster
if($sent) {
echo 'Your message has been sent.';
}
else {
echo 'There was a problem and your message has not been sent.';
}
?>
<HTML>
<HEAD>
<TITLE>Feedback Form Sent - Thanks </TITLE>
</HEAD>
<BODY>
<H1> The following e-mail has been sent. We will endeavour to get in contact with you as soon as possible </H1>
<P> <strong> Your Name: </strong><br>
<? echo $_POST ['sender_name'];?>
<P> <strong> Your address: </strong><br>
<? echo $_POST ['sender_address'];?>
<P> <strong> Your Number: </strong><br>
<? echo $_POST ['sender_number'];?>
<P> <strong> The Heading: </strong><br>
<? echo $_POST ['message_heading'];?>
<P> <strong> The Heading: </strong><br>
<? echo $_POST ['message_heading'];?>
<P> <strong> The Main Message: </strong><br>
<? echo $_POST ['message'];?>
</BODY>
</HTML>
thank you but i am still having no luck
It may be not wrong to apply Grandpa's habits of quoting the POST variables to the first part of your code, too.
Regards,
R.
thanks for replying.. this is what it says..to the above script
Hosting platform: Windows, Win32
Path to web root: D:\\wwwsites\\yoursitecom\\www or use single forward slashes D:/wwwsites/yoursitecom/www
Path to ftp root: D:\\wwwsites\\yoursitecom or use single forward slashes D:/wwwsites/yoursitecom
Path to odbc folder: D:\\wwwsites\\yoursitecom\\odbc or use single forward slashes D:/wwwsites/yoursitecom/odbc
PHP version: 4.3.x
Safe mode: On
ASP style tags: On
Open_basedir: D:/wwwsites Note - the open base directory is further limited to the ftp root and everything below by file system permissions.
Upload_max_filesize: 5 MB
PHP And Email
Outgoing mail server: The outgoing mail server for your web application is 127.0.0.1
PHP Mail() function: The PHP Mail() function operates differently than expected on a Windows server. On a Windows server, we must use the ini_set() function to set the sendmail_from parameter in our PHP scripts or applications.
Format
ini_set("sendmail_from", "yourEmailAddress@YourDomain.com");
mail($send_to_address, $subject, $body);
Example
<?php
ini_set("sendmail_from", "yourEmailAddress@YourDomain.com");
mail("account@server.com","testing mail on win32 via php","Test to make sure that mail is configured correctly.");
?>
just copied and pasted information from a hosting company.. apparently the hosting company is using a windows server and therefore i believe things would need to be a bit different
$message = "Sender's Name: $_POST[sender_name] "\r\n";
$message .= "Sender's Address: $_POST[sender_address] "\r\n";
$message .= "Sender's Number: $_POST[sender_number] "\r\n";
$message .= "Message Heading: $_POST[sender_heading] "\r\n";
$message .= "Message: $_POST[message] "\r\n";
the " don't match up right ... try something like:
<edit>added ' into the post variable</edit>
$message = "Sender's Name:" . $_POST['sender_name'] . "\r\n";
$message .= "Sender's Address:" . $_POST['sender_address'] . "\r\n";
$message .= "Sender's Number:" . $_POST['sender_number'] . "\r\n";
$message .= "Message Heading:" . $_POST['sender_heading'] . "\r\n";
$message .= "Message:" . $_POST['message'] . "\r\n";
Also, here:
$mailheaders .= 'Browser: $HTTP_USER_AGENT\n';
$mailheaders .='From page: $HTTP_HOST\n';
$mailheadersv .='IP address: $SERVER_ADDR\n';
all those lines need to be enclosed in double quotes (") otherwise those variables won't be parsed.
$mailheaders .= "Browser: $HTTP_USER_AGENT\n";
$mailheaders .= "From page: $HTTP_HOST\n";
$mailheadersv .= "IP address: $SERVER_ADDR\n";
(I'm guessing that the 'v' on the end is a typo).
I think that will help things out a bit.
-sned
[edited by: sned at 5:11 pm (utc) on Aug. 16, 2005]
I looks like you have an extra double quote on several lines:
$message = "Sender's Name: $_POST[sender_name] "\r\n";
$message .= "Sender's Address: $_POST[sender_address] "\r\n";
$message .= "Sender's Number: $_POST[sender_number] "\r\n";
$message .= "Message Heading: $_POST[sender_heading] "\r\n";
$message .= "Message: $_POST[message] "\r\n";
Remove the second double quote, right before the \r\n, and I think that should fix it.
Chad
$mailheaders .= 'MIME-Version: 1.0'. "\r\n";
$mailheaders .= 'Content-type: text/html; charset=iso-8859-1'. "\r\n";
<br />
<b>Parse error</b>: parse error, unexpected T_STRING in <b>C:\Program Files\EasyPHP1-8\www\contactus.php</b> on line <b>27 (in this case line one here)</b><br />
with the error message
$to = "asdf@yahoo.co.uk";
$subject = "";
$message = "";
$thankyou = "http://www.jhkj.com/thankyou.html";
$mailheaders = 'To: tim <sonas@yahoo.co.uk>' . "\r\n";
$mailheaders .= 'cc: uyk <kjhu@yahoo.co.uk>' . "\r\n";
$mailheaders .='bcc: jo <jkhkj@aol.com>' ."\r\n";
$mailheaders .= "Browser: $HTTP_USER_AGENT\n";
$mailheaders .= "From page: $HTTP_HOST\n";
$mailheaders .= "IP address: $SERVER_ADDR\n";
$mailheaders .= "MIME-Version: 1.0 \r\n";
$mailheaders .= "Content-type: text/html; charset=iso-8859-1 \r\n";
$sent = mail ( $to, $subject, $message, $mailheaders);
Header ("Location: $thankyou");
if($sent) {
echo 'Your message has been sent.';
}
else {
echo 'There was a problem and your message has not been sent.';
}
?>
<HTML>
<HEAD>
<TITLE>Feedback Form Sent - Thanks </TITLE>
</HEAD>
<BODY>
<H1> The following e-mail has been sent. We will endeavour to get in contact with you as soon as possible </H1>
<P> <strong> Your Name: </strong><br>
<? echo $_POST ['sender_name'];?>
<P> <strong> Your address: </strong><br>
<? echo $_POST ['sender_address'];?>
<P> <strong> Your Number: </strong><br>
<? echo $_POST ['sender_number'];?>
<P> <strong> The Heading: </strong><br>
<? echo $_POST ['message_heading'];?>
<P> <strong> The Heading: </strong><br>
<? echo $_POST ['message_heading'];?>
<P> <strong> The Main Message: </strong><br>
<? echo $_POST ['message'];?>
</BODY>
</HTML>
<br />
<b>Parse error</b>: parse error, unexpected $ in <b>C:\Program Files\EasyPHP1-8\www\contactus.php</b> on line <b>74</b><br />
which is well passed the </HTML> message..
and now it is giving me this message..
if (($_POST[sender_name] == "") && ($_POST[sender_address] == "") && ($_POST[sender_number] == "") &&($_POST[message_heading] == "") && ($_POST[message] == "")) {
header ("Location: contactus.html");
exit;
There needs to be a '}' after exit;
-sned
/em blows the wisp of smoke from the barrel :)
[edited by: sned at 6:26 pm (utc) on Aug. 16, 2005]
you have an opening brace but no closing and all those parentheses don't need to be there, change first 4 lines to this
if ($_POST[sender_name] == "" && $_POST[sender_address] == "" && $_POST[sender_number] == "" && $_POST[message_heading] == "" && $_POST[message] == "") {
header ("Location: contactus.html");
exit;
}
<added>sned was quicker ;)
if (($_POST[sender_name] == "") && ($_POST[sender_address] == "") && ($_POST[sender_number] == "") &&($_POST[message_heading] == "") && ($_POST[message] == "")) {
exit; }
Notice: Use of undefined constant sender_name - assumed 'sender_name' in c:\program files\easyphp1-8\www\tmpe50cllbwx1.php on line 5
Notice: Undefined index: sender_name in c:\program files\easyphp1-8\www\tmpe50cllbwx1.php on line 5
Notice: Use of undefined constant sender_address - assumed 'sender_address' in c:\program files\easyphp1-8\www\tmpe50cllbwx1.php on line 5
Notice: Undefined index: sender_address in c:\program files\easyphp1-8\www\tmpe50cllbwx1.php on line 5
Notice: Use of undefined constant sender_number - assumed 'sender_number' in c:\program files\easyphp1-8\www\tmpe50cllbwx1.php on line 5
Notice: Undefined index: sender_number in c:\program files\easyphp1-8\www\tmpe50cllbwx1.php on line 5
Notice: Use of undefined constant message_heading - assumed 'message_heading' in c:\program files\easyphp1-8\www\tmpe50cllbwx1.php on line 5
Notice: Undefined index: message_heading in c:\program files\easyphp1-8\www\tmpe50cllbwx1.php on line 5
Notice: Use of undefined constant message - assumed 'message' in c:\program files\easyphp1-8\www\tmpe50cllbwx1.php on line 5
Notice: Undefined index: message in c:\program files\easyphp1-8\www\tmpe50cllbwx1.php on line 5
if ($_POST[sender_name] == "" && $_POST[sender_address] == "" && $_POST[sender_number] == "" && $_POST[message_heading] == "" && $_POST[message] == "") {
header ("Location: contactus.html");
exit;
}
guess I just overlooked it ... all the $_POST variables need to be in single quotes:
if ($_POST['sender_name'] == "" && $_POST['sender_address'] == "" && $_POST['sender_number'] == "" && $_POST['message_heading'] == "" && $_POST['message'] == "") {
header ("Location: contactus.html");
exit;
}
-sned
<edit>bah .. can't even count my own '</edit>
if (($_POST['sender_name'] == "") && ($_POST['sender_address'] == "") && ($_POST['sender_number'] == "") &&($_POST['message_heading'] == "") && ($_POST['message'] == "")) {
exit; }
Notice: Undefined index: sender_name in c:\program files\easyphp1-8\www\tmpekj2ilbxh5.php on line 5
Notice: Undefined index: sender_address in c:\program files\easyphp1-8\www\tmpekj2ilbxh5.php on line 5
Notice: Undefined index: sender_number in c:\program files\easyphp1-8\www\tmpekj2ilbxh5.php on line 5
Notice: Undefined index: message_heading in c:\program files\easyphp1-8\www\tmpekj2ilbxh5.php on line 5
Notice: Undefined index: message in c:\program files\easyphp1-8\www\tmpekj2ilbxh5.php on line 5
Thanks i have put the single quotes in but still i get these errors... please help
You need to turn error reporting down a bit in php.ini - here's the docs:
[uk2.php.net...]
error_reporting = E_ALL & ~E_NOTICE
...seems to be the norm, which will dispose of all those index not set warnings...
if (($_POST['sender_name'] == "") && ($_POST['sender_address'] == "") && ($_POST['sender_number'] == "") &&($_POST['message_heading'] == "") && ($_POST['message'] == "")) {
exit; }
When the script is run, all of those variables are empty, since nothing was posted. The next line of your script calls the exit function. The script exits, nothing else runs and nothing else is displayed. If you were to add a line just before your exit, say, echo "Hello World";, then you would see that output.
So, while the script is now debugged and running normally, the result is not what you were expecting. If someone else doesn't do it first, I might be able to re-write this script sometime tonight and post it here for you. Got a couple of bugs to fix over here first...
So you are posting from the form now and nothing is happening? Is the e-mail getting sent? Have you checked the script to ensure that your variables are getting posted? A line of code like this at the top of your script will show you if the form submitted OK.
foreach ($_POST as $key=>$val) echo $val;
And, what about your server logs? There might be an error getting logged that will help you understand what is happening.
I had reworked this original script into a single php script that contained both the form and the form processing. However, when the script is executed in ZEND it always returned a Notice level warning about undefined indexes on this line:
if (($_POST['sender_name'] == "") ¦¦ ($_POST['sender_address'] == "") ¦¦ ($_POST['sender_number'] == "") ¦¦ ($_POST['message_heading'] == "") ¦¦ ($_POST['message'] == ""))
Running the same script with no Error Reporting in my own production PHP environment there were no notices or warnings. Inserting the line error_reporting(OFF); did not help in the ZEND environment.
My question then is why? Is the error reporting a global setting in ZEND, as opposed to per script like I'm familiar with?
Anyway, to overcome the problem I simply reverted back to the original script format which was a form in the html document and a php script to process the form. (Still awaiting word on how things went.)