Connecting Tech Pros Worldwide Forums | Help | Site Map

How to print out $_REQUEST varilables from a server

Newbie
 
Join Date: Jun 2008
Posts: 1
#1: Jun 23 '08
I am having problem retrieving $_REQUEST array key/value i submintted using post method. here is the simple form I am posting:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5.  
  6. <form action="http://192.168.130.51:8080/merchantAPI/postPairs" method="post">
  7.      Request Type:  <input type="text" name="reqType" value="CCSale"/><br />
  8.      Merchant ID:   <input type="text" name="merchantID" value="12"/><br />
  9.      Merchant Key:  <input type="text" name="merchantKey" value="key"/><br />
  10.      Refrence Num:  <input type="text" name="referenceNum" value="1"/><br />
  11.      Total Amount:  <input type="text" name="chargeTotal" value="1"/><br />
  12.      Credit Card#:  <input type="text" name="creditCardNumber" value="373235387881007"/><br />
  13.      Exp Month:     <input type="text" name="creditCardExpMonth" value="12"/><br />
  14.      Exp Year:      <input type="text" name="creditCardExpYear" value="2008"/><br />
  15.      <input type="submit" name="submit" value="Submit" >
  16. </form>
  17. </body> 
  18. </html>
  19.  
After submitting the form I want to view/print the response from the server using a simple code such as:
Expand|Select|Wrap|Line Numbers
  1. foreach($_REQUEST as $key=>$value)
  2. echo("<tr><td>$key</td><td>$value</td></tr>");
  3.  
how can i do this. can anyone please help



Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,747
#2: Jun 23 '08

re: How to print out $_REQUEST varilables from a server


Hi. Welcome to Bytes!

The code you posted should work fine.
You just have to create a PHP file, containing the PHP code you posted, and have the action parameter of the <form> element point to that PHP file.
Newbie
 
Join Date: Jun 2008
Posts: 25
#3: Jun 24 '08

re: How to print out $_REQUEST varilables from a server


You mean you want to debug the variables from your PHP script?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. print '<pre>';
  3. print_r($_REQUEST);
  4. print '</pre>';
  5. ?>
  6.  
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,747
#4: Jun 25 '08

re: How to print out $_REQUEST varilables from a server


I like the compact version :)
Expand|Select|Wrap|Line Numbers
  1. echo "<pre>", print_r($_REQUEST, true), "</pre>";
  2.  
Reply