I am getting an error message which is most irrititating as the script works on other projects:
Fatal error: Call to a member function getNumMembers() on a non-object in /var/www/vhosts/mindseyemidlands.co.uk/httpdocs/icommission/client2.php on line 265
here is my code - you will notice that the form is supposed to show only if the user is logged on.
<?php
include("include/session.php");
$_SESSION['formdata1']='';
$username = $_SESSION['username'];
include("connect.php");
// query
$sql = "SELECT * FROM client WHERE username = '".$username."'";
$result = mysql_query($sql);
// if we have rows, fetch them & prepopulate the form
if(mysql_num_rows($result) > 0) {
$row = mysql_fetch_array($result);
} else {
$row = array('client'=>'','organisation'=>'','address1'=>'','address2'=>'','town'=>''
,'postcode'=>'' ,'telephone'=>'','email'=>'','website'=>'','comments'=>'');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"><html><!-- InstanceBegin template="/Templates/template.dwt" codeOutsideHTMLIsLocked="false" --><head><title>icommission</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /></head>
<body>
<div id="banner">
<h1 align="center"><img src="logo.jpg" alt="icommission" width="575" height="118" /></h1>
</div>
<div id="navigation"><table width="600" border="0">
<tr>
<td width="345"><div align="left"><a href="client.php">Client</a></div></td>
<td width="345"><div align="left"><a href="serviceprovider.php">Service Provider </a></div></td>
</tr>
</table>
</div>
<div id="centercontent">
<!-- InstanceBeginEditable name="edit1" -->
<table>
<tr><td>
<?php
/**
* User has already logged in, so display relavent links, including
* a link to the admin center if the user is an administrator.
*/
if($session->logged_in){
echo "<h1>Logged In</h1>";
echo "Welcome <b>$session->username</b>, you are logged in. <br><br>"
."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] "
."[<a href=\"useredit.php\">Edit Account</a>] ";
if($session->isAdmin()){
echo "[<a href=\"admin/admin.php\">Admin Center</a>] ";
}
echo "[<a href=\"process.php\">Logout</a>]";
?>
<form name="form1" id="form1" method="post" action="client_formhandler.php">
<table width="500" border="0">
<tr>
<td>Client name</td>
<td>
<input name="client" type="text" id="client" value="<?=$row['client']?>" size="40"></td>
</tr>
<tr>
<td>Organisation</td>
<td><input name="organisation" type="text" id="organisation" value="<?=$row['organisation']?>" size="40"></td>
</tr>
<tr>
<td>Address1</td>
<td><input name="address1" type="text" id="address1" value="<?=$row['address1']?>" size="40"></td>
</tr>
<tr>
<td>Address2</td>
<td><input name="address2" type="text" id="address2" value="<?=$row['address2']?>" size="40"></td>
</tr>
<tr>
<td>Town</td>
<td><input name="town" type="text" id="town" value="<?=$row['town']?>" size="40"></td>
</tr>
<tr>
<td>Postcode</td>
<td><input name="postcode" type="text" id="postcode" value="<?=$row['postcode']?>" size="40"></td>
</tr>
<tr>
<td>Telephone </td>
<td><input name="telephone" type="text" id="telephone" value="<?=$row['telephone']?>" size="40" /></td>
</tr>
<tr>
<td>Email</td>
<td><input name="email" type="text" id="email" value="<?=$row['email']?>" size="40"></td>
</tr>
<tr>
<td>Website</td>
<td><input name="website" type="text" id="website" value="<?=$row['website']?>" size="40"></td>
</tr>
<tr>
<td>Comments</td>
<td><input name="comments" type="text" id="comments" value="<?=$row['comments']?>" size="40"></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td>Click submit </td>
<td><input type="submit" name="submit" value="submit" /></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</form>
<?php
}
else {
echo '<h1>Login</h1>';
/**
* User not logged in, display the login form.
* If user has already tried to login, but errors were
* found, display the total number of errors.
* If errors occurred, they will be displayed.
*/
if($form->num_errors > 0){
echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>";
}
?>
<form action="process.php" method="post">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>" /></td><td><? echo $form->error("user"); ?></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>" /></td><td><? echo $form->error("pass"); ?></td></tr>
<tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?> />
<font size="2">Remember me next time
<input type="hidden" name="sublogin" value="1" />
<input type="submit" value="Login" /></td></tr>
<tr><td colspan="2" align="left"><br /><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
<tr><td colspan="2" align="left"><br />Not registered? <a href="register.php">Sign-Up!</a></td></tr>
</table>
</form>
<?php
}
echo "</td></tr><tr><td align=\"center\"><br><br>";
echo "<b>Member Total:</b> ".$database->getNumMembers()."<br>";
echo "There are $database->num_active_users registered members and ";
echo "$database->num_active_guests guests viewing the site.<br><br>";
include("include/view_active.php");
?>
</td></tr>
</table>
<!-- InstanceEndEditable -->
</div>
</body>
<!-- InstanceEnd --></html>
any help greatly appreciated as always. I see one isse I may have is the way I am echoing the form.
<?php
/**
* User has already logged in, so display relavent links, including
* a link to the admin center if the user is an administrator.
*/
if($session->logged_in){
echo "<h1>Logged In</h1>";
echo "Welcome <b>$session->username</b>, you are logged in. <br><br>"
."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] "
."[<a href=\"useredit.php\">Edit Account</a>] ";
if($session->isAdmin()){
echo "[<a href=\"admin/admin.php\">Admin Center</a>] ";
}
echo "[<a href=\"process.php\">Logout</a>]";
?>
<form name="form1" id="form1" method="post" action="client_formhandler.php">
<table width="500" border="0">
<tr>
<td>Client name</td>
<td>
<input name="client" type="text" id="client" value="<?=$row['client']?>" size="40"></td>
</tr>
how else can I echo it other than echoing the login script, closing with ?> then showing the form fields
<input name="client" type="text" id="client" value="<?=$row['client']?>" size="40">
Trouble is I want to prepopulate the form hence the value is displayed thus