Jump to content

forms and php


sarabjit

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??
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.