I should be perfect if I use POST VAR and not GET VAR 🙂
I will try to explain what my probleme is (i'm french so do be afraid by my langage 🙂
i do script which build HTML form automaticaly. this script use a .dat file to configure the HTML form.
my script must be able to give selected var whose have be given to him (understand ?)
the selected var is in the .dat.
If val is give in the .dat, my script give this value to the next page
else the script get the previous value of the var and give it to the next page
it's not very easy to understand (and it's harder when I explain it 🙂
example:
<B>in my .dat</B>
[parameter]
//list of parameters whose must be reward
id
var4test=val4test
<B>in the HTML page:</B>(it receive as argument id=4)
<A href="nextpage.hml?id=4&var4test=val4test&other_var=foo">link</A>
<B>solution:</B>
1- get the value
why don't try to get directly $id, because if i use another id var in my script, i will loose the origin value of $id
after hard thinking, i found that regular expression it's the best way to do.I use that:
<B>in my script:</B>
<?
$VAR="id";
echo "<U>QUERY_STRING=</U> $QUERY_STRING<BR>\n";
echo "<U>var=</U> $VAR<BR>\n";
//$express = "(.)(".$VAR.")(=)(.)+(&|$)(.)";
$express = "(.".$VAR."=?)(.)(((&.)|($))?)";
echo "<U>expression=</U> $express<BR>\n";
if(eregi( $express, $QUERY_STRING, $VAL) )
{
$VAL = $VAL[2];
echo "<U>Val found=</U> $VAL<BR>\n";
}
else
{echo "val not found !<BR>\n";}
?>
<B>but it return:</B>
QUERY_STRING= id=1&var=val&action=voir&
var= id
expression= (.id=?)(.)(((&.*)|($))?)
Val found= 4&var4test=val4test&other_var=foo
I cannot found the correct regular expression to return only the value of the var
if you have question, ask it 🙂
thanx very much