Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: $_GET variable not working in this case

  1. #1
    Join Date
    Dec 2009
    Posts
    29
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default $_GET variable not working in this case

    i have a dynamically loaded page with the following

    Code:
    Main Page
    {
    
    Menu Dynamically loaded content having form {
    display $_GET['someid']; Form {
    action = index.php#currentpage
    }
    }
    }
    this is not working....

    when i goto that seperate page
    Code:
    something/currentpage.php?user=adfsfd&id=234234
    i want to work like this
    Code:
    something.index.php?user=adkjs&id=234#currentpage
    how is this possible
    Last edited by legend.raju; 12-29-2009 at 09:07 PM. Reason: added further info

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Can you post your actual code?

  3. #3
    Join Date
    Dec 2009
    Posts
    29
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Post

    it is in prodigy.zxq.net

    check the members page at

    Members.php is

    HTML Code:
    <div class="pagecontent">
    <h3>
    <?php 
    if($_GET['userid'] == "boopathi")
    {
    	if($_GET['password'] == "admin")
    	{
    		echo "Welcome" + $_GET['userid'];
    	}
    }
    else
    {
    	echo "Login";
    }
    ?>
    
    </h3>
    <form name="login_form" action="#members" method="get">
    <table border=0 cellpadding=1 cellspacing=8>
    <tr>
    <td>User name </td>
    <td><input type="text" class="box" name="userid" /></td>
    </tr>
    <tr>
    <td>Password</td>
    <td><input type="password" class="box" name="password" /></td>
    </tr>
    <tr>
    <td></td>
    <td>
    <input type="submit" />
    </td>
    </tr>
    </table>
    </form>
    
    </div>

    and

    index.php has
    members.php as a dynamically loaded ajax page

    the site is
    Code:
    http://prodigy.zxq.net
    .....

    i understand that it has error in action=index.php#members ....
    but what i want is

    the members.php is loaded into a div
    when i submit the form it should validate in members.php or some other file other than index.php and return to the same page ....

    ll be helpful if it is dynamic .. if the page reloads also no problem ..

    do you understand what i want to do ?

  4. #4
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    The error is being caused because you are assuming that $_GET['userid'] is already set, where it may not be. Change it to:

    PHP Code:
    <?php 
    if(isset($_GET['userid']) && $_GET['userid'] == "boopathi")
    {
        if(isset(
    $_GET['password']) && $_GET['password'] == "admin")
        {
            echo 
    "Welcome " $_GET['userid'];
        }
    }
    else
    {
        echo 
    "Login";
    }
    ?>
    I also changed the "Welcome" part, as you want to concatenate the strings, and not actually add the two together.

  5. #5
    Join Date
    Dec 2009
    Posts
    29
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    what about action="#members" .....
    i tried with the changes (isset) ...
    but not working ...

    the form is submitted .. but not working .. !

  6. #6
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Might be cause of the anchor link not sure if this goes back to the server try ?members instead of #members

  7. #7
    Join Date
    Dec 2009
    Posts
    29
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    it is not working ... !

    i want something thats happening dynamically as in new orkut
    orkut.com/Main#home?uid=24233424

    but for me the url gets changed to this
    something/?userid=something&passwd=abcd#members

  8. #8
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Use post not get to keep the values out of the address bar


    or with schmoopys code

    PHP Code:
    <div class="pagecontent">
    <h3>
    <?php 
    if(isset($_POST['userid']) && $_POST['userid'] == "boopathi")
    {
        if(isset(
    $_POST['password']) && $_POST['password'] == "admin")
        {
            echo 
    "Welcome " $_POST['userid'];
        }
    }
    else
    {
        echo 
    "Login";
    }
    ?> 
    </h3>
    <form name="login_form" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
    <table border=0 cellpadding=1 cellspacing=8>
    <tr>
    <td>User name </td>
    <td><input type="text" class="box" name="userid" /></td>
    </tr>
    <tr>
    <td>Password</td>
    <td><input type="password" class="box" name="password" /></td>
    </tr>
    <tr>
    <td></td>
    <td>
    <input type="submit" />
    </td>
    </tr>
    </table>
    </form>

    </div>

  9. #9
    Join Date
    Dec 2009
    Posts
    29
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Post variable not working too .. .!

    and schmoopys code :

    it is the same as action="members.php"

    i go to members.php instead of index.php#members .. !

  10. #10
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    the posts are probably working but code is wrong forgot you were on different page change <?php echo $_SERVER['PHP_SELF'];?> to "#" or "?".

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
  •