Jump to content


Photo

how to send mail by php


  • Please log in to reply
3 replies to this topic

#1 zjp

zjp
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 July 2006 - 07:29 AM

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

#2 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 06 July 2006 - 07:32 AM

$REQUEST_METHOD o.O What's that
Or are you trying to mean
$_REQUEST

Edit:
Check out on this site, hope it helps you.
http://www.thesitewi...edbackphp.shtml

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#3 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 06 July 2006 - 07:35 AM

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:
$realname = strip_tags($realname);
$email = strip_tags($email);
$feedback = strip_tags($feedback);
unless register_globals is set to ON in your php.ini this won't work. you need to do this:
$realname = strip_tags($_POST['realname']);
$email = strip_tags($_POST['email']);
$feedback = strip_tags($_POST['feedback']);

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.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#4 zjp

zjp
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 July 2006 - 07:48 AM

Thank you ,i try it




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users