Solved

post variables in location

Posted on 2001-06-05
18
242 Views
Last Modified: 2008-03-17
Is there any way to use the POST-method instead
of the GET-method to overgive the variable id
(and maybe some more) to nextPage.php in the
following code:

<?
  header("location: nextPage.php?id=$id");
?>


Thanks for help.

Gamba
0
Comment
Question by:Gamba
  • 7
  • 6
  • 2
  • +3
18 Comments
 
LVL 1

Expert Comment

by:manucorp
ID: 6157364
no header("location ...")
use the 302 moved location of the HTTP protocol
but you cant try to use cookie if you want to hide the id

0
 

Author Comment

by:Gamba
ID: 6157872
could you give some code example?
i don't know how to implement this.

Thanks,

Gamba
0
 

Author Comment

by:Gamba
ID: 6157873
...I mean, for the moved location,
cause I don't want to use cookies.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 4

Expert Comment

by:ykf2000
ID: 6158209
Hi,

If you want to use a post method u'll need some javascript.
See below:


<?
  echo "<form action='nextPage.php' method='post' name='theForm'>";
  echo "<input type='hidden' name='id' value='$id'>";
  echo "</form>";
  echo "<script language='javascript'>";
  echo "document.theForm.submit();";
  echo "</script>";
?>
0
 
LVL 1

Expert Comment

by:fajr_n
ID: 6158491
If you don't want use cookies, how about the session. You can found in PHP.

this way still display the id value if the user click viewsource, although using session.

<form method="post" action="nextPage.php">
<input type="hidden" name="id" value="<!--id -->">
<input type="submit" name="submit" value="send">
</form>

better is the value of id variable save in session. Look like you need 2 process.

First,
- Activate the session
- Searching the id value
- Save the id value in session
- Redirect to nextPage.php

let's see source below:

<?
    // You can type the source to search id value here
    require("session.php");
    if(empty($id_user))
    {
      $id_user=$id; //the id value save in session
    }
    else
    {
      header ("Cache-Control: no-cache, must-revalidate");
      header ("Pragma: no-cache");
      header ("Location: nextPage.php");  
    }
?>

Session function in file session.php:
<?
    session_name("NEXTP");
    session_start();
    session_register("id_user");
?>

Below is nextPage.php file:
<?
    require("session.php");
    echo $id_user;
?>

I wish resolve your problem.
0
 
LVL 1

Expert Comment

by:fajr_n
ID: 6158500
Ups .. sorry my english and my words not good enough
0
 
LVL 8

Expert Comment

by:us111
ID: 6158713
another way
<?
    $id = 10;
    if ($submit)
    {   include("nextPage.php");
         exit();
    }
?>
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6203563
This question is still open today, perhaps it was just overlooked.  Please update it with comments if more information is needed to get your solution.  If you've been helped by the participating expert(s), you may just convert their comment to the accepted answer and then grade and close.  If an answer has ever been proposed you may not have this option to accept the comment as answer, if that is the case, ask the specific expert you wish to award to post an answer.  Finalizing questions benefits you and others who then search our PAQ, and rewards the experts who provided help.  A win/win scenario.  PLEASE DO NOT ACCEPT THIS AS THE ANSWER, IT IS MERELY A REMINDER.  If no response has been received by month-end, I will delete or accept an answer based on the information provided.  Expert input is welcome.

If you wish to award multiple participants, comment here as to which experts you'd like to award and what amounts.  If you'd like to delete this question,  comment here as to the reason, so that the participants may be advised and/or help further.  

Here is the Community Support link:   http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt where you may post zero point questions, include the link for special handling.

Click your Member Profile to see all your open questions, so that you can finalize them as well.  Your responsiveness is appreciated.  

Moondancer
Community Support Moderator @ Experts Exchange
 
0
 

Author Comment

by:Gamba
ID: 6203711
Oops, I did post a comment to the last question,
but it seems not to be submitted.
So, once again:

us111,

this seems to be very near to what I want.
I did check this, but my problem is now, that
whith your solution not only code from nextpage.php
is included, but also the code form currentpage.php.
This is no problem as such, but if I have a lot of
interaction, always including more and more code,
it gets a little bit complicated.
Do you have an idea to solve this?

I increased points a little, cause things seem to
get a bit more complicated.

Thanks for help,

Gamba

0
 
LVL 8

Expert Comment

by:us111
ID: 6205374
The other solution is to use session:

<?
if ($PHPSESSID)
 session_start($PHPSESSID);
else
 session_start();

 if ($submit <> "")
{ session_register("id");
  header("Location: nextpage.php")
}
?>

nextpage.php:
<?
if ($PHPSESSID)
 session_start($PHPSESSID);
else
 session_start();

print $id;
?>

or you can use the fsockopen function:
http://www.php.net/manual/en/ref.network.php
0
 

Author Comment

by:Gamba
ID: 6205392
I guess, the session_start-function in PHP
needs cookies, or not?
So if I would use cookies, I would not need
to post the id.

Is there no other way, e.g. manually
setting request method or anything else?

Gamba

0
 
LVL 8

Expert Comment

by:us111
ID: 6205400
session doesn't need cookies, it's server-side not client-side
0
 

Author Comment

by:Gamba
ID: 6205641
Are you sure?
Any time, I disable cookies in the browser,
it seems to me, that session-handling would fail.

How could the session-variable reach nextpage.php,
if there is no cookie and it is not included in
currentpage.php via get or post?

0
 
LVL 8

Expert Comment

by:us111
ID: 6205667
session_start creates a SID onto the server in /tmp or somewhere else.
the variable is stored into the SID file.

You can test, disable your cookie and you'll see it will work.

have a look at http://www.php.net/manual/en/ref.session.php, all is explained.
0
 

Author Comment

by:Gamba
ID: 6205706
Thank you, but they say:

To continue, <A HREF="nextpage.php?<?=SID?>">click here</A>
   
The <?=SID?> is not necessary, if
    --enable-trans-sid was used to compile PHP.

Does this mean, the session-function does automatically
append the SID as get-request-parameter to the URL,
so that I don't have to do append it myself?

The point for me is, that I don't want it to occur
in the browser-navigation-line (is this correct in english, i don't know). So the session would not
be too useful.

Anyway, you did a lot of work to comment all questions,
so the points are yours.
Maybe you could post another comment, if you could help
me to answer my concern about the php-session.
Otherwise i will also accept your last comment.

Thank you

Gamba
0
 
LVL 8

Accepted Solution

by:
us111 earned 150 total points
ID: 6205749
By default php is compiled with --enable-trans-sid.
It means that you don't have to specify the SID.

I believe that the better way to understand session is to play with it.
Try the simple script above.

Btw, you need to specify
if ($PHPSESSID)
  session_start($PHPSESSID);
else
  session_start();
if you want to access the variables stored into the session

Try & test. And then if you have further questions don't hesitate to ask
0
 

Author Comment

by:Gamba
ID: 6205760
I will do so.

Thank you,

Gamba
0
 
LVL 8

Expert Comment

by:us111
ID: 6205766
you're welcome
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Moving from Mcrypt to OpenSSL 18 48
php help 34 58
jQuery force form POST 7 53
show child records separated by commas 12 12
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question