|
-
Mar 9th, 2006, 07:32 AM
#1
Thread Starter
Addicted Member
Server Variables
Hey all
Need some help with some server variables....
My problem is i have a textbox on a html page called page1.html that when an sql query is placed in to the textbox that SQL query will display the relevent data on a PHP page called page2.php.
i have the page1.html pass the data using the GET method, on page2.php i want to grab the information passed over using the GET method using server variables... so far i have the following code
page2.php
Code:
<?php
$input = $_SERVER['QUERY_STRING'];
echo ("{$input}")
?>
This grabs the information that was entered in the textbox:
textarea=SELECT+*+FROM+tbl_Students+WHERE+DegreeID+%3D+1&Submit=Submit
what i want to do now is return the text to it's original form
SELECT * FROM tbl_Students WHERE DegreeID = 1
How would i do this?
thanks
Last edited by JamesBowtell; Mar 9th, 2006 at 08:28 AM.
-
Mar 9th, 2006, 10:13 AM
#2
Thread Starter
Addicted Member
Re: Server Variables
hey i have managed to get rid of the characters to return the string to it's original state using the following code:
Code:
<?php
$input = $_SERVER['QUERY_STRING'];
$input = str_replace('+', ' ', $input);
$input = str_replace('%3D', '=', $input);
$input = str_replace('textarea=', '', $input);
$input = str_replace('&Submit=Search', '', $input);
echo ("{$input}")
?>
nut i can imagine the code i'm using will not be the best solution to the problem can anyone suggest a better way of taking out the original variable?
-
Mar 9th, 2006, 10:37 AM
#3
Re: Server Variables
urldecode($_SERVER['QUERY_STRING']);
-
Mar 9th, 2006, 04:32 PM
#4
Thread Starter
Addicted Member
Re: Server Variables
cool that replaced the + and % but is there anothe method other than
$input = str_replace('textarea=', '', $input);
$input = str_replace('&Submit=Search', '', $input);
to remove the textarea= and &Submit=Search
-
Mar 9th, 2006, 06:36 PM
#5
Re: Server Variables
The variables passed by the Get request are in the $_GET superglobal array so you can just use:
urldecode($_GET['textarea'])
-
Mar 9th, 2006, 07:00 PM
#6
Thread Starter
Addicted Member
Re: Server Variables
this tutorial is ment to teach us how to use the server variables to grab the string and remove the characters automatically without using the POST or GET method
-
Mar 9th, 2006, 07:15 PM
#7
Re: Server Variables
Oh, well you didn't say that, I suggest a preg pattern would probably be simplest
urldecode(preg_replace('#textarea=(.*)&#i', '$1', $_SERVER['HTTP_REQUEST']));
Unless you can get away with $_REQUEST or $HTTP_REQUEST_VARS
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|