Jump to content

Recommended Posts

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";

}

?>

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

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

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

<<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

 

 

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

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

 

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.