Welcome to TalkGraphics.com
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: PHP Script Help

  1. #1
    Join Date
    Feb 2001
    Location
    Surrey, BC, Canada
    Posts
    2,379

    Default PHP Script Help

    Hi,
    I am trying to incorporate this PHP script from the forum.
    I want to change the last line in red where is says "Echo "Thank you..." to go to a thank you page, but I don't have the PHP programming skills any one help me?
    <?PHP
    $to = "
    youremail@wherever.com";
    $subject = "
    Contact Form response";
    $headers = "From:
    Form Mailer";
    $forward = 0;
    $location = "";
    $date = date ("l, F jS, Y");
    $time = date ("h:i A");
     
     
    $msg = "
    Below is a message from your contact form submitted on $date at $time.\n\n";
    if ($_SERVER['REQUEST_METHOD'] == "POST") {
    foreach ($_POST as $key => $value) {
    $msg .= ucfirst ($key) ." : ". $value . "\n";
    }
    }
    else {
    foreach ($_GET as $key => $value) {
    $msg .= ucfirst ($key) ." : ". $value . "\n";
    }
    }
    mail($to, $subject, $msg, $headers);
    if ($forward == 1) {
    header ("Location:$location");
    }
    else {
    echo "
    Thank you for contacting us. We will get back to you as soon as possible.";
    }
    ?>
    Jim

  2. #2
    Join Date
    Nov 2000
    Location
    Red Boiling Springs TN USA
    Posts
    19,208

    Default Re: PHP Script Help

    Hi Jim,

    I'm not an expert on PHP.

    The code is setup to provide redirection to a page if you need it.

    If you change $forward = 0; to read as $forward = 1; and change $location = ""; to $location = "http://myredirect";

    In place of "myredirect" put in the full URL to the page you want the viewer to go to.
    Soquili
    a.k.a. Bill Taylor
    Bill is no longer with us. He died on 10 Dec 2012. We remember him always.
    My TG Album
    Last XaReg update

  3. #3
    Join Date
    Nov 2000
    Location
    Red Boiling Springs TN USA
    Posts
    19,208

    Default Re: PHP Script Help

    See the attached image for a brief explanation of the code.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	code-snippet.gif 
Views:	124 
Size:	15.0 KB 
ID:	64760  
    Soquili
    a.k.a. Bill Taylor
    Bill is no longer with us. He died on 10 Dec 2012. We remember him always.
    My TG Album
    Last XaReg update

  4. #4
    Join Date
    Feb 2001
    Location
    Surrey, BC, Canada
    Posts
    2,379

    Default Re: PHP Script Help

    Hi,
    thanks I tried a goto but didn't work..
    Jim

  5. #5
    Join Date
    Nov 2000
    Location
    Red Boiling Springs TN USA
    Posts
    19,208

    Default Re: PHP Script Help

    You are welcome.
    Soquili
    a.k.a. Bill Taylor
    Bill is no longer with us. He died on 10 Dec 2012. We remember him always.
    My TG Album
    Last XaReg update

  6. #6
    Join Date
    Feb 2001
    Location
    Surrey, BC, Canada
    Posts
    2,379

    Default Re: PHP Script Help

    hi,
    the Modifications you suggested aren't working! I tired various references to $location="thankyou.htm" ?
    thanks any way for your attempt (maybe my implementation)
    Jim

  7. #7
    Join Date
    Nov 2000
    Location
    Red Boiling Springs TN USA
    Posts
    19,208

    Default Re: PHP Script Help

    Jim, I think you must provide the entire URL including the http:// etc.
    Soquili
    a.k.a. Bill Taylor
    Bill is no longer with us. He died on 10 Dec 2012. We remember him always.
    My TG Album
    Last XaReg update

  8. #8
    Join Date
    Feb 2001
    Location
    Surrey, BC, Canada
    Posts
    2,379

    Default Re: PHP Script Help

    hi,
    I have tried the full path..just get a blank page.
    It is Sledgers web script... maybe I should contact him directly...
    Thanks for help tho..
    Jim

  9. #9

    Default Re: PHP Script Help

    Scotty I doubt it will work the way you have changed it, I corrected your URL error in the PM you sent me but I hadn't realized it was the script I'd used for the contactform.web file I posted in June.

    You have used a script that is not mine but a free one I found on the web which worked for the purpose.
    I'm no php programer either, so the alterations you have made might just have broken the script

    The script should be left as:

    <?PHP
    $to = "youremail@wherever.com";
    $subject = "Contact Form response";
    $headers = "From: Form Mailer";
    $forward = 0;
    $location = "";

    $date = date ("l, F jS, Y");
    $time = date ("h:i A");



    $msg = "Below is a message from your contact form submitted on $date at $time.\n\n";

    if ($_SERVER['REQUEST_METHOD'] == "POST") {
    foreach ($_POST as $key => $value) {
    $msg .= ucfirst ($key) ." : ". $value . "\n";
    }
    }
    else {
    foreach ($_GET as $key => $value) {
    $msg .= ucfirst ($key) ." : ". $value . "\n";
    }
    }

    mail($to, $subject, $msg, $headers);
    if ($forward == 1) {
    header ("Location:$location");
    }
    else {
    echo "Thank you for contacting us. We will get back to you as soon as possible.";
    }

    ?>


    Actually, it was John (neodiest) who found the original script (sorry John )
    Last edited by steve.ledger; 13 August 2009 at 10:45 PM.

  10. #10
    Join Date
    Feb 2001
    Location
    Surrey, BC, Canada
    Posts
    2,379

    Default Re: PHP Script Help

    Hi,
    I got your PM and got the original script again and the change was so simple I feel dumb.
    If you modify the areas where I got as red it works to my thankyou page.
    <?PHP
    $to = "youremail@wherever.com";
    $subject = "Contact Form response";
    $headers = "From: Form Mailer";
    $forward = 1;<Jims mod
    $location = "thankyou.htm"; Jims mod

    $date = date ("l, F jS, Y");
    $time = date ("h:i A");

    $msg = "Below is a message from your contact form submitted on $date at $time.\n\n";
    if ($_SERVER['REQUEST_METHOD'] == "POST") {
    foreach ($_POST as $key => $value) {
    $msg .= ucfirst ($key) ." : ". $value . "\n";
    }
    }
    else {
    foreach ($_GET as $key => $value) {
    $msg .= ucfirst ($key) ." : ". $value . "\n";
    }
    }
    mail($to, $subject, $msg, $headers);
    if ($forward == 1) {
    header ("Location:$location");
    }
    else {
    echo "Thank you for contacting us. We will get back to you as soon as possible.";
    }
    ?>

 

 

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
  •