Results 1 to 3 of 3

Thread: can I have two php scripts on one page<

  1. #1
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default can I have two php scripts on one page<

    I put these two scripts on one page.
    submit.php
    Code:
    <?php 
    session_start(); 
    if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='')  { 
         echo  '<strong>Incorrect verification code.</strong><br>'; 
    } else { 
         // add form data processing code here 
         echo  '<strong>Verification successful.</strong><br>'; 
    }; 
    ?>

    mail.php
    Code:
    <?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $design = $_POST['design'];
    $change = $_POST['change'];
    $how = $_POST['how'];
    $message = $_POST['message'];
    $formcontent=" From: $name \n Email: $email \n How do we look: $design \n What would you Change:     $change \n How did you get here: $how \n Message: $message";
    $recipient = "youremailaddresshere";
    $subject = "Contact Form";
    $mailheader = "From: $email \r\n";
    mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
    echo "Thank You! We appreciate you took time to fill out our feedback form." . " -" . "<a href='form.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
    ?>
    It works but gives a warning message along with the thank you note.

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/webuseri/public_html/css/5/mail2.php:13) in /home/webuseri/public_html/css/5/mail2.php on line 15

    Code:
    <?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $design = $_POST['design'];
    $change = $_POST['change'];
    $how = $_POST['how'];
    $message = $_POST['message'];
    $formcontent=" From: $name \n Email: $email \n How do we look: $design \n What would you Change:     $change \n How did you get here: $how \n Message: $message";
    $recipient = "aflorkoski6821@tvcconnect.net";
    $subject = "Contact Form";
    $mailheader = "From: $email \r\n";
    mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
    echo "Thank You! We appreciate you took time to fill out our feedback form." . " -" . "<a href='form.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
    
    session_start(); 
    if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='')  { 
         echo  '<strong>Incorrect verification code.</strong><br>'; 
    } else { 
         // add form data processing code here 
         echo  '<strong>Verification successful.</strong><br>'; 
    }; 
    ?>
    Can this warning be eliminated or do I have to find a way to use two "action="" in the form or something??

    Bud

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Yes and how you do that depends upon what you want to have happen when verification fails.

    Do you still want the email to be sent? The way you have the code now implies that the answer is yes, but logic could dictate otherwise.

    If you do though, just do what the error message implies. Move the session_start() to the beginning.

    If not, I'd probably go with something like:

    PHP Code:
    <?php
    session_start
    (); 
    if (
    $_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='')  { 
         echo  
    '<strong>Incorrect verification code.</strong><br>Mail not sent.'
         die();
    }

    $name $_POST['name'];
    $email $_POST['email'];
    $design $_POST['design'];
    $change $_POST['change'];
    $how $_POST['how'];
    $message $_POST['message'];
    $formcontent=" From: $name \n Email: $email \n How do we look: $design \n What would you Change:     $change \n How did you get here: $how \n Message: $message";
    $recipient "aflorkoski6821@tvcconnect.net";
    $subject "Contact Form";
    $mailheader "From: $email \r\n";
    mail($recipient$subject$formcontent$mailheader) or die("Error Sending Mail!");
    echo 
    "Thank You! We appreciate you took time to fill out our feedback form." " -" "<a href='form.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
    ?>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    ajfmrf (09-03-2011)

  4. #3
    Join Date
    Jan 2011
    Location
    Southeastern CT
    Posts
    612
    Thanks
    46
    Thanked 32 Times in 32 Posts

    Default great addition John

    Thanks for the adjusted script to not send the email if an error is found.

    I have added more and hope to get things polished up this week end.

    Again John comes through.


    Bud

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
  •