I am a self-proclaimed "newbie" to PHP and MySQL. I have read through several tutorials, but I just do not get what I ma doing wrong with this simple script.
I am currently running on a server that supports MySQL 3.23.56 and PHP 4.2.2. I am attempting to write a script to allow my members to submit reports directly to our database for viewing by other members.
Can someone take a look at this and see why it is not working?
The PHP script entitled "script.php" is as follows:
<?php
$db = mysql_connect("localhost", "my user name","my pasword"); <--changed to the actual names of course....
mysql_select_db("margaritaair_com",$db);
$sql = "INSERT INTO flightlog (macid, name, date, type, departure, destination, time, charterdoll, comment) VALUES ('$macid', '$name', '$date','$type','$departure','$destination','$time','$charterdoll','$comment')";
$result = mysql_query($sql);
if ($result) {
echo ("PIREP recorded successfully");
} else{
echo("An error has occurred, please contact the Club President");
}
MySQL_close()
?>
The Data input form is as follows:
<HTML>
<HEAD>
<BODY background="sky01.jpg">
<TITLE>PIREP INPUT FORM</TITLE>
<form method="post" action="script.php">
MACID: <input type="text" name="macid"><br>
Name: <input type="text" name="name"><br>
Date of Flight: <input type="text" name="date"><br>
Type of Flight: <input type="text" name="type"><br>
Departure: <input type="text" name="departure"><br>
Destination: <input type="text" name="destination"><br>
Charter Pay: <input type="text" name="charterdoll"><br>
Comment: <input type="text" name="comment"><br>
<input type="submit" name="submit" value="SUBMIT ">
</form>
</html>
When I run the script I get no errors returned, but the information does not make it into the database. Both script.php and the html form are in the same directory and the directory has the proper permissions to write. You can go to http://www.margaritaair.com/test1.html to give it a try if you like.
Any ideas? Or does anyone know where to get a script that is already working?
Thanks
Todd