iceblox Posted January 2, 2010 Share Posted January 2, 2010 Hi All, I have a compaison engine which allows the user to select options from a number of drop down elements, Ive used to use GET on the form but i am trying to change it to POST for a redesign. This all works ok but I am using pagination just a simple php one that pases the next page number through. But obviously this drops all the search criteria, So i had a look at encoding the query string as which works but i need to actually get the value of each variable so that i can show which ones have been selected to the user itms? Hopefully there is a way to do it without reverting back to GET? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/186937-passing-post-vairables/ Share on other sites More sharing options...
wildteen88 Posted January 2, 2010 Share Posted January 2, 2010 If you dont want to use GET, you could use use cookies or sessions to store the search criteria Quote Link to comment https://forums.phpfreaks.com/topic/186937-passing-post-vairables/#findComment-987152 Share on other sites More sharing options...
co.ador Posted January 2, 2010 Share Posted January 2, 2010 something similar I was encountering. One solution, not the best was to use two different variables with the same value. One to receive the passed parameter from the form and another use for the pagination. don't know if it is the best approach probably not but it works. Quote Link to comment https://forums.phpfreaks.com/topic/186937-passing-post-vairables/#findComment-987153 Share on other sites More sharing options...
conman20 Posted January 2, 2010 Share Posted January 2, 2010 Hi there,i really need help!i start to study php using wrox books, right now im on the user login part,i got a header problem which i cannot solve..Warning: Header may not contain more than a single header, new line detected. This is the login.php <?php session_start(); $_SESSION['logged'] = 0; if (isset($_POST['submit'])){ if ($_POST['username'] == "wroxbooks" && $_POST['password'] == "aregreat") { $_SESSION['logged'] = 1; header("Refresh: 5; URL=" .$_POST['redirect'] . ""); echo "You are being redirected to your original page requests!<br>"; echo "(If your browser doesn't support this, <a href=\"". $_POST['redirect']."\">click here</a>)"; }else{ ?> <html> <head> <title>Beginning PHP, Apache, MySQL Web Development</title> </head> <body> Invalid Username and/or Password<br><br> <form action="login.php" method="post"> <input type="hidden" name="redirect" value="<?php echo $_POST['redirect'];?>"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br><br> <input type="submit" name="submit" value="Login"> </form> <?php } } else { ?> <html> <head> <title>Beginning PHP, Apache, MySQL Web Development</title> </head> <body> You must be logged in to view this page<br><br> <form action="login.php" method="post"> <input type="hidden" name="redirect" value="<?php echo $_GET['redirect'];?>"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br><br> <input type="submit" name="submit" value="Login"> </form> <?php } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/186937-passing-post-vairables/#findComment-987155 Share on other sites More sharing options...
co.ador Posted January 2, 2010 Share Posted January 2, 2010 one of the disadvantages I found was, the second variable for the pagination will come with two notice and undefined if it is not provided in the form. The form I am using has several inputs and users can either choose not to enter an input if they one. If that happen then as I said this method will fail because there haven't been an definition for that input field and the variable is waiting for a value. Maybe cookies are better to use. Right now I was thinking if there is a way to force users to fill all the input fields and not allow users to get any information if all the input fields are not filled? Quote Link to comment https://forums.phpfreaks.com/topic/186937-passing-post-vairables/#findComment-987156 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.