Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2005
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    header redirecting but included file is not working

    Hello, I have a script that is supposed to redirect to the same page but pass a get parameter to flag which partial is included on the page.

    The redirect is working and the section where the template is to be included is entered but it's still showing the previous template. It's almost like
    the include is getting ignored.

    Sample code:

    Code:
    $update = $db->create_update("prescriptions", $_POST, null, "id =". $_POST['prescription_id']);
    if($update){ header("Location: prescription.php?step=1"); exit; }
    
    include_once(BASE_PATH ."/templates/cpanel/prescription.tmpl.html");

    and here's the code in the prescription.tmpl.html template:
    Code:
    <body leftmargin="10" topmargin="10" marginwidth="10" marginheight="10">
    
    <?php if($step == 1){ echo "INCLUDING TEMPLATE 1 HERE"; include(BASE_PATH ."/templates/cpanel/prescription_1.tmpl.html"); } ?> 
    <?php if($step == 2){ include(BASE_PATH ."/templates/cpanel/prescription_2.tmpl.html");  } ?>
    
    </body>
    </html>
    After the redirect, prescription_2.tmpl.html is still showing even though the if section where prescription_1.tmpl.html is to be included is entered.

    Very strange - any ideas?

    Thanks,
    Clem C

  • #2
    Gütkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Well, is the second if section also entered?

  • #3
    New Coder
    Join Date
    Dec 2005
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    no -it's not entered at all. I definitely checked for that.

  • #4
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,066
    Thanks
    2
    Thanked 319 Times in 311 Posts
    GET parameters on the end of the URL are available as a $_GET variable. You must use $_GET['step']
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •