Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2007
    Location
    Leeds - UK
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Emails from a form using PHP [New to PHP]

    Hi all.

    I'm competant with HTML and such and have decided to pick up a little PHP for my future studies etc.. I have some understanding of PHP, but nothing that can be properly applied.

    I was thinking that I would try producing a webform to send me emails of whatever has been entered. The idea sounds easy enough to me, but I have a couple of questions to someone who knows PHP (and related skills).

    First, how easy is this to implement? I'm not quite a beginner, but might as well be sometimes.

    Second, what do I need to get this working?

    Many thanks if you do reply. If you need more info of what I am trying to do or what I can do let me know.

    Cheers
    sjwatsi

  • #2
    New Coder
    Join Date
    Sep 2006
    Posts
    92
    Thanks
    4
    Thanked 1 Time in 1 Post
    Assuming you know how to get the form data over to the php script and you are sending 3 fields : from, subject and body you could do something like this

    PHP Code:
    <?php
         $from 
    $_POST['from'];
         
    $subj $_POST['subject'];
         
    $body $_POST['body'];

    mail'your_email@mail.com'$subj$body'From: $from' );

    ?>
    Not tried it, but I think that should work.
    Nemesis War
    Online browser based space combat game.
    It's free, it's great, you'll love it.
    Come join us at http://www.nemesiswar.net/

  • #3
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    You'll need to use double-quotes to parse the $from variable:
    PHP Code:
    <?php
         $from 
    $_POST['from'];
         
    $subj $_POST['subject'];
         
    $body $_POST['body'];

    mail'your_email@mail.com'$subj$body"From: {$from}" );

    ?>

  • #4
    New to the CF scene
    Join Date
    Sep 2007
    Location
    Leeds - UK
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Many thanks to both you guys.


  •  

    Posting Permissions

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