Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: adding another function to the form

  1. #11
    Join Date
    Jan 2009
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Could you, please, check once again. Here is the whole script:
    I saved it as contact.php

    Something is wrong?

    <?php
    $to = $_REQUEST['sendto'] ;
    $from = $_REQUEST['Email'] ;
    $name = $_REQUEST['Name'] ;
    $headers = "From: $from";
    $subject = "Web Contact Data";

    $fields = array();
    $fields{"Name"} = "Name";
    $fields{"Company"} = "Company";
    $fields{"Email"} = "Email";
    $fields{"Phone"} = "Phone";
    $fields{"List"} = "Mailing List";
    $fields{"Message"} = "Message";

    $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

    $headers2 = "From: noreply@YourCompany.com";
    $subject2 = "Thank you for contacting us";
    $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.oursite.com";
    if($from == '') {print "You have not entered an email, please go back and try again";}
    else {
    if($name == '') {print "You have not entered a name, please go back and try again";}
    else {
    $send = mail($to, $subject, $body, $headers);
    $send2 = mail($from, $subject2, $autoreply, $headers2);

    if ($send) {
    if (isset($_POST['check'])) {
    $direct_to = 'http://www.knitsandpieces.com/thankyou.htm';
    } else {
    $direct_to = 'http://www.knitsandpieces.com/thankyou2.htm';
    }
    {
    header("Location: " . $direct_to);
    } else {
    print "We encountered an error sending your mail, please notify info@dekko2.com";
    }
    }
    ?>

  2. #12
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Change:
    Code:
    if ($send) {
    if (isset($_POST['check'])) {
    $direct_to = 'http://www.knitsandpieces.com/thankyou.htm';
    } else {
    $direct_to = 'http://www.knitsandpieces.com/thankyou2.htm';
    }
    {
    header("Location: " . $direct_to);
    } else {
    print "We encountered an error sending your mail, please notify info@dekko2.com";
    }
    }
    To:
    Code:
    if ($send) {
    if (isset($_POST['check'])) {
    $direct_to = 'http://www.knitsandpieces.com/thankyou.htm';
    } else {
    $direct_to = 'http://www.knitsandpieces.com/thankyou2.htm';
    }
    header("Location: " . $direct_to);
    } else {
    print "We encountered an error sending your mail, please notify info@dekko2.com";
    }
    }
    My bad.
    Jeremy | jfein.net

  3. #13
    Join Date
    Jan 2009
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wink

    Thank you for all your help!
    Actually, it still gave me the error message when I did syntax check of the file, but I added one more curly thing { at the very end and it WORKS now!

    Again, oodles of thanks!

    if ($send) {
    if (isset($_POST['check'])) {
    $direct_to = 'http://www.knitsandpieces.com/thankyou.htm';
    } else {
    $direct_to = 'http://www.knitsandpieces.com/thankyou2.htm';
    }
    header("Location: " . $direct_to);
    } else {
    print "We encountered an error sending your mail, please notify info@dekko2.com";
    }
    }
    } (I added this one)

  4. #14
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Ok, great. Your welcome - and I'm glad to help you. (This is why I had the } at the way bottom, but it then gave you an error)
    Jeremy | jfein.net

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
  •