fazlionline Posted May 23, 2009 Report Share Posted May 23, 2009 Hi All I have a form: http://www.fazlionline.com/school/send_email_03.php I want if anyone fill this form and press the button, the given information should be sent to me. But it not works Parse error: syntax error, unexpected '@' in E:\inetpub\vhosts\fazlionline.com\httpdocs\school\send_email_03.php on line 2 Can anyone help me? !!!I want my script so simple!!! Is there anything needed. Thanks Quote Link to comment Share on other sites More sharing options...
tpattison Posted May 24, 2009 Report Share Posted May 24, 2009 Please post the PHP code of that page so that we can diagnose the problem. Quote Link to comment Share on other sites More sharing options...
fazlionline Posted May 26, 2009 Author Report Share Posted May 26, 2009 (edited) ok Edited May 26, 2009 by fazlionline Quote Link to comment Share on other sites More sharing options...
fazlionline Posted May 26, 2009 Author Report Share Posted May 26, 2009 Send us your feed back: Name: Message: Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted May 26, 2009 Report Share Posted May 26, 2009 The mail function needs a minimum of 3 parameters. To, Subject and Message are required, Additional headers and Parameters are optional, although the From header is suggested to avoid becoming Spam. $to = 'nobody@example.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> http://ca.php.net/manual/en/function.mail.php Quote Link to comment Share on other sites More sharing options...
fazlionline Posted May 26, 2009 Author Report Share Posted May 26, 2009 Thanks Dear This was successful But have TWO problems: 1. When I go to this page, an email is automatically sent to my inbox. 2. I write the email address in ?Email? box, but it not appears in the email received, it just says ?From: "$_POST@yahoo.com" <$_POST@yahoo.com>". 3. Is sending emails direct to inbox is safe. Please check http://www.fazlionline.com/school/send_email_01.php again Thanks Quote Link to comment Share on other sites More sharing options...
cugopob.vlad Posted May 26, 2009 Report Share Posted May 26, 2009 1. When I go to this page, an email is automatically sent to my inbox. here i would use the conditional statement after you validate all the user input, for example: if($_POST['button']){ mail($to, $subject, $message, $headers); } this way it only sends the message when you push the send button 2. I write the email address in ?Email? box, but it not appears in the email received, it just says ?From: "$_POST@yahoo.com" <$_POST@yahoo.com>". and here what i would do is put the elements into the html. such as and then assign the user input in email the the variable $email like this $email=$_POST['email']; $to = 'nobody@example.com'; $subject = 'the subject'; $message = 'hello'; $headers = "From: $email" . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); Quote Link to comment Share on other sites More sharing options...
fazlionline Posted May 27, 2009 Author Report Share Posted May 27, 2009 (edited) I made the changes as you told, but it still give error. At this time, no email is sent to my inbox. My new code is: <?php if($_POST['button']){ mail($to, $subject, $message, $headers); } $email=$_POST['email']; $to = $_POST['email']; $subject = $_POST['name']; $message = $_POST['message']; $headers = "From: $email" . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); ?> The error I receive is: Warning: mail() [function.mail]: SMTP server response: 503 Bad sequence of commands. You must specify the recipients of a message before you can send it in E:\inetpub\vhosts\fazlionline.com\httpdocs\school\send_email_01.php on line 4 What is the solution? check it here: http://www.fazlionline.com/school/send_email_01.php Edited May 27, 2009 by fazlionline Quote Link to comment Share on other sites More sharing options...
cugopob.vlad Posted May 27, 2009 Report Share Posted May 27, 2009 Send us your feed back: <?php if ($_POST && isset($missing) && !empty($missing)) { ?> Please complete the missing item(s) indicated. <?php } elseif ($_POST && $mailsent = false) { ?> Sorry, there was a problem sending your message. Please try later. <?php } elseif ($_POST && $mailsent = true) { ?> Your message has been sent. Thank you for your feedback. <?php } ?> Name: <?php if(isset($missing) && in_array('name', $missing)) { ?> :Please enter your name <?php }?> Email: <?php if(isset($missing) && in_array('email', $missing)) { ?> :Please enter your email <?php }?> Message: <?php if(isset($missing) && in_array('message', $missing)) { ?> Please enter your Message: <?php }?> <?php if (isset($missing)) { echo htmlentities($_POST['message']); } ?> Quote Link to comment Share on other sites More sharing options...
fazlionline Posted May 28, 2009 Author Report Share Posted May 28, 2009 (edited) hello cugopob.vlad i tried your code, is too lengthyit and gives error, Method Not AllowedThe HTTP verb used to access this page is not allowed. see it here: http://www.fazlionline.com/school/killer01.html I liked jlhaslip's Script hi jlhaslip, will u plz help me just to add one field for email only!!! or see the form agian: http://www.fazlionline.com/school/email01.html Thansk Edited May 28, 2009 by fazlionline Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted May 28, 2009 Report Share Posted May 28, 2009 $to = 'nobody@example.com'; $subject = 'the subject'; $message = 'hello'; $message .= "\r\n"; $message .= $_POST['uremail']; $message .= "\r\n"; $message .= 'End message'; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> Quote Link to comment Share on other sites More sharing options...
fazlionline Posted June 21, 2009 Author Report Share Posted June 21, 2009 I tried all the above codes, but an error occurs on every code Now let?s start from beginning and make a new file Quote Link to comment Share on other sites More sharing options...
fazlionline Posted June 21, 2009 Author Report Share Posted June 21, 2009 Ok Now, I have three fields, Name, Email and Message Can anyone write a simple & fresh code for me? See my page here: http://www.fazlionline.com/help/sendemail01.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.