Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use Post Method in php program 1

Status
Not open for further replies.

owenewo

ISP
Oct 3, 2004
3
US
If I use header command in the php program, I can transfer data to another site by Get method as following.

<?
header("Location:?>

But, how can I use post method to do same thing? since if it's a secured site, I don't want people to see the parameters.

Could someone please help?
 
Do it via a form with a POST method.

===================================
Never underestimate the power of stupid people in big numbers
===================================
 
Hello,

When data is submitted via a post it is stored like this:

Code:
[green]//Access the variable like this
//The 'varname' is the name of the form field
[/green]
[blue]$myVar = $_POST['varname'][/blue]

If you want to pass things without forms use Sessions
Code:
[green]//Create a secure variable using the unique session_id() from the user's browser.
You can keep accessing these vars as long as you call session_start() on each of the pages that use the session_vars
[/green]
[blue]
session_start();
$myVar = "MyName".session_id();
session_register($myVar);
$_SESSION[$myVar]="Test";
[/blue]

Hope that helps,
Ron

cout << "If you don't know where you want to go, we'll make sure you get taken";
 
here is the question,
How to use Post form without the click from user? since it's in a program, and can not get click from user.
 
This cannot be performed server-side. If you want to do it, use javascript.
Code:
<html>
<body [red]onload="document.forms[0].submit();"[/red]>
<form action="page2.php" name="f" id="f" method="post">
<input type="text" name="values_to_be_passed" value="....">
</form>
</body>
</html>

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
Client side can be seen by the client (visitor), so post is not the way to go, I think.

As far as I know, the client can not view the source of your header()..

I tried on my own script and it only returned:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top