webspinner Posted April 19, 2007 Share Posted April 19, 2007 I'm trying to get a simple(?) sendmail script working. It's not. :-\ I noticed that some coordinates are being sent along with my variables to the server in the URL string: for instance: "%21%3F&submit.x=31&submit.y=8" Where are these coming from? I can't figure it out. And could that be causing my script to fail? Is the order of the variables critical? Here's the script: <? if(!empty($_POST['name']) || !empty($_POST['email']) || !empty($_POST['message'])) { $to = "buzz@yahoo.com"; $subject = "You Rock \n"; $body = stripslashes($_POST['message']); $body .= "\n\n---------------------------\n"; $body .= "Mail sent by: " . $_POST['name'] . " <" . $_POST['email'] . ">\n"; $header = "From: " . $_POST['name'] . " <" . $_POST['email'] . ">\n"; $header .= "Reply-To: " . $_POST['name'] . " <" . $_POST['email'] . ">\n"; $header .= "X-Mailer: PHP/" . phpversion() . "\n"; $header .= "X-Priority: 1"; if(@mail($to, $subject, $body, $header)) { echo "output=sent"; } else { echo "output=error"; } } else { echo "output=error"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/47770-coordinates-being-sent-with-nameval-pairs/ Share on other sites More sharing options...
kenrbnsn Posted April 19, 2007 Share Posted April 19, 2007 Those are sent if you are using an image for the submit button. PHP sees them as $_POST['submit_x'] and $_POST['submit_y']. Sending email to Yahoo, AOL, and Hotmail from PHP can be problematical. If you search the forums for email problems, you should find a number of threads that deal with possible solutions. Ken Quote Link to comment https://forums.phpfreaks.com/topic/47770-coordinates-being-sent-with-nameval-pairs/#findComment-233337 Share on other sites More sharing options...
webspinner Posted April 19, 2007 Author Share Posted April 19, 2007 Ken, Thanks. However, this script is working on another site with the same TO: email. Is the order of the variables an issue and does PHP just ignore the $_POST['submit_x'] and $_POST['submit_y'], or does it cause a problem. Thanks, Rick Quote Link to comment https://forums.phpfreaks.com/topic/47770-coordinates-being-sent-with-nameval-pairs/#findComment-233341 Share on other sites More sharing options...
kenrbnsn Posted April 19, 2007 Share Posted April 19, 2007 However, this script is working on another site with the same TO: email. Is that another site on the same server or another site on a different server? What do you mean by Is the order of the variables an issue Since you're not referring to either $_POST['submit_x'] or $_POST['submit_y'], you don't have to worry about them. Ken Quote Link to comment https://forums.phpfreaks.com/topic/47770-coordinates-being-sent-with-nameval-pairs/#findComment-233343 Share on other sites More sharing options...
webspinner Posted April 19, 2007 Author Share Posted April 19, 2007 <<Is that another site on the same server or another site on a different server?>> same server, different folder <<What do you mean by>> Uh, I guess I was wondering if the variables need to arrive in the same order they show up in the PHP script. Guess not. Also, I changed the email address to one at a school. Still getting the not-too-illustrative: output=error Quote Link to comment https://forums.phpfreaks.com/topic/47770-coordinates-being-sent-with-nameval-pairs/#findComment-233362 Share on other sites More sharing options...
kenrbnsn Posted April 19, 2007 Share Posted April 19, 2007 Remove the "@" symbol from the "mail" line. It is suppressing the real error message that might help solve the problem. Never use the "@" symbol during development work. Ken Quote Link to comment https://forums.phpfreaks.com/topic/47770-coordinates-being-sent-with-nameval-pairs/#findComment-233377 Share on other sites More sharing options...
webspinner Posted April 19, 2007 Author Share Posted April 19, 2007 Ken, <<Remove the "@" symbol from the "mail" line. It is suppressing the real error message that might help solve the problem. Never use the "@" symbol during development work.>> I did that and received the same: "output=error". But then the light went on.... I changed the form method from post to get and it works!! Should I put the "@" back in? Thanks for stayin with this. -Rick Quote Link to comment https://forums.phpfreaks.com/topic/47770-coordinates-being-sent-with-nameval-pairs/#findComment-233403 Share on other sites More sharing options...
kenrbnsn Posted April 19, 2007 Share Posted April 19, 2007 Did you also change all the references of $_POST to $_GET? Ken Quote Link to comment https://forums.phpfreaks.com/topic/47770-coordinates-being-sent-with-nameval-pairs/#findComment-233411 Share on other sites More sharing options...
webspinner Posted April 19, 2007 Author Share Posted April 19, 2007 No, but it works. Should I? Quote Link to comment https://forums.phpfreaks.com/topic/47770-coordinates-being-sent-with-nameval-pairs/#findComment-233418 Share on other sites More sharing options...
kenrbnsn Posted April 19, 2007 Share Posted April 19, 2007 If your form uses the "get" method, all the values are passed to the $_GET superglobal array, if the method is "post", then they are in $_POST. At the top of you script, put the following two lines that will dump the contents of each array to your screen: <?php echo '<pre>$_GET:' . print_r($_GET,true) . '</pre>'; echo '<pre>$_POST:' . print_r($_POST,true) . '</pre>'; ?> Where do you see the values? Ken Quote Link to comment https://forums.phpfreaks.com/topic/47770-coordinates-being-sent-with-nameval-pairs/#findComment-233421 Share on other sites More sharing options...
webspinner Posted April 19, 2007 Author Share Posted April 19, 2007 In the post array.... but wait. My bigger concern is that what happens after the success. Now, all the user gets is directed to a page with "Output=success" Not ok. My ideal would be to have some text displayed on my page that the mail was sent... But I might be ok with a simple redirect back to my page, if the former's too complicated. -Rick Quote Link to comment https://forums.phpfreaks.com/topic/47770-coordinates-being-sent-with-nameval-pairs/#findComment-233437 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.