SitePoint Sponsor

User Tag List

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

    $success_sent_msg= (html site)

    Hello! i really dont know any php at all, but i've got a good working form on my website. But after the form is filled in, a thankyou message is being displayed, but instead of a message i would like a webpage to be opened (like thankyou.htm).

    Does anyone know what to change after "$success_sent_msg="
    this is the code i've got now:


    $success_sent_msg='<p align="center" class="header"><strong>Thank you &nbsp;</strong></p>
    <p align="center" class="thouart">Your quote request has been successfully sent to us<br>
    and we will reply as soon as possible.</p>
    <p align="center" class="thouart">A copy of your query has been sent to you.</p>
    <p align="center" class="header">Thank you for contacting us.</p>

    thak you for helping me.

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    header("Location: http://yoursite.tld/tankyou.htm"); 
    But make sure there is no output before it (no echo's).
    Saul

  3. #3
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    We need to see your whole script, what youve shown is just the variable that gets output.
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  4. #4
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by php_daemon View Post
    PHP Code:
    header("Location: http://yoursite.tld/tankyou.htm"); 
    But make sure there is no output before it (no echo's).
    Daemon, I'm not sure he/she is going to know where to put the redirect.
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  5. #5
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    uhm, ur right, i dont really under stand these replys (i am a girl) this is my whole script:

    /* PHP Form Mailer - phpFormMailer v2.1, last updated 30th Nov 2005 - check back often for updates!
    (easy to use and more secure than many cgi form mailers) FREE from:
    www.TheDemoSite.co.uk
    Should work fine on most Unix/Linux platforms */

    // ------- three variables you MUST change below -------------------------------------------------------
    $valid_ref1="http://www.corneli.nl/quote/contact.html";// chamge "Your--domain" to your domain
    $valid_ref2="http://www.corneli.nl/quote/contact.html";// chamge "Your--domain" to your domain
    $replyemail="secret@email.com";//change to your email address
    // ------------------------------------------------------------

    //clean input in case of header injection attempts!
    function clean_input_4email($value, $check_all_patterns = true)
    {
    $patterns[0] = '/content-type:/';
    $patterns[1] = '/to:/';
    $patterns[2] = '/cc:/';
    $patterns[3] = '/bcc:/';
    if ($check_all_patterns)
    {
    $patterns[4] = '/\r/';
    $patterns[5] = '/\n/';
    $patterns[6] = '/&#37;0a/';
    $patterns[7] = '/%0d/';
    }
    //NOTE: can use str_ireplace as this is case insensitive but only available on PHP version 5.0.
    return preg_replace($patterns, "", strtolower($value));
    }

    $name = clean_input_4email($_POST["name"]);
    $email = clean_input_4email($_POST["email"]);
    $thesubject = clean_input_4email($_POST["thesubject"]);
    $themessage = clean_input_4email($_POST["themessage"], false);
    $address = clean_input_4email($_POST["address"]);
    $postcode = clean_input_4email($_POST["postcode"]);
    $country = clean_input_4email($_POST["country"]);
    $telephone = clean_input_4email($_POST["telephone"]);
    $mobile = clean_input_4email($_POST["mobile"]);
    $size = clean_input_4email($_POST["size"]);
    $size2 = clean_input_4email($_POST["size2"]);
    $people = clean_input_4email($_POST["people"]);



    $error_msg='ERROR - not sent. Try again.';

    $success_sent_msg='<p align="center" class="header"><strong>Thank you &nbsp;</strong></p>
    <p align="center" class="thouart">Your quote request has been successfully sent to us<br>
    and we will reply as soon as possible.</p>
    <p align="center" class="thouart">A copy of your query has been sent to you.</p>
    <p align="center" class="header">Thank you for contacting us.</p>
    <p align="center" class="header"><a href="../start.html"></a></p>';

    $replymessage = "Hi $name

    Thank you for your quote request.

    We will endeavour to reply to you shortly.

    Please DO NOT reply to this email.

    Below is a copy of the message you submitted:
    --------------------------------------------------
    Subject: $thesubject
    Query:
    $themessage
    --------------------------------------------------

    Thank you";

    // email variable not set - load $valid_ref1 page
    if (!isset($_POST['email']))
    {
    echo "<script language=\"JavaScript\"><!--\n ";
    echo "top.location.href = \"$valid_ref1\"; \n// --></script>";
    exit;
    }

    $ref_page=$_SERVER["HTTP_REFERER"];
    $valid_referrer=0;
    if($ref_page==$valid_ref1) $valid_referrer=1;
    elseif($ref_page==$valid_ref2) $valid_referrer=1;
    if(!$valid_referrer)
    {
    echo "<script language=\"JavaScript\"><!--\n alert(\"$error_msg\");\n";
    echo "top.location.href = \"$valid_ref1\"; \n// --></script>";
    exit;
    }
    $themessage = "name: $name \nQuery: $themessage \naddress: $address \npostcode: $postcode \ncountry: $country \ntelephone: $telephone \nmobile: $mobile \nwidth: $size \nheight: $size2 \npeople: $people" ;
    mail("$replyemail",
    "$thesubject",
    "$themessage",
    "From: $email\nReply-To: $email");
    mail("$email",
    "Receipt: $thesubject",
    "$replymessage",
    "From: $replyemail\nReply-To: $replyemail");
    echo $success_sent_msg;

    ?>

  6. #6
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Replace the last line in your script

    echo $success_sent_msg;

    with the line that PHP_Daemon gave you, dont forget to change the path to the webpage you want to redirect to.
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  7. #7
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    All you have to do is change the last line (echo $success_sent_msg) to
    PHP Code:
    header("Location: http://www.corneli.nl/quote/tankyou.htm"); 
    And you can remove the $success_sent_msg initiation at all (the snippet you've posted in your first post).

    Edit:


    oops, too late
    Saul

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

    Question

    uhm, i understand what you guys are saying, i've changed the code, but now when i fill in the form i just get a blank page (wich is my, php page i think).. so its not loading the thankyou.html at all. You can see the form work at: http://www.corneli.nl/quote/contact.html

    this is the changed code:

    <?php
    /* PHP Form Mailer - phpFormMailer v2.1, last updated 30th Nov 2005 - check back often for updates!
    (easy to use and more secure than many cgi form mailers) FREE from:
    www.TheDemoSite.co.uk
    Should work fine on most Unix/Linux platforms */

    // ------- three variables you MUST change below -------------------------------------------------------
    $valid_ref1="http://www.corneli.nl/quote/contact.html";// chamge "Your--domain" to your domain
    $valid_ref2="http://www.corneli.nl/quote/contact.html";// chamge "Your--domain" to your domain
    $replyemail="mysecret@email.com";//change to your email address
    // ------------------------------------------------------------

    //clean input in case of header injection attempts!
    function clean_input_4email($value, $check_all_patterns = true)
    {
    $patterns[0] = '/content-type:/';
    $patterns[1] = '/to:/';
    $patterns[2] = '/cc:/';
    $patterns[3] = '/bcc:/';
    if ($check_all_patterns)
    {
    $patterns[4] = '/\r/';
    $patterns[5] = '/\n/';
    $patterns[6] = '/%0a/';
    $patterns[7] = '/%0d/';
    }
    //NOTE: can use str_ireplace as this is case insensitive but only available on PHP version 5.0.
    return preg_replace($patterns, "", strtolower($value));
    }

    $name = clean_input_4email($_POST["name"]);
    $email = clean_input_4email($_POST["email"]);
    $thesubject = clean_input_4email($_POST["thesubject"]);
    $themessage = clean_input_4email($_POST["themessage"], false);
    $address = clean_input_4email($_POST["address"]);
    $postcode = clean_input_4email($_POST["postcode"]);
    $country = clean_input_4email($_POST["country"]);
    $telephone = clean_input_4email($_POST["telephone"]);
    $mobile = clean_input_4email($_POST["mobile"]);
    $size = clean_input_4email($_POST["size"]);
    $size2 = clean_input_4email($_POST["size2"]);
    $people = clean_input_4email($_POST["people"]);



    $error_msg='ERROR - not sent. Try again.';


    $replymessage = "Hi $name

    Thank you for your quote request.

    We will endeavour to reply to you shortly.

    Please DO NOT reply to this email.

    Below is a copy of the message you submitted:
    --------------------------------------------------
    Subject: $thesubject
    Query:
    $themessage
    --------------------------------------------------

    Thank you";

    // email variable not set - load $valid_ref1 page
    if (!isset($_POST['email']))
    {
    echo "<script language=\"JavaScript\"><!--\n ";
    echo "top.location.href = \"$valid_ref1\"; \n// --></script>";
    exit;
    }

    $ref_page=$_SERVER["HTTP_REFERER"];
    $valid_referrer=0;
    if($ref_page==$valid_ref1) $valid_referrer=1;
    elseif($ref_page==$valid_ref2) $valid_referrer=1;
    if(!$valid_referrer)
    {
    echo "<script language=\"JavaScript\"><!--\n alert(\"$error_msg\");\n";
    echo "top.location.href = \"$valid_ref1\"; \n// --></script>";
    exit;
    }
    $themessage = "name: $name \nQuery: $themessage \naddress: $address \npostcode: $postcode \ncountry: $country \ntelephone: $telephone \nmobile: $mobile \nwidth: $size \nheight: $size2 \npeople: $people" ;
    mail("$replyemail",
    "$thesubject",
    "$themessage",
    "From: $email\nReply-To: $email");
    mail("$email",
    "Receipt: $thesubject",
    "$replymessage",
    "From: $replyemail\nReply-To: $replyemail");
    header("Location: http://www.corneli.nl/quote/thankyou.html");

    ?>

  9. #9
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Add this to the start of your script:
    PHP Code:
    error_reporting(E_ALL); 
    Saul

  10. #10
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I tried your script on your server, but I got an alert, 'subject must be filled', but you dont have a subject field ??
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  11. #11
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, sorry its a bit confusing, but the subject is 'the portrait style' in the form.

    i've added that error reporting code.. but it wont make a difference..

    sorry to be a pain guys.. just want to get this thing working i'm a complete php dummy..

  12. #12
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Not really sure why doesn't it work. But another option is outputting the file instead of redirecting. Try this instead of the header():
    PHP Code:
    readfile("thankyou.html"); 
    Saul

  13. #13
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by corneli View Post
    yeah, sorry its a bit confusing, but the subject is 'the portrait style' in the form.

    i've added that error reporting code.. but it wont make a difference..

    sorry to be a pain guys.. just want to get this thing working i'm a complete php dummy..
    OK, well Ive just tried again and get the same error, even though I choose a portrait style from the drop list.

    It does make a difference because its not allowing the form to submit, not sure how you are testing the PHP script if your error JS is not submiting the form ?
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  14. #14
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by php_daemon View Post
    Not really sure why doesn't it work. But another option is outputting the file instead of redirecting. Try this instead of the header():
    PHP Code:
    readfile("thankyou.html"); 
    thanks php_deamon, this fixed the problem. It now opens the thankyou file.

  15. #15
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mandes View Post
    OK, well Ive just tried again and get the same error, even though I choose a portrait style from the drop list.

    It does make a difference because its not allowing the form to submit, not sure how you are testing the PHP script if your error JS is not submiting the form ?
    hey Mandes, i really havent got a clue about ur error problem. I mean, ive written in the html file that all fields are required to be filled in, but in actual fact, its ony the email and comments field that are required to send the form.

    My first question is helped, the thankyou.htm file opens perfectly. But i was just wondering what i need to change in order to make all the fields required fields, accept for the comment field (that is a required file right , but i dont want it to

    if you could give me any tips that would be great.


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
  •