Page 1 of 1

Contact action php behaving wrong...

Posted: Wed Jun 27, 2007 6:29 pm
by truepal20032001
my code is misbehaving, whats wrong.

i want it to send my contact information, but it will always give me the wrong report even if i inserted the data correctly.

OUTPUT ALWAYS
===============================================
ERROR!
===============================================

php code:
===========================

Code: Select all

<div align="center">
<h1><strong></p>
</div>
<div align="center">
<div align="center">
<div align="center">
<meta http-equiv="refresh" content="2;url=/home.html">


<?php
$name = $_POST[name];
$email = $_POST[email];
$comment = $_POST[comment];
$msg = "Name: $_POST[name]\n";
$msg.= "Email: $_POST[email]\n";
$msg.= "Phone: $_POST[phone]\n";
$msg.= "Comment/Message:\n";
$msg.= "$_POST[comment]\n<br><br>";
$msg.= "Message recieved: ".date('H:i, jS F');
If($name && $comment && $email){
@mail('truepal20032001@yahoo.c...
echo "Thankyou! You'll be replied soon.</strong></h1>
<p><strong><br />
</strong><br />
<strong></strong></p>
<p>";
echo '<html><h1 align="center"><img src="info/check.jpg"</html>';
}
else{
echo "ERROR!!</strong>"}

?>

Posted: Wed Jun 27, 2007 6:45 pm
by Christopher
What does the form look like? Is it being set via POST or GET? Are you filling out all fields?

Re: Contact action php behaving wrong...

Posted: Wed Jun 27, 2007 7:07 pm
by patrikG
Try using quotation marks when using associative arrays

Code: Select all

$name = $_POST["name"];

etc.

Posted: Wed Jun 27, 2007 7:27 pm
by aaronhall
Are the name attributes in your form's input fields spelled correctly? A var_dump($_POST) might reveal what the problem is.

Also, it's rarely ever a good idea to use the shut-up operator (@) as you have on mail() -- if you're worried about users seeing errors in production, use error_reporting() to hide them, but in development, you'll spend a lot more time debugging when relevant information is being muted.

Re: Contact action php behaving wrong...

Posted: Wed Jun 27, 2007 8:42 pm
by truepal20032001
patrikG wrote:Try using quotation marks when using associative arrays

Code: Select all

$name = $_POST["name"];

etc.
oh i see what you are saying:
when php looks at
"$_POST[email];" It looks at them as values, but when they are
"$_POST["email"];" It looks at them as strings right, that would make more sense thanks

Posted: Wed Jun 27, 2007 11:00 pm
by Ambush Commander
Not so much values, but constants; the general jist is correct though.