SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    psycho
    Join Date
    May 2000
    Location
    London
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, i have set up a form with names etc.

    how do i send it to an email address. i know php has a built in email function, but how does it work ?

    Thanks
    James

  2. #2
    SitePoint Zealot
    Join Date
    Nov 1999
    Location
    Manhattan!
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Pretty simple...

    Imagine you have a form with two fields, name and age.

    $text = "This info has been emailed from my super, duper secret online form. The info is: Visitors name = $name and age = $age";

    $email_addr = "me@mydomain.com";
    $subject = "Super secret form";

    mail($email_addr,$subject,$text);

    That is all there is to it...

    If you want to get a little more fancy, you can include headers, such as:

    $email_hdr = "From: Me, Myself and I <me@mydomain.com>";

    and then do

    mail($email_addr,$subject,$text,$email_hrd);

    Hope this helps.

    Christian

  3. #3
    psycho
    Join Date
    May 2000
    Location
    London
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK cheers. It emails it, but not the variables I insert.

    This is the code :

    (advertise.html)
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>&lt;FORM ACTION="php/advertise.php" method="post"&gt;
    &lt;table border="0" cellspacing="1" width="80%"&gt;
    &lt;tr&gt;
    &lt;td width="50%" bgcolor="#BFCFD0"&gt;&lt;small&gt;&lt;font face="Arial"&gt;Name:&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;
    &lt;td width="50%" bgcolor="#BFCFD0"&gt;&lt;small&gt;&lt;font face="Arial"&gt;&lt;input type="text" name="name"
    size="20"&gt;&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td width="50%" bgcolor="#BFCFD0"&gt;&lt;small&gt;&lt;font face="Arial"&gt;Company / Group: &lt;/font&gt;&lt;/small&gt;&lt;/td&gt;
    &lt;td width="50%" bgcolor="#BFCFD0"&gt;&lt;small&gt;&lt;font face="Arial"&gt;&lt;input type="text"
    name="companygroup" size="20"&gt;&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td width="50%" bgcolor="#BFCFD0"&gt;&lt;small&gt;&lt;font face="Arial"&gt;Email address:&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;
    &lt;td width="50%" bgcolor="#BFCFD0"&gt;&lt;small&gt;&lt;font face="Arial"&gt;&lt;input type="text" name="email"
    size="20"&gt;&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td width="50%" bgcolor="#BFCFD0"&gt;&lt;small&gt;&lt;font face="Arial"&gt;Telephone No.&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;
    &lt;td width="50%" bgcolor="#BFCFD0"&gt;&lt;input type="text" name="phone" size="20"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td width="50%" bgcolor="#BFCFD0" valign="middle"&gt;&lt;small&gt;&lt;font face="Arial"&gt;Questions /
    Requests &lt;/font&gt;&lt;/small&gt;&lt;/td&gt;
    &lt;td width="50%" bgcolor="#BFCFD0"&gt;&lt;small&gt;&lt;font face="Arial"&gt;&lt;textarea name="comments"
    rows="4" cols="30"&gt;&lt;/textarea&gt;&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td width="50%" bgcolor="#BFCFD0"&gt;&lt;small&gt;&lt;font face="Arial"&gt;How would you like to be
    contacted?&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;
    &lt;td width="50%" bgcolor="#BFCFD0"&gt;&lt;small&gt;&lt;font face="Arial"&gt;&lt;select box
    name="methodofcontact" size="1"&gt;
    &lt;option value="contactbyEmail"&gt; Email &lt;/option&gt;
    &lt;option value="contactbyPhone"&gt; Phone &lt;/option&gt;
    &lt;/select&gt;&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
    &lt;div align="center"&gt;&lt;center&gt;&lt;p&gt;&lt;small&gt;&lt;font face="Arial"&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &lt;br&gt;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type="submit"
    style="background-color: rgb(0,0,128); color: rgb(255,255,255); font-family: Arial"&gt;&lt;/font&gt;&lt;/small&gt;&lt;/p&gt;
    &lt;/center&gt;&lt;/div&gt;
    &lt;/form&gt;[/code]

    -------------------
    (advertise.php)
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>&lt;?php


    mail("funky_friars@hotmail.com", "Advertising application", "Persons name : $name\n Persons company/group : $companygroup\n Their email address : $email\n Their Telephone no : $phone\n Questions and requests : $requests\n They would like to be contacted by : $contactmethod");



    ?&gt;[/code]

    cheers again
    -james

  4. #4
    SitePoint Zealot
    Join Date
    Nov 1999
    Location
    Manhattan!
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you calling the mail() function inside a sub routine? Try to just print out $name, $number etc on the receiving page to check if the variables actually make it...

    Christian


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
  •