Page 1 of 1

Super simple PHP form script giving me all types of errors!!

Posted: Mon Jun 22, 2009 1:02 am
by botlife1
Hey everyone,

I am a little brain dead at the moment from working all day and I can't figure out why this script is giving me so many error messages. The script works just fine even with the errors. It is a simple email form script that also sends an automatic email to the person who originally emailed.

Below is the script

<?php


$formmessage = "Name: ".$_POST[name]."\n"."Email: ".$_POST[email]."\n"."Phone Number: ".$_POST[telephone]."\n"."Message: ".$_POST[message]. "\n";
$my_email = "mysite@yahoo.com";


mail($my_email,$message);

$recipient = $email;
$subject = "Customer Email Via Website";
$forminfo =
($_POST['name'] . "\r" .
$_POST['email'] . "\r" .
$_POST['telephone'] . "\r" .
$_POST['message'] . "\r" .

date("M-d-Y") . "\r\n\n");

$formsend = mail("$my_email", "$subject", "$formmessage", "From: info@mysite.com");


$formmessage2 =
"Thank you for filling out our short contact form. Mysite is dedicated to providing amazing customer service. If you do not recieve a response within 24 hours, please feel free to contact us at 818.237.6666"."\n\r"."Best,"."\n\r"."The Mysite Team";
$my_email = "info@mysite.com";



$subject2 = "Thank You For Contacting Mysite";

$formsend2 = mail("$email", "$subject2", "$formmessage2", "From: info@mysite.com");

?>

Here are the error messages

Notice: Use of undefined constant name - assumed 'name' in /home/u2/ztezgkkskn/html/lotus/core/core.functions.php(637) : eval()'d code on line 217

Notice: Use of undefined constant email - assumed 'email' in /home/u2/ztezgkkskn/html/lotus/core/core.functions.php(637) : eval()'d code on line 217

Notice: Use of undefined constant telephone - assumed 'telephone' in /home/u2/ztezgkkskn/html/lotus/core/core.functions.php(637) : eval()'d code on line 217

Notice: Use of undefined constant message - assumed 'message' in /home/u2/ztezgkkskn/html/lotus/core/core.functions.php(637) : eval()'d code on line 217

Notice: Undefined variable: message in /home/u2/ztezgkkskn/html/lotus/core/core.functions.php(637) : eval()'d code on line 221

Warning: mail() expects at least 3 parameters, 2 given in /home/u2/ztezgkkskn/html/lotus/core/core.functions.php(637) : eval()'d code on line 221

Notice: Undefined variable: email in /home/u2/ztezgkkskn/html/lotus/core/core.functions.php(637) : eval()'d code on line 223

It just doesn't make any sense why it is not working, I have used this script plenty of times and it works still. Is there a way I can tell PHP to not display error messages?

Re: Super simple PHP form script giving me all types of errors!!

Posted: Mon Jun 22, 2009 1:37 am
by requinix
botlife1 wrote:Is there a way I can tell PHP to not display error messages?
Don't.
Notice: Use of undefined constant name - assumed 'name' in /home/u2/ztezgkkskn/html/lotus/core/core.functions.php(637) : eval()'d code on line 217

Notice: Use of undefined constant email - assumed 'email' in /home/u2/ztezgkkskn/html/lotus/core/core.functions.php(637) : eval()'d code on line 217

Notice: Use of undefined constant telephone - assumed 'telephone' in /home/u2/ztezgkkskn/html/lotus/core/core.functions.php(637) : eval()'d code on line 217

Notice: Use of undefined constant message - assumed 'message' in /home/u2/ztezgkkskn/html/lotus/core/core.functions.php(637) : eval()'d code on line 217
It's because you use syntax like $_POST[name]. You need to use quotes around the array key.

Code: Select all

$_POST["name"]
Notice: Undefined variable: message in /home/u2/ztezgkkskn/html/lotus/core/core.functions.php(637) : eval()'d code on line 221

Notice: Undefined variable: email in /home/u2/ztezgkkskn/html/lotus/core/core.functions.php(637) : eval()'d code on line 223
What does it sound like it's saying to you? That the "message" and "email" variables are undefined?
You're trying to use a variable that doesn't exist yet. It doesn't have a value. You can't use it.
Warning: mail() expects at least 3 parameters, 2 given in /home/u2/ztezgkkskn/html/lotus/core/core.functions.php(637) : eval()'d code on line 221
Again, what do you think?

Code: Select all

bool mail  ( string $to  , string $subject  , string $message  [, string $additional_headers  [, string $additional_parameters  ]] )
In mail($my_email, $message) you are setting the "to" to $my_email and the "subject" to $message. There's no mention of "message".