On of my new collegues is learning PHP on a worn out windows 95 machine. We've downloaded the latest version of PHP and Apache and installed MySql 3.23.
He's learning from an old book so I think this is where the problem originates. Anyway its the old "I can't pass this variable" problem again.
YES we've checked the php.ini file and although whether we set register_globals to on or off I found I could only access posted variables by using $_POST['variablename']
Now the problem is we can't get the data into the database.
I'll post the two scripts but they're probably in a right mess now because we've played around with them so much just trying to get the thing to work!! I'm probably just overlooking something obvious!!!
Code: Select all
employeeform.php
<HTML>
<HEAD>
<TITLE>Employee entry form</TITLE>
</HEAD>
<BODY>
<P>Please fill out the form below to submit your first name, last name, address, and position.</P>
<FORM NAME="employees" METHOD="POST" ACTION="employeesEntry.php">
First name: <INPUT TYPE="text" NAME="first" SIZE=25><BR>
Last name: <INPUT TYPE="text" NAME="last" SIZE=25><BR>
Address: <INPUT TYPE="text" NAME="address" SIZE=25><BR>
Position: <INPUT TYPE="text" NAME="position" SIZE=25><BR>
<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Enter Information">
</FORM>
</BODY>
</HTML>Code: Select all
<?php
$DBhost = "localhost";
$DBuser = "shearn";
$DBName = "employees";
$table = "employees";
if ($_POSTї'SUBMIT'] == "Enter Information") {
echo "<BODY>First Name:", $_POSTї'first'],"<br>";
echo "Last Name:", $_POSTї'last'],"<br>";
echo "Address:",$_POSTї'address'],"<br>";
echo "Position:", $_POSTї'position'], "<br><br></BODY>";
//process form
//$dblink =
mysql_connect("localhost") or die(mysql_error());
mysql_select_db("employees") or die(mysql_error());
print ("Connected successfully.");
$first=$_POSTї'first'];
$last=$_POSTї'last'];
$address=$_POSTї'address'];
$position=$_POSTї'position'];
$sql ="INSERT INTO employees (first, last, address, position) VALUES ('$first',$last','$address','$position')";
//$result =
mysql_query($sql);
print(" Your information has been recorded.");
//mysql_close($dblink);
}
?>