I set up a server on an AMD 650 machine running gentoo linux.
I installed Apachie 2, MySQL 4.1 and PHP 4.3.11
I use another computer on my local net (192.168.0.x) to access the server as a client.
MySQL works perfectly. I have created and queried databases with no problem.
Apachie 2 appears to work with no problem. I can call up web pages in the expected maner.
I created a set of php scripts which I found in Larry Ullman's book "PHP and MySQL For Dynamic Web Sites." For those of you with that book, I used Script 7.7 and replaced all the constants with my own values.
The script does the following things:
-) require_once() a script which opens MySQL and attaches the database.
-) Creates a form for the user to enter their username and password.
-) Handles the form.
-) If all input was provided, query the database for the username/password pair.
-) If username/password are in the database, then
session_start();
$_SESSION['authenticated'] = TRUE;
header ("Location: main-admin.php");
exit();
Everything appears to work untill I hit the session_start(). If I leave any fields blank or give a bad password, the script catches it and generates the error responce.
But if I give a good responce, the script just yields a perfectly blank HTML doc. Not even a title.
If I go to the server and run
# php index.php
it comes back with "Illegal Instruction." but with no explanation.
If I comment out the session_start(); then everything works perfectly, including the header().
If I move session_start(); to the very beginning of the script, it still dies and with the same symptoms. And since the script is generating a form on its first pass, the header() function is not encountered.
So why does php 4.3.11 concidder session_open to be an illegal instruction?
I have read the php manual, but have found nothing there.
php.ini has session auto start set to 0. I did not see anything else in php.ini which seemed to be related.
Thanks for any help or suggestions you can give.
I have coppied the entire script below for those who are interested.
Bob W.
<?php # /home/justadventure/html/admin/index.php
# This is the Index page for Admins.
# Admins must enter by this page. It is the only page which authenticates.
# It also starts a session.
# Every other admin page will check for authentication, via a session variable.
# If that variable is unavailable, then access is denied.
#
# This page both prompts for authentication via a form and also handles the form.
# It verifies that the user is allowed to continue and then passes control to the Main page.
#
# If authentication fails, then an explaination is displayed.
#
# Version 1.0 10-MAY-2005
# First, check if the form was submitted and we are now to handle it.
if (isset($_POST['submit'])) {
require_once ('../../secret/mysql-admin-main.php');
function escape_data ($data) {
global $dbc;
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string($data, $dbc);
}
$message = NULL;
if (empty($_POST['username'])) {
$u = FALSE;
$message .= '<p>You forgot to enter your username!</p>';
} else {
$u = escape_data($_POST['username']);
}
if (empty($_POST['password'])) {
$p = FALSE;
$message .= '<p>You forgot to enter your password!</p>';
} else {
$p = escape_data($_POST['password']);
}
if ($u && $p) { // If everything's OK.
$query = "SELECT adm_usrname FROM admins WHERE adm_usrname='$u' and adm_password=PASSWORD('$p')";
$result = @mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_NUM);
if ($row) {
// Start the session, register the values & redirect.
session_start();
$_SESSION['authenticated'] = TRUE;
header ("Location: main-admin.php");
exit();
} else {
$message = '<p>The username and password entered do not match those on file.</p>';
}
mysql_close();
} else {
$message .= '<p>Please try again.</p>';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>JustAdventure Administers Login Page</title>
</head>
<body>
<?php
if (isset($message)) {
echo '<font color="red">', $message, '</font>';
}
# Create the form and designate this script as the handler.
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset><legend>Enter your information in the form below:</legend>
<p><b>User Name:</b> <input type="text" name="username" size="10" maxlength="20" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /></p>
<p><b>Password:</b> <input type="password" name="password" size="20" maxlength="20" /></p>
<div align="center"><input type="submit" name="submit" value="Login" /></div>
</fieldset></form><!-- End of Form -->
</body>
</html>
--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----