Log in

View Full Version : Resolved Reading the URL and parsing it.



Rohan72
02-22-2010, 12:05 AM
Another question, related to my previous post...

When sending a variable with a form I use

<form action="index.php" method="get">
and with the variables I am using it would lead me to a page such as http:/ /www.test.com/index.php?lang=english

now I would like to read the that URL with some script but without the variable (?lang=english) and parse that into the action attribute of that form.

How can I do that?

Nile
02-22-2010, 12:47 AM
Use:


method="post"

Then when you read the variable you normally would do $_GET['lang'] but now you would do $_POST['lang']

Rohan72
02-22-2010, 12:58 AM
Nile, I think you misunderstood my question.
I would like to read the URL from the page I am currently on and then parse that into the form.
Something like this:

URL = http:/ /www.test.com/index.php?lang=english


<?php
script to read the URL - ?lang=english
?>

<form action="the url just retrieved by the phpscript" method="get"

Nile
02-22-2010, 01:01 AM
Then use $_GET['lang']... Or am I still misunderstanding you?

Rohan72
02-22-2010, 01:11 AM
I am afraid you do...

I'll take this page as an example.

If I had the form on this page, I would like a phpscript to read the URL and delete the "?t=52583" part from it so that the form tag would something like

<form action="<?php echo $UrlFromAbove ?>" method="get">
so when viewing the source code in IE, you would see it like

<form action="http://www.dynamicdrive.com/forums/showthread.php" method="get">

This is because the form is not on the page itself, but in a footer, that I include in every page.

Nile
02-22-2010, 01:14 AM
Use _SERVER["PHP_SELF"]

Rohan72
02-22-2010, 01:21 AM
Thanks a lot!

problem solved :)

Nile
02-22-2010, 01:22 AM
Glad to help. :)