Sessions and Objects using PHP4
| From: | David OBrien | Date: | Fri, 14 Jan 2005 18:24:18 +0000 |
| Subject: | Sessions and Objects using PHP4 | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-206411@lists.php.net to get a copy of this message | ||
I have RTFM and TTFE and still am having a heck of a time getting my objects to play well between pages
The only real examples are in the notes for classes & objects
http://us2.php.net/manual/en/language.oop.php
Basic usage
<?
include_once("config.inc");
include_once("class.php");
$songbook = new songbook(); // defined in the class.php
session_register('songbook');
$songbook->get_stats();
$songbook->populate_manu();
$songbook->populate_series();
if (!isset($songbook->userid) || $songbook->userid == "") {
header("Location: login.php");
}
Now the login.php is basically the same but if the login correctly it should set $songbook->userid to the username
require('common.php');
session_start();
include_once("class.php");
$songbook = new songbook();
session_register('songbook');
include("newheader.php");
if ( isset($_POST['submitit'])) {
$link = dbconnector();
$sql = "select * from userinfo where lower(username)=lower('".$_POST['user']."') and lower(password)=lower('".$_POST['pass']."')";
$result = mysql_query($sql);
if( mysql_num_rows($result) > 0 ) {
$songbook->userid = strtolower($_POST['user']);
header("Location: green.php");
} else {
$errormsg = "<font size=3>Invalid Username or Password.<br>\nPlease Try Again.</font>";
}
}
So I guess what I am asking is how DO you make objects work across pages?
-Dave