Hi since I was kept receiving the error " headers alread sent" in my login code, I decided to separate the from from its action. I'm getting this error now: is there a way to fix it?: Fatal error: Call to a member function on a non-object in g:\programs(2)\easyphp1-8\www\ha\previous\new folder\another\htdocs\loginaction.php on line 4 codes are here the for action code: loginaction.php: <?php include('global.php'); include('html_form.php'); if ($form->valid()) { $processed = $form->getProcessed(); $remember = $form->getValue('remember'); if (!isset($_SESSION['login'])) { $_SESSION['login'] = 3; } else { if ($_SESSION['login'] <= 1) { die('You cannot log in.'); } } if ($user->_checkLogin($processed['username'], $processed['password'], $remember)) { if (isset($_SESSION['log_to'])) { header("Location: {$_SESSION['log_to']}"); exit; } else { header("Location: account.php"); exit; } } else { failed($form); } } else { begin_html(); $form->display(); } function failed(&$form) { begin_html(); echo "<p>You could not be logged in, $_SESSION[login] attempts left.</p> <p>Possible reasons for this are:</p> <ul> <li>Your username and/or password is not correct. Check your username and password and then try again.</li> <li>You haven't " . '<a href="signup.php" title="Sign up for an account, it is free">registered</a> yet</li> <li>Your account is temporarily disabled.</li> <li>You are trying to login simultaneously from two different computers or two browsers on the same computer.</li> </ul>'; } ?> PHP: and the form: <? require_once 'global.php'; if ($_SESSION['logged']) { include('clean.php'); redirect('account.php'); } else{ ?><html> <head> <meta http-equiv="Content-Language" content="fa"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>left menu</title> </head> <body> <table border="1" width="100%" id="table1" height="346"> <tr> <td width="97" height="37">left menu</td> <td height="37"> <p align="center">I'd like items here</td> <td width="148" height="37">right menu</td> </tr> <tr> <td width="97">my menu</td> <td><?php /* $Id: login.php,v 1.7 2002/09/03 22:02:01 shaggy Exp $ */ require_once 'html_form.php'; define("act","loginaction.php"); $form = new Form(act); $form->addText('username', 'شناسه كاربري'); $form->addPassword('password', 'رمز عبور'); $form->addCheckbox('remember', 'Remember me'); $form->addSubmit('ورود'); $form->addRule('username', 'range:5:20', 'Enter your username, 5 - 20 characters.'); $form->addRule('password', 'range:5:20', 'Enter your password, 5 - 20 characters.'); $form->addFilter('_ALL_', 'db'); $form->display(); ?></td> <td width="148">my menu</td> </tr> </table> </body> </html> <?}?> PHP: original code: <? require_once 'global.php'; ?><html> <head> <meta http-equiv="Content-Language" content="fa"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>left menu</title> </head> <body> <table border="1" width="100%" id="table1" height="346"> <tr> <td width="97" height="37">left menu</td> <td height="37"> <p align="center">I'd like items here</td> <td width="148" height="37">right menu</td> </tr> <tr> <td width="97">my menu</td> <td><?php /* $Id: login.php,v 1.7 2002/09/03 22:02:01 shaggy Exp $ */ require_once 'html_form.php'; $form = new Form(uri_self()); $form->addText('username', 'شناسه كاربري'); $form->addPassword('password', 'رمز عبور'); $form->addCheckbox('remember', 'Remember me'); $form->addSubmit('ورود'); $form->addRule('username', 'range:5:20', 'Enter your username, 5 - 20 characters.'); $form->addRule('password', 'range:5:20', 'Enter your password, 5 - 20 characters.'); $form->addFilter('_ALL_', 'db'); if ($form->valid()) { $processed = $form->getProcessed(); $remember = $form->getValue('remember'); if (!isset($_SESSION['login'])) { $_SESSION['login'] = 3; } else { if ($_SESSION['login'] <= 1) { die('You cannot log in.'); } } if ($user->_checkLogin($processed['username'], $processed['password'], $remember)) { if (isset($_SESSION['log_to'])) { redirect($_SESSION['log_to']); } else { redirect('account.php/'); } } else { failed($form); } } else { begin_html(); $form->display(); } function failed(&$form) { begin_html(); echo "<p>You could not be logged in, $_SESSION[login] attempts left.</p> <p>Possible reasons for this are:</p> <ul> <li>Your username and/or password is not correct. Check your username and password and then try again.</li> <li>You haven't " . '<a href="signup.php" title="Sign up for an account, it is free">registered</a> yet</li> <li>Your account is temporarily disabled.</li> <li>You are trying to login simultaneously from two different computers or two browsers on the same computer.</li> </ul>'; $form->display(); } ?></td> <td width="148">my menu</td> </tr> </table> </body> </html> PHP:
you need to declare $form as an object. should look something like as follows. from what i gather, the class resides in html_form.php so... require_once 'html_form.php'; $form = new Form(act); PHP:
thanks I have something like this on my first post. (second code): require_once 'html_form.php'; define("act","loginaction.php"); $form = new Form(act); PHP: and then the form elements. isn't that enough? :roll: