Jump to content

Recommended Posts

<?php

        if ( $REQUEST_METHOD == "POST" ) {

 
        $realname = strip_tags($realname);
        $email = strip_tags($email);
        $feedback = strip_tags($feedback);

 
        $sendto = "zjp19831102@163.com";
        $subject = "order request";
        $message = "$realname, $email\n\n$feedback";
          mail($sendto, $subject, $message);

              }
        ?>
    <?php

    if ($REQUEST_METHOD=="POST") {
        echo("<p><b>Thank you for your feedback. The following message was sent:</b></p>\n");
        echo("<blockquote><pre>\n");
        echo("$message");
        echo("</pre></blockquote>");
?>
<meta http-equiv="refresh" content="5">
  <?
    }

    else {
?>
<script language="javascript">
  function DoSubmit ()
  {
    if (document.form.realname.value == "") {
      alert ("You forgot to enter your name.");
      document.form.realname.focus ();
      return "";
    }
    if (document.form.email.value == "") {
      alert ("You forgot to enter your email.");
      document.form.email.focus ();
      return "";
    }

    if (document.form.reedback.value == "") {
      alert ("You forgot to enter your feedback. ");
      document.form.reedback.focus ();
      return "";
    }

    document.form.submit ();
  }
</script>
  <form action="<?php echo("$script_name"); ?>" METHOD="POST" name="form">
  <table cellpadding="4" cellspacing="0" border="0">
    <tr><td><b>Name: </b></td><td><input type="text" name="realname" size="25"></td></tr>
    <tr><td><b>Email:</b></td><td><input type="text" name="email" size="25"></td></tr>
    <tr><td colspan=2><b>Feedback:</b><br />
        <textarea name="feedback" rows="12" cols="45" wrap="physical"></textarea>
    </td></tr>
    <tr><td colspan="2" align="center"><input type="submit" onclick="DoSubmit ()" value="send"></td></tr>
  </table>
  </form>


<?php } ?>


??? ??? ??? ??? ???
This code can't send the mail ,who can tell me where i'm wrong !
Thanks a lot!!!!
Link to comment
https://forums.phpfreaks.com/topic/13819-how-to-send-mail-by-php/
Share on other sites

so...what do you mean by it "can't" send the mail? are you getting an error message of some kind? are you getting your "Thank you for your feedback. The following message was sent:" but it wasn't sent? please provide as much details as possible.

and by the way:
[code]
$realname = strip_tags($realname);
$email = strip_tags($email);
$feedback = strip_tags($feedback);
[/code]
unless register_globals is set to ON in your php.ini this won't work. you need to do this:
[code]
$realname = strip_tags($_POST['realname']);
$email = strip_tags($_POST['email']);
$feedback = strip_tags($_POST['feedback']);
[/code]

and it should be $_SERVER['REQUEST_METHOD'] unless register_globals is set to ON, as well.  but even if it IS set to ON, you shouldn't use your variables as you are using them. you should be using $_POST and $_SERVER for security reasons.
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.