Jump to content

Need help with include...


ronnie1988

Recommended Posts

Okay if I use an include to include a login script the login button doesn't work at all but it works on the page itself just not on the include

 

http://store.crytell.com/

 

when I attempt to login nothing happens Im sure I have the script dir right

 

<body bgcolor="#100f14"> 
<?
/**
* Main.php
*
* This is an example of the main page of a website. Here
* users will be able to login. However, like on most sites
* the login form doesn't just have to be on the main page,
* but re-appear on subsequent pages, depending on whether
* the user has logged in or not.
*
* Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
* Last Updated: August 26, 2004
*/
include("./storelogin/include/session.php");
?>

<html>
<title>Jpmaster77's Login Script</title>
<body>

<table>
<tr><td>


<?
/**
* 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=\"./storelogin/userinfo.php?user=$session->username\">My Account</a>]   "
       ."[<a href=\"./storelogin/useredit.php\">Edit Account</a>]   ";
   if($session->isAdmin()){
      echo "[<a href=\"./storelogin/admin/admin.php\">Admin Center</a>]   ";
   }
   echo "[<a href=\"./storelogin/process.php\">Logout</a>]";
}
else{
?>

<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="./storelogin/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="./storelogin/forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
<tr><td colspan="2" align="left"><br>Not registered? <a href="./storelogin/register.php">Sign-Up!</a></td></tr>
</table>
</form>

<?
}

/**
* Just a little page footer, tells how many registered members
* there are, how many users currently logged in and viewing site,
* and how many guests viewing site. Active users are displayed,
* with link to their user information.
*/
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("./storelogin/include/view_active.php");

?>


</td></tr>
</table>


</body>
</html>

																<?include_once "./storelogin/main.php"; // this will include a.php?>

Link to comment
Share on other sites

Keep in mind that you're using a script that had it's last update 6 years ago. This was PHP 5.0.0 - PHP 5.0.3 latest and you're using PHP 5.2.14, some things may not work as expected... and use of globals, I believe, became a big no-no since then. It's a -REALLY- old script, I skimmed over the source and there are methods that aren't really used now, but it looks like you've fixed your problem.

Link to comment
Share on other sites

I see what your problem is. You are downloading login scripts and then trying to include the login.php script on your page. You can't do this if it's got a full HTML layout on it already. What you're essentially doing is including an entire html page right now.

 

If you want, you could either remove all the HTML you don't need in login.php, or find out where the form from the script sends the data using $_POST and make a form that submits the same data to that page.

 

Personally, I would recommend writing it from scratch so that you don't have to overcome problems with other peoples' scripts. It's a lot more of a learning curve, but at least after you've done it you know exactly what is wrong with your scripts. That alone played a big factor in my learning PHP.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.