Jump to content

JakeJ

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

JakeJ's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I avoid that problem by splitting the processing of page from the display.
  2. Rather than using the MySQL connection string in a session variable, I put my connection string in its own file and then use that file as include wherever I need it. And if I need to change the connection string, I only need to do it in one place. Is there a particular reason you're putting it in a session variable? The only reason I can think of to put it in a session variable is if it's going to change quite a bit. In any case, do you have session_start() in the other page? If not, it won't inherit the $_SESSION[] array. If those things don't solve the problem, post some code.
  3. Here's my code: What happens is, when index.php loads and $_SESSION['submit'] is not set, it loads test.php. That works great. When I click the button on the form, the code in test.php checks to see if submit is set and sets $_SESSION['submit'] and sets that to 'test2.php'. But then when the form reloads, I have to click submit AGAIN in order for it to actually go to test2.php. I don't know why. Since $_SESSION['submit'] has been set, why doesn't my logic at the top of index.php read it and set $body_include to the right form and load it appropriately? <?php session_start(); $header_include = './includes/mainstyle.php'; if(isset($_SESSION['submit'])) { $body_include = $_SESSION['submit']; } Else { $body_include = "test.php"; } include ($header_include); ?> </head> <body class="twoColFixLtHdr"> <FORM NAME = "MAINFORM" ACTION=<?php echo $_SERVER['PHP_SELF']; ?> METHOD=POST runat="vdaemon"> <!-- begin #header --> <?php include_once("/includes/incl_header2.php"); ?> <!-- end #header --> <!-- begin #sidebar --> <div id="sidebar1"> <?php include ("/includes/incl_sidebar.php"); ?> </div> <!-- end #sidebar --> <!-- end #sidebar1 --> <!-- begin #main content --> <div id="mainContent"> <?php echo $body_include; include($body_include); #$process =1; ?> </div> <!-- end #mainContent --> <!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --> <br class="clearfloat" /> <div id="footer"> <p> </p> <!-- end #footer --></div> <!-- end #container --></div> </FORM> </body> </html> //test.php <?php Echo "Please log in<br> Username: <input type='text' name='username' value='' /><br /> Password: <input type='password' name='password' value='' /><br /><br /> Log In <INPUT ID='submit' NAME='submit' TYPE=IMAGE BORDER=0 SRC='../images/wiz_edit.png' VALUE='login'><p>"; If (isset($_POST['submit'])) { $_SESSION['submit'] = 'test2.php'; } ?>
  4. This problem is absolutely KILLING ME. I have index.php and it's a form with action=<?php echo $_SERVER['PHP_SELF']; ?> I want to do everything inside of index.php using includes. I have some code that determines that name of the include that goes in the body of the page. This works fine when I first load the page since it's either looking for the results of a variable or goes to a static page name. The include that goes in the body of the page, contains the inputs for the form. When I submit the form, I want it to do some processing and error checking and either return the errors (which works just fine) or redirect back to index.php but with a different include in the body. The example that I've got forces me to submit twice in order for the redirect to happen if I do any conditional checking and assign the next page based on that. I thought about posting my sample code that isn't working but I'm so turned around in my head now, I don't know which way is up. Starting with a fresh example from someone else is bound to give me some perspective on the matter. So how would you do this? Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.