PDA

View Full Version : Passing values both by POST and query string. Not possible?


WA
12-04-2002, 01:51 AM
I'm curious, is it not possible to submit a form using "method=post" while passing a query string to the URL at the same time? For example, lets say I have the following form:


<form action="<?=$PHP_SELF . "?apples=1?>" method="post">
<textarea name="mytextarea">Some data here</textarea>
<form>

If I submit the form, while I can retrieve $apples (1), attempting to retrieve $mytextarea returns variable not found. Is it not possible to add a query string to the form's action while using post at the same time?

Thanks,

Dylan Leblanc
12-04-2002, 02:36 AM
I think POST vars override GET vars.

WA
12-04-2002, 03:04 AM
Nevermind, it actually does work. I just forgot to declare the variable referencing the query string as global inside a function. Ah bad habits from JavaScripting are hard to kick :)

firepages
12-04-2002, 03:10 AM
You can + If you have PHP > 4.2 you can use the superglobals and even do this if you want to confuse yourself :)



<?
echo $_GET['apples'].'<br />'.$_POST['apples'];
?>

<form action="<?=$_SERVER['PHP_SELF'] . "?apples=orange";?>" method="post">
<textarea name="apples">Some data here</textarea>
<form>

<input type="submit" name="submit" value="submit" style="width:200" width="200">

firepages
12-04-2002, 03:13 AM
sorry George , didnt see you there :)

remember that $_GET, $_POST etc are already global so if you use


<?
function yaks(){
return $_POST['var'];
}
?>


then that works without the global declaration.