Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

question about $http_post_vars and $http_get-vars?

Status
Not open for further replies.

william6789

Technical User
Mar 14, 2003
21
0
0
CA
Hi,
I am a PHP beginner. If I want to pass parameter between HTMl to PHP, which function should I use? For instance, if I want to get a parameter value from PHP in HTML, which function should I use? If HTMl want to pass a parameter to PHP, which function shoud I use? If PHP want to retrive the parameter value passed by HTMl, how can I do it? vice versa, if PHP want to send a parameter to HTML, what should I use? all aboves are based on register_globals=off
I am a little confusing for usage of $http_get_vars and $http_post_vars? could someboby give me some comments or examples of using it?
By the way, which one is better for programing PHP and MySQl, shorter type(<?) or loger type(<?PHP>)?
Thanks in advance.

William
 
Hi,

GET and POST are methods - ways in which the information passed from an HTML form that a user fills out goes to a script.

GET is when you see URL's like this: (a query string)
You would use $_GET[&quot;variable&quot;] to access it and it would produce the value of 'value'

POST is when you don't see query string URL's from the form and when the information is passed silently.
You would use $_POST[&quot;variable&quot;] to access that. You use post typically when you use Credit Cards or when you insert information to a databse containing alot of information or fields or textarea fields which can contain alot of text.

<? and <?php are both the same. I believe that is preference. I always use <?php

Hope this helps!

Nate

mainframe.gif

 
Note that some servers will only recognise php code if it is in <?php ?> rather than <? ?>, like the one that hosts my site.
 
Thanks.
Accroding to SPYDERIX's explanation. Get and post are all mothods that pass parameter's from HTML to PHP. If HTML want to get pararmeters from PHP, which method should I use?
I test one file worte in short type , and it works weel. When I run it under longer style after changing <? to <PHP, parameter could not be passed, even though i use $_get to transfer data, especially from PHP to HTML.
BTW, Is $_get[&quot;variable&quot;] the same as $HTTP_GET_VARS? and the same as $_post[&quot;variable&quot;] and $HTTP_POST_VARS?

Thanks

william
 
Hi,

&quot;If HTML want to get pararmeters from PHP, which method should I use?
&quot;

Method? The is no method going from php to html so to speak. If you have a variable called $name and it equaled William $name = &quot;William&quot;; then to get that to show when outputted you would use:
echo $name;

Or say if you have the path to an image in a variable:
$path = &quot;/images/image.jpg&quot;;

And you wanted to put that into an html image tag you would do one of 2 things:
echo &quot;<img src=\&quot;&quot; . $path . &quot;\&quot;>&quot;;
which is simplified to:
echo &quot;<img src=\&quot;$path\&quot;>&quot;;

or you could do this:
<img src=&quot;<?php echo $path; ?>&quot;>

HTTP_GET_VARS is the same as $_GET[] and HTTP_POST_VARS is the same as $_POST[] One is the older method used in previous versions of php.

Hope this helps!

Nate

mainframe.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top