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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirect with POST variables in PHP

Status
Not open for further replies.

SFiend

Programmer
Jun 4, 2004
39
CZ
Hi, I have tried something like that, but with no response...

Code:
$Data = "Castka=$Castka";
$Size = strlen($Data);
header("POST /help/prijem.php HTTP/1.1", false);
header("Host: localhost", false);
header("Content-Type: application/x-[URL unfurl="true"]www-form-urlencoded",[/URL] false);
header("Content-Length: $Size", false);
header("Conection: close", false);
header("", false);
header("$Data");

I don't know how to do it. Any solutions?
 
You can't both redirect the user to another site and post POST-method data. You can do one or the other but not both.

In any regard, the headers you're trying to send look to me like you're trying to send data from PHP to another website. Using a PHP script, for example, to communicate with a web service. You might want to look at faq434-2502


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Yes, I want to send data to another site and redirect there.

I have site, where people insert a price, but I want to make sure that they use just numbers and no letters and the ammount of money has to be higher than 1.

Example:
'1' ok
'3' ok
'hyui1' wrong
';1' wrong
'0.34' wrong
 
You can't redirect.

You must use PHP as a proxy, which accepts user input, validates it, and if it validates the input sends it to the foreign server (see faq434-2502) and optionally returns the output from the foreign server to the user. Instead of sending the output of the foreign server to the user, your script might parse the foreign server's return and send appropriate messages to your user.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
So, just write a validation routine in the script itself, and have the processing if the validation succeeds.
Basic structure:
Code:
<?
# if POSTED validate
if ($_POST['price']){
   # validation code
   if (intval($_POST['price']) <= 0){
      $error_flag = true;
   }
   # display error
   if ($error_flag){
      # blah....
   } else {
     # do the process
   }
} else {
   # normal page view
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top