Ok i'm willing to payfor what I need

Discussion in 'PHP' started by explore, Jan 15, 2009.

  1. #1
    Hi I'm looking for some help. I have a form mail and would like to have a php script to make it work. I'm not sure if i'm at the right place but hope someone can guide me there. My form mail is located at this link
    http://www.quebec-ufo-research.com/report%20form.html.
    I would like to keep the page the way it is. Can some show me the steps to get it working.
    Thanks :|
     
    explore, Jan 15, 2009 IP
  2. CaseyPC

    CaseyPC Active Member

    Messages:
    85
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    98
    #2
    I'll write you a PHP script that safely emails the form data and explain how you can use the PHP email script on all of your forms for $10.
     
    CaseyPC, Jan 15, 2009 IP
  3. artiskool

    artiskool Peon

    Messages:
    34
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That would be an easy task just to send an email.

    All you need to do first is check whether form is submitted by using if statement [ if ($_POST) ], then check all the validations and sanitized all the inputs as part of security. After that just call the mail() function in php passing the required parameters or parameters you want to pass and your done.

    Sample code below:

    
    // check if form with post method submitted
    if ($_POST) {
      // sanitized all your user inputs
      $name = $_POST['name']; //senders name
      $email = $_POST['email_from'];
      $recipient = $_POST['email_to'];
      $body = $_POST['body'];
      $subject = $_POST['subject'];
      $header = "From: ". $name . " <" . $email . ">\r\n";
    
      mail($recipient, $subject, $body, $header);
    }
    
    PHP:
     
    artiskool, Jan 15, 2009 IP
  4. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #4
    Yep, just stick <?php before and ?> after artiskool's code, and stick it in a file, for example, sendmail.php, and then set the action of the form to it, like action="sendmail.php"
     
    crath, Jan 15, 2009 IP
  5. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #5
    No offence, but only use that as is if you want your site to be turned into a spammers paradise.

    That could easily be made to send out thousands of spam emails from your hosting,

    PLEASE for the sake of sanity add validation to that or you may find yourself regretting it.
     
    Danltn, Jan 16, 2009 IP
  6. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #6
    or just limit the number of emails a user can send per day or whatever
     
    crath, Jan 16, 2009 IP
  7. ezay

    ezay Peon

    Messages:
    212
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Capatcha Script Maybe? So that bots cannot spam the site.
     
    ezay, Jan 16, 2009 IP
  8. harrisunderwork

    harrisunderwork Well-Known Member

    Messages:
    1,005
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    135
    #8
     $recipient = $_POST['email_to']; 
    Code (markup):
    Is there any need of this, I think email needs to be send in your inbox , right ?
     
    harrisunderwork, Jan 16, 2009 IP
  9. artiskool

    artiskool Peon

    Messages:
    34
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    For the sake of clarification I always do sanity and validations in every code I made to avoid some security issues like email injection, XSS and the like, and this does not mean to avoid spammers. Spammers are always there like bots and automated scripts, and you can prevent that by either using CAPTCHA.
     
    artiskool, Jan 16, 2009 IP
  10. artiskool

    artiskool Peon

    Messages:
    34
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    It depends on your requirements. It's up to you whether to remove it or not. It is just a sample code. :)
     
    artiskool, Jan 16, 2009 IP