SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP contact forms

    Hey there,

    I'm a complete novice to PHP and I would like to know a good book that can teach me the basics and tell me how to set up a contact form and send it via email using PHP - can anyone help please?

    Many thanks

  2. #2
    SitePoint Zealot
    Join Date
    Jun 2007
    Location
    Regina, SK, Canada
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I read the book "PHP & MySQL by Visual". Its a great picture book if you learn better that way! By the way, your contact form is below.

    Here is what the PHP should look like.

    Code PHP:
    if(isset($_POST['submit'])){
       // set vars
       $youremail = 'you@youremail.com'
       $email = $_POST['email'];
       $subject = 'Your subject here';
       $msg = 'Your message here';
       // headers
       $headers = "From: you [at] yourdomain.com \r\n";
       $headers.= "Content-Type: text/html; charset=ISO-8859-1 ";
       $headers .= "MIME-Version: 1.0 ";  
     
       mail($youremail,$subject,'Email: '.$email.'<br>Message: '.$msg,$headers);
       // sends their contact information to your email ($youremail).  You can then reply back to them since you have their email.
    }

    The HTML should look something like this.

    Code HTML4Strict:
    <form method="post">
      Your Email: <input type="text" name="email" />
      Your Message: <textarea name="msg"></textarea>
      <input type="submit" name="submit" value="Send" />
    </form>
    Last edited by jboesch; Jul 23, 2007 at 11:09.

  3. #3
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I always liked the Sam's teach yourself... yada yada yada books.

    I have a copy of Sam's teach yourself Php, Mysql, and apache. The apache end is mainly config. But, the mysql portion is cool to have around as a reference.

    They make a teach yourself Php, but the only copy I saw around was for php 4.0.

  4. #4
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Many thanks

    Hey thanks to you both for the reply - where do I put the PHP part of the script?

  5. #5
    SitePoint Zealot
    Join Date
    Jun 2007
    Location
    Regina, SK, Canada
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You put all of that on the same page. Put the PHP at the top above the <html> tag. So it should be like..

    <?
    The PHP Code
    ?>
    <html>
    <title>blah</title>
    <head>
    </head>

  6. #6
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    thanks again

    Thats very helpful, thanks again - i'll see how I get on!


Bookmarks

Posting Permissions

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