PHP Classes

Ex. Functions not working

Recommend this page to a friend!

      AEDEDL  >  All threads  >  Ex. Functions not working  >  (Un) Subscribe thread alerts  
Subject:Ex. Functions not working
Summary:The functions Add, edit, delete, disable do not work
Messages:2
Author:Xavier Van Nieuwenhuyse
Date:2007-02-26 17:00:08
Update:2007-02-27 09:44:02
 

  1. Ex. Functions not working   Reply   Report abuse  
Picture of Xavier Van Nieuwenhuyse Xavier Van Nieuwenhuyse - 2007-02-26 17:00:08
The functions Add, edit, delete, disable do not work in the example.
The list of records wiht their links shows correctly.
Using PHP 4.3.10

  2. Re: Ex. Functions not working   Reply   Report abuse  
Picture of Xavier Van Nieuwenhuyse Xavier Van Nieuwenhuyse - 2007-02-27 09:44:02 - In reply to message 1 from Xavier Van Nieuwenhuyse
I guess this script works with Register Globals off?

Here are some modifications that will make the script work in both cases:

In the sample script:

Line 55-59:
$this->data['id'] = (empty($_REQUEST['id'])) ? "":$_REQUEST['id'];
$this->data['name'] = (empty($_REQUEST['name'])) ? "":$_REQUEST['name'];
$this->data['email'] = (empty($_REQUEST['email'])) ? "":$_REQUEST['email'];
$this->data['website'] = (empty($_REQUEST['website'])) ? "":$_REQUEST['website'];
$this->data['active'] = (empty($_REQUEST['active'])) ? "1":$_REQUEST['active'];

Line 98:
$action = (isset($_GET['action'])) ? $_GET['action'] : "none";

Line 101:
echo "<HTML>\n<BODY>\n<CENTER>\n<A HREF=".$_SERVER['PHP_SELF'].">List All</A> - <A HREF=".$PHP_SELF."?action=add>Add Entry</A><P>\n<TABLE>\n\n";

Probably all the $PHP_SELF need to replaced, but the script works with this only replacement.

Remove line 46 and 47:
// You only need to make all variables used GLOBAL here. All other functions use the internal $this->data variable...
GLOBAL $id, $name, $email, $website, $active;

In the class, in the add and edit section:
Change lines 16 and 36
switch ($_SERVER['REQUEST_METHOD']) {

Remove lines 15 and 35 (or just above the two lines you changed):
GLOBAL $REQUEST_METHOD;