synking Posted April 5, 2012 Share Posted April 5, 2012 Hey guys. Wondering if you people could give me some help on a procedural problem i am having. I want to display information from a database. What i am hoping to do is process all of the query and connection in the background. He is how i am doing this. there is a form that submits to the process page with post variables. and in that page there is a few switch statements that change the query and based on that change forwards them to a different page to display the result but the connection and variable name are not being forwarded so the table never gets processed. It is all done in an if statement and switch statemenst any ideas on how to do this properly. I think i am just confused on the procedure of it all. Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 5, 2012 Share Posted April 5, 2012 How are you "forwarding" from the processing page to the display page? You shouldn't be forwarding the user and in stead should have separate scripts to break up the functionality and INCLUDE the scripts. I'm guessing you are doing a header() redirect or something similar which wipes out any post data. Here is an example of one way: process_page.php //Do some validation to ensure you have the necessary info to actually do the processing if(!isset($_POST['foo']) { echo "Error: Unable to process your request"; } else { include('get_data_page.php'); if(!$result) { echo "Error: unable to get data<br>" . mysql_error(); } else { include('display_page'); } } get_data_page.php //Create/run query $fooVar = mysql_real_escape_string($_POST['foo']); $query = "SELECT * FROM table WHERE foo = '$fooVar'"; $result = mysql_query($query); display_page.php while($row = mysql_fetch_assoc($result) { //Create output } Quote Link to comment Share on other sites More sharing options...
synking Posted April 5, 2012 Author Share Posted April 5, 2012 Ok that makes more sense instead of sending it away to process include the process page in the page i want it to use to display. I was thinking backwards. Thanks for the tip. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.