Jump to content

Archived

This topic is now archived and is closed to further replies.

sarabjit

forms and php

Recommended Posts

i'm at my wits end to solve this thing...

i have a simple form with only one field (userQuery) on one page which is being analyzed in the next...

here's the form:
[b]
<form action="search.php" method="get">
<tr><td colspan="2"><div align="center">
<input name="userQuery" type="text" id="userQuery" size="86">
</div></td></tr>
<tr><td width="225"><input type="submit" name="Submit" value="Search"></td>
</tr>
</form>[/b]

and here's the code in search.php which picks this query:
[b]
<?php
if (isset($userQuery)) {
...
}
else {
...
}
?>[/b]

the condition isset ($userQuery) however is always resulting in false, even though my address bar shows:
http://.../search.php?userQuery=test&Submit=Search

Any ideas??

Share this post


Link to post
Share on other sites
try:

[code]if (isset($_GET['userQuery'])) [/code]

Share this post


Link to post
Share on other sites
if your getting info from the URL it always helps :)

Share this post


Link to post
Share on other sites
[!--quoteo(post=358288:date=Mar 25 2006, 05:45 PM:name=sarabjit)--][div class=\'quotetop\']QUOTE(sarabjit @ Mar 25 2006, 05:45 PM) [snapback]358288[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Thanks!!
[/quote]

just to elaborate on what Hooker said, ALWAYS ALWAYS ALWAYS use $_GET if refering to a URL parameter. and ALWAYS ALWAYS ALWAYS use $_POST if refering to variables posted by a form.
i've been done over with this in the past, as not paying attention to where you want the variables to come from can lead to all sorts of problems.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.