Alright, so I'm messing around with some php on my site. I haven't been able to find anything on this on any online resources.
Say if a link is:
somethingstupid.com/crap.php?variable=value&anotherone=somethingelse
How do I use the variables in the code? Is it just like this?
Code:
<?php echo $value . $somethingelse; ?>
Or do I have to do something like you do with postdata?
Also, anybody know any good actual books that would be a good resource for php, java, and that kind of thing. I'm trying to learn it, and I'm sick of searching for reliable info online.
_________________ Aw man, I shot Marvin in the Face!
I don't know if this is what you are looking for or not, but eh.. worth a shot right? If you have a website, say whatever.com/index.php?user=bob use $HTTP_GET_VARS['user'] to "rip" bob out of the user variable.
Additional variables can be added by calling $HTTP_GET_VARS again with the other variable name. http://www.php.net is a great resource for finding code that is usually better than any book. If you really want to pay for a book, go ahead but between google and php.net you should be able to find just about anything you're looking for.
I'd just like to point out that in my last post I used the same name for the user in the URL and the $user string, I thought that might have been kind of confusing, so I just wanted to make it clear what I was trying to do with that. You use $HTTP_GET_VARS on the variable in the URL. So, in your example of somethingstupid.com/crap.php?variable=value&anotherone=somethingelse
you'd use.
Joined: Mon 04-15-2002 4:23PM Posts: 516 Location: Far, far away from Rolla (Colorado to be exact)
Source: Off Campus
hdncollision wrote:
Also, anybody know any good actual books that would be a good resource for php, java, and that kind of thing. I'm trying to learn it, and I'm sick of searching for reliable info online.
Core Java 1 & 2 (Sun Press) is great for Java in general. If you are wanting to do stuff with web services then Java Servlet Programming (O'Reilly) is pretty good too. The last is a little dated and just kind of briefly (read: not very helpful for 2.3 additions) goes over the Servlet 2.3 specification (the book won't tell you much about filters and stuff) but is still pretty good.
_________________ That's right. I'm gone. Rolla couldn't hold me. If you are still there, I know your pain. But I'm still going to laugh at you from far, far away.
In that url, the arguments would be "variable" and "anotherone". The values for these arguments (value and somethingelse) will be stored in the variables $value and $anotherone if register_globals is enabled in the php.ini file. I am pretty sure this option is disabled by default.
Otherwise the way you get at arguments is thusly:
If your request was sent using the GET method (ie the arguments were passed in the url as in your example), you would use $_GET['variable'] and $_GET['anotherone'] to access the values.
If your request was sent to the server via a form, and using the POST method, you would use $_POST['variable'] and $_POST['anotherone'].
And that's it.
As far as books, I would highly highly recommend the O'Reilly book "Programming PHP". Also, php.net has a really nice function library, complete with examples.
Let me know if you have any more php questions. I should put this knowledge to some sort of use.
Users browsing this forum: No registered users and 9 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum