Hello... I was wondering if anybody could help me find a solution to my rather annoying problem!! I used to run these scripts on another server without any hiccups... However, on the new server, I keep getting "Cannot Redeclare"; I have tried include_once though that didn't work either?
I've included the scripts here for you - it is a login system:
THE LOG-IN PAGE: (INDEX.PHP)
<form action="process_login.php" method="post" name="login" id="login">
<table width="56%" border="0" align="center" cellpadding="4" cellspacing="0">
<tr class="logtext">
<td width="42%"><span class="style35"> USERNAME</span></td>
<td width="58%">
<input name="username" type="text" id="username2" size="15">
</td>
</tr>
<tr class="logtext">
<td><span class="style35">PASSWORD</span></td>
<td>
<input name="password" type="password" id="password" size="15">
</td>
</tr>
<tr class="logtext">
<td> </td>
<td><input type="image" name="submit" src="images/enter.jpg" width="115" height="20"></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr class="text">
<td width="100%" align="left" valign="top" class="style42 style41 style39 text"><div align="center"><strong><? echo $thanks_output; ?>
<?php
if (isset($error_output))
{
echo '<p class="logtext" text-align: center;">' . $error_output . '</p>';
}
?>
</strong></div></td>
</tr>
</table>
</form>
PROCESS_LOGIN.PHP (PROCESSES THE LOG-IN)
<?php
session_name("SID");
session_start();
include 'logging_functions.php';
include 'db.php';
if (isset($_POST['submit']))
{
$username = $_POST['username'];
$password = $_POST['password'];
if ((!$username) || (!$password))
{
$error_output = 'Please enter your Username and Password!';
include 'login.php';
exit;
}
// Convert password to md5 hash
$password = md5($password);
// check if the user info validates the db
$sql = mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$password' AND activated = '1'") or die(mysql_error());
$login_check = mysql_num_rows($sql);
if ($login_check > 0)
{
while ($row = mysql_fetch_assoc($sql))
{
$_SESSION['username'] = stripslashes($row['username']);
$_SESSION['first_name'] = stripslashes($row['first_name']);
$_SESSION['last_name'] = stripslashes($row['last_name']);
}
// Cookie domain
setcookie(session_name(), session_id(), (time() + 3600), '/', '', '0');
header('location: main.php');
}
else
{
$error_output = 'Incorrect username and/or password. Try again?';
include 'index.php';
}
}
else
{
// Form data wasn't available. Check for existing session.
if (is_logged_in())
{
$error_output = 'You are already logged in.';
}
include 'main.php';
}
?>
LOGGING_FUNCTIONS.PHP - LOGS PEOPLE IN/OUT:
<?php
function is_logged_in()
{
if (isset($_SESSION['username']))
{
return true;
}
else
{
return false;
}
}
function logout($destroy_cookie = true)
{
if (is_logged_in())
{
$_SESSION = array();
session_destroy();
if ($destroy_cookie)
{
setcookie(session_name(), session_id(), (time() - 3600), '/', '', '0');
}
}
}
?>
FINALLY, THE HEADER INSIDE THE MAIN.PHP PAGE:
<?php
session_name("SID");
session_start();
include 'logging_functions.php';
if (!is_logged_in())
{
header('location: index.php');
}
?>
DB.PHP - only contains the database connection string u/name & p/wd.
Any help/advice you could offer would be greatly appreciated!
Have a great day...
Many Thanks,
MM2006 :rolleyes: