p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: URL Link with register globals OFF


Message #1 by "Philipp Feer" <svaziphil@s...> on Mon, 28 Oct 2002 17:37:05 +0800
Hi all
 
Again stuck with changing a website to the "register globals OFF -
Standard" .
 
Below the partially code that works if I have the globals ON.
I guess again that $action is not set. But I can not figure out how to
set $action with a link. The Menu is not a form so I can not send action
hidden (right?). 
 
As well how do I pass an additional variable (eg. $LoginName) as if did
it before in that way: 
echo "$PHP_SELF?action=editOwn&LoginName=$LoginName"
 
 
------------------------------------------------------------------------
---
 
<a href="<? echo "$_SERVER[PHP_SELF]?action=addNewUser"?>"><img
src="../Buttons/AddUser.gif" alt="add new user" border="0"><br>
        </a> <a href="<? echo "$PHP_SELF?action=editUsers"?>"><img
src="../Buttons/EditUsers.gif" alt="edit users" width="150" height="34"
border="0"><br>
        </a> <a href="<? echo
"$PHP_SELF?action=editOwn&LoginName=$LoginName"?>"><img
src="../Buttons/EditOwnInfo.gif" alt="edit own info" border="0"><br>
        </a> <a href="<? echo "$PHP_SELF?action=deleteUsers"?>"><img
src="../Buttons/deleteUser.gif" alt="delete user" width="150"
height="34" border="0"></a></p>
      <p>&nbsp;</p></td>
 
 
 
 
 
if(isset($_POST['action']) && $_POST['action '] != ''){
              
                          switch($_POST['action']) {
                                      case "addNewUser":
/*************** user management (User_inc) **************/
                                                addNewUser();
                                      break;
                                      case "addNewUser2":
                                      addNewUser2();
                                      break;
                                      case "editUsers":
                                                editUsers();
                                      break;
                                                  default: 
                                                  DisplayMenu($level);
                                                  break;
 
             }// end switch 
} else {
    
    echo ". NO ACTION <br>\n";   // so we know there wasn't an
    $level = 1; // temporary, because no login yet
            DisplayMenu($level);                  // action but you can
go ahead with the script 
 
}
 
-----------------------------------------------------------------
 
Thank you, phil
 

Message #2 by "Nikolai Devereaux" <yomama@u...> on Mon, 28 Oct 2002 12:21:29 -0800
Okay, the problem you're having here is that variables passed on the URL are
GET parameters, not POST parameters.


For example:

<?php

echo "<a href=\"{$_SERVER['PHP_SELF']}?myvar=myval\">Click here</a>\n";

if(isset($_GET['myvar']))
{
    echo "<hr>\nYou sent \"{$_GET['myvar']}\"!\n";
}

?>


Take care,

Nik

Message #3 by "svazi" <svaziphil@s...> on Thu, 31 Oct 2002 14:04:27
Thank you!

It worket!!

> 
Okay, the problem you're having here is that variables passed on the URL 
are
GET parameters, not POST parameters.


For example:

<?php

echo "<a href=\"{$_SERVER['PHP_SELF']}?myvar=myval\">Click here</a>\n";

if(isset($_GET['myvar']))
{
    echo "<hr>\nYou sent \"{$_GET['myvar']}\"!\n";
}

?>


Take care,

Nik


  Return to Index