SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2009
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with PHP mail form

    Hey,

    I'm needing to put a form together for a client but i have a lack of knowledge in PHP and i can't figure out what i need to do to get the form working.

    Previously, my client had a form he created in Dreamweaver on his site, which i copy pasted the code for from the source code of his site. I then placed the .php file in my folder which acts as a 'thankyou for your booking' page people are directed to once submitting the form.

    I thought this would be all i needed but when testing the form no e-mail is received, so I'm obviously missing something.

    I noticed as well that there are three e-mail addresses written within the form code: 2 in the HTML and one in the PHP. Are these necessary, should they all be the same?

    Any help is appreciated!

    Here is the site and the form: http://feedthefitness.com/test/skydive2/bookings.html

    This is the PHP code:

    Code:
    <?php
    $to = "$username";
    $subject = "From your website www.skydivecanberra.com.au";
    $headers  = "MIME-Version: 1.0\r\n";
    if (strlen($email) < 10) {
    $headers .= "From: Your Website <shnikkidrum@hotmail.com>\r\n"; }
    else { $headers .="From: $Name <$email>\r\n"; }
    
    
    $message = "
    Day: $Day Date: $Time $Select2 $Year
    
    Name: $Name
    Address: $Address1
    Town/Suburb: $TownSuburb
    State: $State
    Postcode: $postcode
    
    Work: $WorkPh
    Home: $HomePh
    Mobile: $Mobile
    Fax: $FaxPh
    
    Email: $email
    
    Video Required: $video
    
    Comments: 
    $comments";
    
    mail($to, $subject, $message, $headers);
    ?>
    <HTML>
    <HEAD>
    </HEAD>
    <BODY>
    <h1> Thank you, your booking form has been submitted - Terry or Tina will contact you ASAP to confirm the booking and arrange payment of deposit. </h1>
    </BODY>
    </HTML>
    Thanks

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I replace your $to with my email address and run this,I get an email. Is the the full script? Because none of these variables have anything in them, you need to get them from the previous form using $_POST[].

    PHP Code:
    $to $_POST['username']; 

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2009
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply. When you entered your e-mail address do you mean you entered it here:

    $to = "$username";

    so

    $to = "email@address.com";

    or change it too - $to = $_POST['username'];

    ?

    I currently have my e-mail address in the PHP form -
    $headers .= "From: Your Website <myemail@hotmail.com>\r\n"; }

    is this wrong?

    Sorry, i haven't ever done anything with PHP before so I'm extremely clueless.

    Should i change the e-mails within the HTML code as well? Because they aren't matching what is declared in the PHP mail form.


    <input name="Submit" type="submit" onClick="MM_goToURL('parent','email@address2.com');return document.MM_returnValue" value="Submit"> -->

    and near the top of the form:

    <input type="hidden" name="username" value="email@address3.com">


    Thanks!

  4. #4
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just did $to = "email@address.com"; you need to either hard-code the email, or pull it from the posted data. If you're new to php forms, give this site a read: http://www.tuxradar.com/practicalphp/7/0/0

    This form is also very vulnerable to be hijacked and used to spam, as the user controls the "to" email address. You'll also receive a lot of form-spam as there's nothing to verify the sender as a human. You might be better of just finding a ready-made php email script.

  5. #5
    SitePoint Zealot
    Join Date
    Feb 2009
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When i enter my e-mail address in the $to, when submitting the form i get the error:

    Parse error: syntax error, unexpected T_VARIABLE in /home/feedthe1/public_html/test/skydive2/mail.php on line 3

    Thanks for the link, I've been looking for some informative tutorials so i will give them a read.

    My client mentioned he is receiving a lot of spam through the form, so it's probably a good idea to start from scratch. I have previously used an open source form generater to create a form which works fine and allows you to enter a spam code. Although i don't know why but my client seems to want it to all be done in dreamweaver, even though i don't use it myself.

    Do you know where i could find a ready made php email script? Would this script just be a replacement for my current mail.php file? I don't want to go in to deep with PHP as i am clueless.


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
  •