www.webdeveloper.com
Results 1 to 8 of 8

Thread: Pass values from html to php : third method

  1. #1
    Join Date
    Apr 2005
    Posts
    210

    Talking Pass values from html to php : third method

    I know 2 methods for passing html (javascript) values to php:

    1. by link parameters, such as my.php?route=red.
    2. by form.


    I am wondering if there is third method to pass values from html to php?

    If yes, what is that?

    Thanks.

    .

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,608
    Ajax?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    May 2004
    Location
    chennai, tamil nadu, India
    Posts
    451
    $_SERVER['PATH_INFO'] maybe

  4. #4
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    Those two methods are it, corresponding to the two request methods, get and post. IIRC path_info is created by the server based on parsing the request URL but in the past it's been pretty flaky on some servers.
    Last edited by ray326; 06-16-2012 at 04:54 PM.

  5. #5
    Join Date
    May 2012
    Posts
    42
    There's always cookies, but that's not a good way to pass info dynamically. Cookies are more for persistent data.

  6. #6
    Join Date
    Dec 2011
    Posts
    87
    You can also use $_SESSIONS to store variables and pass them to another page.

  7. #7
    Join Date
    Jun 2012
    Location
    lahore
    Posts
    11
    <?php if(!isset($_GET['color']) || $_GET['color'] == 'green') {
    $imgfolder = "green";
    ?>
    <link type="text/css" rel="stylesheet" href="css/green_style.css"/>
    <?php } else if($_GET['color'] == 'blue') {
    $imgfolder = "blue";
    ?>

    in images you make one folder which name green.

  8. #8
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,270
    You can too load a javascript files build with PHP like on this page. See for example, a simple demo...

    The php script has to return a valid Javascript :
    Code:
    <?php
    header("Cache-Control: no-cache, must-revalidate");
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Content-Type:text/javascript;charset=utf-8");
     
    	if (!empty($_GET)) {
    	//	lecture du GET et execution des t&#226;ches 
    	}
    	exit("alert('Your IP address is : ".$_SERVER['REMOTE_ADDR']." !');");
    ?>
    A GET method with possibility of returns...
    Last edited by 007Julien; 06-18-2012 at 06:05 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles