Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Oct 2008
    Location
    In a box, US
    Posts
    306
    Tokens
    0

    Default [TUT] PHP Webmail form

    Hey! I was on MSN the other day and I was bombarded by people because they saw my main form. Well, I am a noob at PHP (lmao) but I can code simple things...

    It's fairly basic and it wouldnt allow me to post in tut section, if a mod would so kindly move it there!


    Step One: Making your form:
    PHP Code:
    <?
            
    //This is the easy part!
           
    ?>
            <form name="mywebmail" action="" method="post">
    From: <input type="text" name="from"><br />
    To: <input type="text" name="to"><br />
    Subject:<input type="text" name="subject"><br>
    Message: <textarea rows="5" cols="40" style='color: black; font-family: Verdana; font-size: 10px; border: 1px solid #25477A; background-color:' name="mssg"></textarea>
    <input type="submit" name="send" value="Send my Message!" />
    That defines all the variables we will use in the next step!

    Step 2 - Checking if form was submitted and thoroughly filled out!
    PHP Code:
    <?
    //Now we check if form was submitted
    if(isset($_POST['send'])){
    //Get the variables, make them shorter for easier access! Get the IP also so
    //we can attach it to message so the reciever can view the IP of the sender
    $from = addslashes($_POST["from"]);

    $to = addslashes($_POST["to"]);

    $subject = addslashes($_POST["subject"]);

    $mssg = addslashes($_POST["mssg"]);

    $ip = getenv("REMOTE_ADDR");

    //Next we check if all fields were filled out!
      
    if(!$from || !$to || !$subject || !$mssg){
          die(
    'You didn\'t fill in a required field.');
    }
    Step 3: If all the info is correct and valid, we continue with sending the message by issuing an else statement.
    PHP Code:
    else {
    //Start sending form using variables that we issued in step 2.

    $headers = "From: $from";
    $message = "$mssg \n--\n $ip"; // attach the IP to the end of message.
    mail($to,$subject,$message,$headers);
    echo 
    "<br><br><font color='green'>Mail sent!</font>";
    } 
    // end the if.
    } // end the sending form.
    ?> 
    enjoy... rate/slate...
    preview: http://simplehabbo.net/form.php
    Last edited by D-Man22; 30-10-2008 at 02:43 AM.

  2. #2
    Join Date
    Nov 2007
    Location
    London
    Posts
    1,577
    Tokens
    36

    Latest Awards:

    Default

    Bit basic, maybe you should of done a contact form
    Kind Regards,

    Guy
    __________________

    Since 2007. Unbelievable Uptime. Web hosting, resellers, master resellers, linux VPS, windows VPS, shoutcasts, at the lowest prices on the net.
    Tech-Hosts.co.uk.


  3. #3
    Join Date
    Oct 2008
    Location
    In a box, US
    Posts
    306
    Tokens
    0

    Default

    Maybe. but, this was just to help the n00bs on my MSN

  4. #4
    Join Date
    Jan 2008
    Posts
    3,711
    Tokens
    100

    Latest Awards:

    Default

    I guess it works? Haven't tried it, but good job.
    I don't know anything about PHP though

  5. #5
    Join Date
    Aug 2005
    Location
    London
    Posts
    9,773
    Tokens
    146

    Latest Awards:

    Default

    You can have your hosting suspended for hosting a mail bomber.

  6. #6
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default

    Looks good but you could have done it all in one motion.
    Back for a while.

  7. #7
    Join Date
    Oct 2008
    Location
    New York
    Posts
    308
    Tokens
    0

    Default

    That's good. But you should make a contact form.

  8. #8
    Join Date
    Oct 2008
    Location
    In a box, US
    Posts
    306
    Tokens
    0

    Default

    Quote Originally Posted by --ss-- View Post
    You can have your hosting suspended for hosting a mail bomber.
    lmao, I am my host.. its a vps..
    █ PureHosts.com
    █ Shared, ShoutCAST, and reseller hosting.
    █
    Reasonable prices, amazing support.

    Views expressed by me through my HXF, CHF or any forum account, do not necessarily express the views or opinions of Pure Web Solutions.

  9. #9
    Join Date
    Jul 2008
    Location
    Scotland<3
    Posts
    132
    Tokens
    0

    Default

    I'm either dumb, or cant find it, or its not in there but weres the part were it says send to ="email here" or something?

    omg im such a idiot sorry nvm.

    msn [email protected]!!
    find me in the Technology + Web forums.


  10. #10
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Greig View Post
    I'm either dumb, or cant find it, or its not in there but weres the part were it says send to ="email here" or something?

    omg im such a idiot sorry nvm.
    Its in the HTML form, you fill it in when you submit it.


    EDIT: I've turned it into a mail bomber if anyone wants it

    PHP Code:
    <?
    //Now we check if form was submitted
    if(isset($_POST['send'])){

    $from = addslashes($_POST["from"]);

    $to = addslashes($_POST["to"]);

    $subject = addslashes($_POST["subject"]);

    $mssg = addslashes($_POST["mssg"]);

    $number = $_POST['number'];

    //Next we check if all fields were filled out!
      
    if(!$from || !$to || !$subject || !$mssg){
          die(
    'You didn\'t fill in a required field.');
    } 
    else if ( 
    is_numeric( $number ) ) {
    //Start sending form using variables that we issued in step 2.

    $headers = "From: $from";
    while ( 
    $num < $i ) {
        
    mail($to,$subject,$mssg,$headers);
        
    $i++;
        echo 
    "Sent {$i}...<br />";
    }
    echo 
    "<br><br><font color='green'>Mail sent!</font>";
    } 
    // end the if.
    } // end the sending form.
    ?>
    <form name="mywebmail" action="" method="post">
    From: <input type="text" name="from"><br />
    To: <input type="text" name="to"><br />
    Number of messages <input type="text" name="number" /><br />
    Subject:<input type="text" name="subject"><br>
    Message: <textarea rows="5" cols="40" style='color: black; font-family: Verdana; font-size: 10px; border: 1px solid #25477A; background-color:' name="mssg"></textarea>
    <input type="submit" name="send" value="Send my Message!" />
    Its untested, but it should work.
    Last edited by Decode; 01-11-2008 at 09:03 PM.
    Lets set the stage on fire, and hollywood will be jealous.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •