0

Hi,
Please help me out.

1. Getting HYPERLINK value from page1 and saving in page2 using GET method.($re=$_GET[variable];)

2. Passing this value in -> select query

3. Displaying my output - correctly(in each and every value, there is an SUBMIT button.)

4. My Form Action is page2 itself.

5. Due to this, by submitting the form, my GET method value becomes NULL.

6.Displaying my output - incorrectly(selecting all NULL field values in WHERE CLAUSE)


Please help me out.Thanks in advance

2
Contributors
15
Replies
16
Views
6 Years
Discussion Span
Last Post by C#Jaap
0

Maybe you can specify your question with code samples. The first thing I think of is: does you form action contain Get-parameters? Or does it perform a Post? In that case use should question your form with $__POST[variable]. With $__REQUEST[variable] you can look for both Post an Get variables.

0

Hi,
In Page1

print "<a href=http://page1.php?code=pcode>click</a>";

In Page2

<?php
            ((isset(submit)) && (isset(submit)=="Upload file"))
            {
                 // code here 
            }
      $result=$_GET['code'];
      $qur="select name,lastname from table where id='$result'";
       ----code------
       html table tag opened
       while loop
       {
           displaying the output in browser -->first time correctly
           ------code goes here-------

            echo "<form action='page2.php' method='post' enctype='multipart/form-data'>";
  echo "<input type='hidden' name='id' value='$pid'>";
  echo "<input type='hidden' name='pe' value='$pp'>";
  echo "<input type='hidden' name='result' value='$result'>";
  echo "<td><input type='file' name='uploaded_file'></td>";
  echo "<td><input type='submit' name='Submit' value='Upload file'></td>";
  echo "</form>";
  echo "</tr>";
       }
       ---------------

     
      ?>

1.first time - displaying the output in the browser correctly from select query(getting the value from gets method -from select query WHERE $id='value').
2.Now - i am clicking submit button
3.displaying the output in the browser incorrectly from select query(NOW get method value become ZERO -displaying all values -from select query WHERE $id='').

Please help me out. Thanks in advance

0

Hi,

Inside SUBMIT button, am not facing any problem. Outside SELECT Query --its giving problem. How to sort out this.GET METHOD values -> why becoming empty string.

0

You are posting some variables with your second form but tries to read them with $_GET. You should use $_REQUEST[variable] to read both GET-params and POST-params.

0

hi,

where i should use this $_REQUEST[variable] ? please point out in my above coding.

0

Use

$result=$_REQUEST['code'];

and add line

echo "<input type='hidden' name='code' value='pcode'>";

to your form

Edited by C#Jaap: n/a

0
$result=$_REQUEST['code'];
echo "<input type='hidden' name='code' value='pcode'>";

You told to do as the above one,

$result=$_REQUEST['code'];
echo "<input type='hidden' name='code' value='$result'>";

value is $result
or
value is $pcode

Value can be of anything.

0

OK, I didn't see that, I only saw 'pcode'. Is your problem solved? (sorry I was a little early)

Edited by C#Jaap: n/a

0

yes, my problem is solved. Nearly, i spent half a day in this. From you, i learned about $_REQUEST method. thanks once again

0

Hi,

again i am facing the same problem, while redirecting the page

   if(condition)
   {
      header("Location:page2.php");
      exit("error");
   }

The $_REQUEST['variable'] -> getting null. How to fix this error.

Edited by Dani: Formatting fixed

0

:-)

if( condition )
{
    header("Location:page2.php?code=$pcode");
    exit("error");
}

Edited by C#Jaap: n/a

0

i tries the same thing.its working.One more doubt, my exit() function showing error message in new browser window. So only, i am using header(), but this function redirect to PAGE2.PHP(home page) without showing any error message. If any error message means, i wants to stop execution of the script using exit("error message"). but "error message" should display in the same browser window

0

I don't understand you completely. Do you want the execution to stop if an error message contains any text? Or do you want sonething else? Your script is writing a header - that makes the browser to redirect in this case - and after that your PHP-script-executions is ordered to stop (by calling exit) while writing a message. Both the header and the messages are sent to the visiting client, that is first redirect and after is writing the message.
If you only wants to display the errormessage you should redirect. If you only wants to redirect don't write any message.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.