This is a discussion on "mail script" within the PHP Forum section. This forum, and the thread "mail script are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
mail script
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
mail script
Ive set up this mail script and im having trouble actually recieving the form are thier any glaring mistakes in it?
<?php if ($_POST) { if (GET_MAGIC_QUOTES_GPC()) { foreach ($_POST as $key => $value) { $temp = stripslashes($value); $_POST[$key] = $temp; } } $to = 'forzaparma1@gmail.com'; $subject = 'Link Exchange'; $message = "From:".$_POST['name']."\n"; $message .= "Email:".$_POST['email']."\n"; $message .= "Website:".$_POST['site']; $headers = "Reply-To:".$_POST['email']; $sent = mail($to, $subject, $message, $headers); } ?> |
|
|
|
|||
|
Re: mail script
It's only an assumption on my part as I've never seen it explicitely stated but I always assumed that, as far as the script was concerned, the globals like $_POST were read only. You are trying to write to it. I think you should rethink how you pick up your incoming variable values and clean them. |
|
|||
|
Re: mail script
I'm not exactly sure what you mean but this is the rest of the script
<?php if (isset($sent)) { echo '<p>Thank you, your details have been sent.</p>'; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" > |
|
|||
|
Re: mail script
I'm thinking something like:
|
|
||||
|
Re: mail script
Does the message send and not get received, or not get sent? You might check your mail settings in php.ini to make sure your server doesn't have rules you are breaking and isn't routing it through a server that won't process it without something you are lacking, like SMTP authentication.
The code itself is not something I can read well enough to give you a definitive answer, especially the "to" injection. The first thing I would do is echo the message to myself, to see the output. If it looked good, I would replace the TO header with my email address and see if it goes through. If not, you'll have to do a bit of code to give you a boolean response if the message is sent. I wouldn't use << if($_POST) >>, mostly because I'm not familiar with it, and actually wouldn't use << if(!empty($_POST)) >> which is the syntax I learned. I'd do a different IF clause for each variable and put any error message into an errors array, inside the IF $sent clause, like
There are a couple of sophisticated touches in your code. (Where'd you come up with << $_POST[$key] = $temp; >>? That's pretty ingenious if it works.) If this comes from Dreamweaver, it might be adding a space before the globals. I don't use it, but I've heard of this. My guess is you would need some sort of substring code to take it out, it would certainly mess you up. One other thought if you suspect the problem is with a server, is to use PEAR. |
|
||||
|
Re: mail script
Sorry, that would be << $errors = array(); >>
|
|
|||
|
Re: mail script
The form is sent I know this because the code
<?php if (isset($sent)) { echo '<p>Thank you, your details have been sent.</p>'; } ?> is displayed it just isnt getting recieved to my email.....I don't know where I came up with the code exactly I just read a few tutorials and pieced together what I knew....it isnt very sophisticated as to have code that stops spammers and such.....I should put in error mesages which I will do by making all fields required once I get the script to recieve...I've checked with my host the script is in compliance with all the rules set and such at least thats what tech support said....Ill read up some more and use a proven code before I try put together my own! |
![]() |
| Tags |
| mail, script |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] parse error, unexpected T_EXIT in php mail script | Posie | PHP Forum | 8 | Dec 13th, 2007 14:21 |
| Can someone help me with this e-mail form??? | johnson8707 | PHP Forum | 4 | Jul 4th, 2006 17:51 |
| e-mail lookup | pengyou | PHP Forum | 4 | Feb 16th, 2006 13:01 |
| visitors name not displayed in mail after filling in mail form | made on earth | PHP Forum | 7 | Nov 16th, 2005 22:43 |
| PHP form mail script required... | JohneeMac | PHP Forum | 7 | Sep 27th, 2004 18:54 |