Jump to content

GET variable coming up empty when inserting integers


jumpenjuhosaphat

Recommended Posts

Your not using the GET method, get is used in links you are using POST, switch the method to post and try again with your script reading $_POST variables.

Read,

http://www.phpfreaks.com/phpmanual/page/language.variables.predefined.html
Link to comment
Share on other sites

In addition,

[code=php:0]
<form name="myform" method="post" action="index.php">
<input name="distance" type="text" />
<input name="apply" type="submit" value="Search" />
</form>
[/code]

Its a bad idea to use submit as the name of a submit button.
Link to comment
Share on other sites

No, I'm using the get method.  It needs to be the get method so that the pages can be bookmarked.  If I use the post method, it'll hide the underlying variables and the page won't be markable.

I discovered where I had gone wrong.....In the if statement, I made a big duh...:)

I didn't use the double =, if(this==that), instead I used if(this=that), and by doing that, I set the value of the $distance variable to a 0.  Thank you all for your help.
Link to comment
Share on other sites

[quote author=jumpenjuhosaphat link=topic=123969.msg513084#msg513084 date=1169722081]
No, I'm using the get method.  It needs to be the get method so that the pages can be bookmarked.  If I use the post method, it'll hide the underlying variables and the page won't be markable.[/quote]

I'm a little lost by this but if you say so. Naming a control submit causes some problems when using client side script.
Link to comment
Share on other sites

[quote author=Cep link=topic=123969.msg513089#msg513089 date=1169722662]
[quote author=jumpenjuhosaphat link=topic=123969.msg513084#msg513084 date=1169722081]
No, I'm using the get method.  It needs to be the get method so that the pages can be bookmarked.  If I use the post method, it'll hide the underlying variables and the page won't be markable.[/quote]

I'm a little lost by this but if you say so. Naming a control submit causes some problems when using client side script.
[/quote]

Well, the difference between get and post is how the variables are passed to the script.  In the get method, the variables are passed via the URL, in the post method, the variables are passed via the HTTP header.  You can't pass variables via the post method using a link, and you can't bookmark, or save the variables using the post method.  Posted variables are convenient when you don't want the values to be visible, typically for security reasons.  But in my case I need the values to be part of the URL, because the site is a database driven site, and each page is a derivative of the index.php page.  In other words, page 2 would be index.php?action=go&page=2

Does that make sense?  Thanks for the tip on the submit name, I never knew that.
Link to comment
Share on other sites

[quote author=Cep link=topic=123969.msg513089#msg513089 date=1169722662]
[quote author=jumpenjuhosaphat link=topic=123969.msg513084#msg513084 date=1169722081]
No, I'm using the get method.  It needs to be the get method so that the pages can be bookmarked.  If I use the post method, it'll hide the underlying variables and the page won't be markable.[/quote]

I'm a little lost by this but if you say so.
[/quote]

Cep,

Your understanding of HTML forms is slightly off the mark.  When you submit a form, you can use either the POST or the GET method.  The OP clearly has GET in his/her form method and so the parameters will be passed in the URL.

Regards
Huggie
Link to comment
Share on other sites

hmm.. 2 pages and no one has seen the error:

This: [code=php:0]if ($distance=''[/code]

should read: [code=php:0]if ($distance==''[/code]

You also don't need to use the $distance=$_GET['distance']; assignment, you can just use $_GET['distance'] directly, and you should also check it exists first.
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.