Ok, I am trying to build a cpanel to a website. I had it working, but later found out that when I uploaded to live server, that the one on the live server is a newer version of php. I am running 4.2.0 and the liver server is running 4.3.1
Ok, here is the code that I have. What do I need to do in order to get this to work correctly? I have looked for other tutorials, but they are for versions lower than 4.3.1 Can someone help me, or shoot me a link to a tutorial that will work with 4.3.1?
<?php
$auth = false; // Assume user is not authenticated
if (isset($PHP_AUTH_USER) && isset($PHP_AUTH_PW)) {
// Connect to MySQL
mysql_connect("mysql2.smarterlinux.com","computerzonehq","")
or die ('Unable to connect to server.');
// Select database on MySQL server
mysql_select_db("computerzonehq")
or die ('Unable to select database.');
// Formulate the query
$sql = "SELECT * FROM users WHERE
username = '$PHP_AUTH_USER' AND
password = '$PHP_AUTH_PW'";
// Execute the query and put results in $result
$result = mysql_query($sql)
or die ('Unable to execute query.');
// Get number of rows in $result.
$num = mysql_num_rows($result);
if ($num !=0) {
// A matching row was found - the user is authenticated.
$auth = true;
}
}
if (! $auth) {
header('HTTP/1.0 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Computerzonehq"');
echo 'You are not authorized to view this page!<BR>
Please <a href="login.php">Log In</a> to continute<BR>
<BR>
Thank you,<BR>
SysCom
';
exit;
} else {
//display authorized information
echo '
<P>You are logged in as, '.$PHP_AUTH_USER.'!</P>
<BR>
<a href="http://127.0.0.1/mysql/">Database Management</a>(Seperate Login Required.)<BR>
<a href="../counter/sc_stats.php">View Stats</a><BR>
<a href="../counter/sc_clear.php">Clear Server Stats</a>(Seperate Login Required.)<BR>
<a href="../phpinfo.php">View PHP Info</a><BR>
';
}
?>
Like I said, I just need the easiest way to fix this. Or a tutorial on user auth'n that will work with php version 4.3.1
Or, is there a way that I can turn "register_globals on" just for this doc? I do not have control over ther server. I have asked the hosting admin to change this or help me out, but I am not getting much help there either.
Thanks again,
Frustrated PHP newbie