Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/186937-passing-post-vairables/
Share on other sites

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.

 

 

 

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>

 

 

 

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.