SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    stirling
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php GET parameters

    I am posting variables from one page using - method = "GET" in the first page thE values appear in the url but i cannot retrieve them in the next page with the following lines:
    <?PHP
    $uname = $HTTP_GET_VARS['name'];
    $password = $HTTP_GET_VARS['password'];
    echo "$uname";
    ?>
    What have i done wrong??
    thnx. dh

  2. #2
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Try :

    PHP Code:
     
    $uname 
    $_GET['name'];
    $password $_GET['password'];
     
    echo 
    $uname

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We would need more code to tell you what's wrong but try doing this after <?php
    print_r($_GET);

    See if the entries are in there. If they are not then something is wrong with your code.

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    stirling
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The url appears with:

    ....SuccessfulRegistration.php?name=ddd&password=ddd&address=gfgf&postcode=dfsd&telephone=5656
    &handicap=12

    trying those methods displays a blank page.
    the HTML code on the first page that sends the parameters is:

    HTML Code:
    <form action = "SuccessfulRegistration.php" method = "GET">
    	<br>
    	To register to this website please enter your details below, then click 'Submit'.
    	<br>
    	<br>
    
    	 	Enter username:  <input type = "text" id = "name_field" name = "name"/><br>
    	 	<br>
    	 	Enter password:  <input type = "password" id = "password_field" name = "password"/><br>
    	 	<br>
    	 	Enter address:   <input type = "text" id = "address_field" name = "address"/><br>
    	 	<br>
    	 	Enter postcode:   <input type = "text" id = "postcode_field" name = "postcode"/><br>
    	 	<br>
    	 	Enter Telephone Number:  <input type = "number" id = "telephone_field" name = "telephone"/><br>
    	 	<br>
    	 	Enter your handicap:   <input type = "number" id = "handicap_field" name = "handicap" value="none"/>   (If known)<br>
    	 	<br>
    	 	<br>
    	 	<input type = "submit" VALUE = "Submit"/>
    	</form>
    if that helps

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    stirling
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok sorted that problem. But is there a way i can hide the password in the url. The type of the input is hidden so it doesnt appear when typed. Just to make it more secure.

  6. #6
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    Use POST instead of GET as your form method.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  7. #7
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    stirling
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks but using POST instead of GET gives me blank values when i insert into my database for some reason. Is that the only way to hide the password? is there a simple way of encoding and decoding on arrival?

  8. #8
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    POST sould act the same as GET in the respect that it will pass the info to the next page by do it silently...

    Therefore if you used the POST method in your form..

    HTML Code:
    <form action = "SuccessfulRegistration.php" method = "POST">
    	<br>
    	To register to this website please enter your details below, then click 'Submit'.
    	<br>
    	<br>
    
    	 	Enter username:  <input type = "text" id = "name_field" name = "name"/><br>
    	 	<br>
    	 	Enter password:  <input type = "password" id = "password_field" name = "password"/><br>
    	 	<br>
    	 	Enter address:   <input type = "text" id = "address_field" name = "address"/><br>
    	 	<br>
    	 	Enter postcode:   <input type = "text" id = "postcode_field" name = "postcode"/><br>
    	 	<br>
    	 	Enter Telephone Number:  <input type = "number" id = "telephone_field" name = "telephone"/><br>
    	 	<br>
    	 	Enter your handicap:   <input type = "number" id = "handicap_field" name = "handicap" value="none"/>   (If known)<br>
    	 	<br>
    	 	<br>
    	 	<input type = "submit" VALUE = "Submit"/>
    	</form>
    On the next page use....
    PHP Code:
    $name_field $_POST['name_field'];
    # etc..... 
    Then use those variables in your insert statement.

    See if that works.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

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