PHP Mail Form

Discussion in 'Web Design & Coding' started by Grandmaster, Jan 6, 2004.

  1. Grandmaster

    Grandmaster Electronica Addict Political User Folding Team

    Messages:
    10,574
    Location:
    Santa Clara, CA
    Hi guys, I'm looking for a PHP Mail Form script for use at my site. I just want it to be really simple and I don't want my email address to be displayed in the code as well, so all the spam bots can't pick it up. Please post any good ones you know of. :)

    Thanks
     
  2. Jason

    Jason I'm Just Me!

    Messages:
    36
    Location:
    Beverley, UK
  3. Grandmaster

    Grandmaster Electronica Addict Political User Folding Team

    Messages:
    10,574
    Location:
    Santa Clara, CA
    Simple php mail looks like what I need, I'll try it when I get home. Thanks :)
     
  4. yodler

    yodler OSNN Junior Addict

    Messages:
    20
    happens to be the one i use.
     
  5. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    The one I wrote for camportal :)
    PHP:
    case ask:
    print 
    "<br />Please enter your details
    <form action=\"?page=send\" method=\"post\">
    <div>
    <br /><label for=\"username\">Your name</label>
    <br />&nbsp;&nbsp;&nbsp;&nbsp;
    <input type=\"text\" name=\"usersname\" id=\"username\" /><br />
    <br /><label for=\"usersurl\">Your Website (enter \"none\" if you don't have one)</label>
    <br />&nbsp;&nbsp;&nbsp;&nbsp;
    <input type=\"text\" name=\"usersurl\" id=\"usersurl\" /><br />
    <br /><label for=\"camurl\">Your WebCam URI/Image (<b>must be a direct .jpg link!</b>)</label>
    <br />&nbsp;&nbsp;&nbsp;&nbsp;
    <input type=\"text\" name=\"camurl\" id=\"camurl\" /><br />
    <br /><label for=\"mailfrom\">Your E-Mail adress (for contact use only, won't be displayed)</label>
    <br />&nbsp;&nbsp;&nbsp;&nbsp;
    <input type=\"text\" name=\"mailfrom\" id=\"mailfrom\" /><br />
    <br /><label for=\"where\">Where did you hear about us?*</label>
    <br />&nbsp;&nbsp;&nbsp;&nbsp;
    <input type=\"text\" name=\"where\" id=\"where\" /><br />
    <br /><label for=\"comment\">Questions / Comments?*</label>
    <br />&nbsp;&nbsp;&nbsp;&nbsp;
    <textarea name=\"comment\" id=\"comment\" rows=\"5\" cols=\"20\" ></textarea><br /><br />
    <br />&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"submit\" value=\"Send\" />
    </div>
    </form>
    <br /><br /><br />
    <br /><br /><br />
    <i>* optional field</i>"
    ;
    break;
    case 
    send:
    $fielderror "<font color=\"red\">Please fill in ALL fields.</font>";
    if (
    $_POST[mailfrom] == NULL) {print "$fielderror";}
    elseif (
    $_POST[camurl] == NULL) {print "$fielderror";}
    elseif (
    $_POST[usersurl] == NULL) {print "$fielderror";}
    elseif (
    $_POST[usersname] == NULL) {print "$fielderror";}
    else {
    $_POST[usersname] == stripslashes($_POST[usersname]);
    mail("E@MAIL.DOMAIN""Subject","CAM URL : $_POST[camurl]\nUSER name: $_POST[usersname]\nURL: $_POST[usersurl]\nEMAIL: $_POST[mailfrom]\nWHERE: $_POST[where]\nCOMMENTS: $_POST[comment] \n\n\n\n oki, thx.",
         
    "From: $_POST[mailfrom]\r\n"
        
    ."X-Mailer: PHP/" phpversion());
    print 
    "
    <script language=\"javascript\" type=\"text/javascript\">
    setTimeout(\"window.location.replace('?');\",5000);
    </script>
    <b>Request Sent!</b>
    <br /><br />&nbsp;&nbsp;
    <table border=\"0\">
    <tr>
    <td valign=\"top\" width=\"150\">&nbsp;&nbsp;Submitted Information </td>
    <td>
    <i>From</i><br /> 
    $_POST[usersname] (<a href=\"mailto:$_POST[mailfrom]\">$_POST[mailfrom]</a>)
    <br />
    <br /><i>Cam URL</i><br /> <a href=\"
    $_POST[camurl]\">$_POST[camurl]</a>
    <br />
    <br /><i>Website URL</i><br /> <a href=\"
    $_POST[usersurl]\">$_POST[usersurl]</a>
    </td></tr></table>
    <br />
    <br />
    <br /><b>Your details have been submitted and will be reviewed.<br /><span style=\"font-size:18px;\">this is NOT an instant process.</span></b>
    <br />
    <br />
    <br />You will be re-directed to the <a href=\"?page=one\">main page</a> in a few seconds.
    "
    ;
    }
    break;
     
  6. Grandmaster

    Grandmaster Electronica Addict Political User Folding Team

    Messages:
    10,574
    Location:
    Santa Clara, CA
  7. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    Hey, it works!
    :p
     
  8. Grandmaster

    Grandmaster Electronica Addict Political User Folding Team

    Messages:
    10,574
    Location:
    Santa Clara, CA
    Oh yes you are, oh yes :D
     
  9. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    Looks like that script could do with a stripslashes(); in there. :)
     
  10. Grandmaster

    Grandmaster Electronica Addict Political User Folding Team

    Messages:
    10,574
    Location:
    Santa Clara, CA
    Heh, that isn't how I got the email, I just adding the Subject, Message part.
     
  11. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    :withstupid:
     
  12. ~bk

    ~bk I Political User

    Messages:
    3,768
    Location:
    Canada
    lol :D
     
    Grandmaster likes this.