| | |||||
| ||||||||
| CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Account Suspended Join Date: Oct 2005 Location: United Kingdom
Posts: 1,554
![]() ![]() ![]() ![]() | [Tutorial] on $_POST & $_GET Hi Im going to explain $_POST & $_GET that iv learnt about on php.net, $_POST is used to get infomation from a form like say your form was like this: HTML Code: <form action='something.php' method='post' enctype="multipart/form-data"> <input name="name" type="text" size="45" /> </form> PHP Code: you use $_GET to get infomation that is in the address bar, this is how to use it. PHP Code: ????: NamePros.com http://www.namepros.com/showthread.php?t=251015 The script will get john as the name and put that in the sentence. Hope this helps took me a bit of time to figer it out on php.net but i got there and i though i would share it here. |
| |
| | #2 (permalink) |
| NamePros Member Join Date: May 2006
Posts: 160
![]() | GET can still be used to retrieve information from a form, it's just that that information is passed from the form to the server via the address / URL. Traditionally, GET was used as a way of getting information whereas POST was used to send information. That is to say, traditionally a GET request should not make changes on the server (whereas POSTs can). This is actually a good way to think, anyway. People that have browser accelerators that prefetch URLs will have lots of problems if GET type URLs are prefetched and if those URLs actually make a change on the server. Imagine prefetching 100s of URLs that are actually 'Delete this Entry' type URLs! |
| |
| | THREAD STARTER #3 (permalink) | ||||
| Account Suspended Join Date: Oct 2005 Location: United Kingdom
Posts: 1,554
![]() ![]() ![]() ![]() |
| ||||
| |
| | #4 (permalink) |
| Buy my domains. Join Date: Feb 2006
Posts: 2,792
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | PHP Code: |
| |
| | #5 (permalink) | ||||
| NamePros Regular Join Date: Aug 2005 Location: NY, USA
Posts: 608
![]() ![]() ![]() ![]() ![]() ![]() |
__________________ ask me about the internet | ||||
| |
| | #6 (permalink) |
| NamePros Member Join Date: May 2006
Posts: 160
![]() | Forget the INI settings. If you want variables to be parsed in strings, use double quoted strings. Double quoted strings parse variables while single quoted ones don't. Don't rely on changes to PHP.INI unless you have to... |
| |
| | THREAD STARTER #7 (permalink) |
| Account Suspended Join Date: Oct 2005 Location: United Kingdom
Posts: 1,554
![]() ![]() ![]() ![]() | yh i found that out as well iv been reading about php alot of php.net and w3school so i got the hang of most of it now. it would be like this: <?php $name = $_GET['name']; echo 'Thank you '.$name.' for soemthing bla bla'; ?> and that would print 'Thank you name for something bla bla. |
| |
| | #8 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,074
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | yes NetworkTown.Net that is another method to insert a variable into a string. That method is called concatenation. Some people prefer 1 method over the other I personally prefer concatenation over variables in double quotes as it is easier for me to see. |
| |