hi there people,
Having recently installed and getting to grips with php4.2.2, mysql4.0.1 alpha & apache2.0.39....
I am desparate for some help here. When I run my forms / scripts, they do not seem to recognise that all the fields have been completed properly, I always get the die statement
("You have not completed the form correctly, Please go back and try again.") every single time.
I fill the form in correctly every time. so what is the problem? Maybe you could try running
these files on your installation and let me know if it works for you. I have checked and rechecked the code but cannot seem to find any problems with it. Maybe you can? If it works for you then it must be something to do with my installation. (If it is - maybe you know what I should change?)
I have created the following simple php form called getdetails.php.
[UBB]
<html>
<head>
<title> Submit Lecture details </title>
</head>
<body bgcolor="#FFFFFF">
<form action="grabdetails.php" method="POST">
</a>
<table border="0" cellpadding="0" cellspacing="0" bordercolor="#111111" width="100%">
<tr>
<td width="100%" bgcolor="#FF9900" height="22" colspan="2">
<p style="margin-left: 10"><b><font face="Verdana" size="2" color="#FFFFFF">
Upload a File</font></b></td>
</tr>
<tr>
<td width="100%" bgcolor="#FFE3BB" colspan="2">
<p style="margin-left: 10; margin-right: 10"><font face="Verdana" size="2">
<br>Please insert all the information regarding the lecture video you have
chosen to upload. The file will not upload if all fields are not filled in
correctly. Once you have chosen the lecture video file, please click on the
" Upload this file" button below.
<br> </font></td>
</tr>
<tr>
<td width="15%" bgcolor="#FFE3BB">
<p style="margin-left: 10"><font face="Verdana" size="2">
Module Code:</font></td>
<td width="85%" bgcolor="#FFE3BB">
<input type="text" name="ModCode" size="20" maxlength="50"></td>
</tr>
<tr>
<td width="15%" bgcolor="#FFE3BB">
<p style="margin-left: 10"><font face="Verdana" size="2">Module Title:</font></td>
<td width="85%" bgcolor="#FFE3BB">
<font face="Verdana" size="2">
<input type="text" name="Title" size="20" maxlength="50"></td>
</tr>
<tr>
<td width="15%" bgcolor="#FFE3BB">
<p style="margin-left: 10"><font face="Verdana" size="2">Lecturer Name:</font></td>
<td width="85%" bgcolor="#FFE3BB">
<font face="Verdana" size="2">
<input type="text" name="Lecturer" size="20" maxlength="50"></td>
</tr>
<tr>
<td width="15%" bgcolor="#FFE3BB">
<p style="margin-left: 10"><font face="Verdana" size="2">Week:</font></td>
<td width="85%" bgcolor="#FFE3BB">
<font face="Verdana" size="2">
<input type="text" name="Week" size="20" maxlength="50"></td>
</tr>
<tr>
<td width="15%" bgcolor="#FFE3BB">
<p style="margin-left: 10"><font face="Verdana" size="2">Topics Covered:</font></td>
<td width="85%" bgcolor="#FFE3BB">
<font face="Verdana" size="2">
<input type="text" name="Topics" size="20" maxlength="255"></td>
</tr>
/*<!--<tr>
<td width="15%" bgcolor="#FFE3BB">
<p style="margin-left: 10"><font face="Verdana" size="2">File Location:</font></td>
<td width="85%" bgcolor="#FFE3BB">
<font face="Verdana" size="2">
<input type="file" name="fileUpload" size="20"></font></td>
</tr>-->*/
<tr>
<td width="33%" bgcolor="#FFE3BB">
<p style="margin-left: 10"><font face="Verdana" size="2">
<br>
<br>
</font></td>
<td width="67%" bgcolor="#FFE3BB">
<font face="Verdana" size="2">
<input type="submit" value="Submit"></font></td>
</tr>
</table>
</form>
</body>
</html>
[/UBB]
I then created a php script to store the values from the form in mysql a database called projectg, table lecfiles. as below...
[UBB]
<html>
<head>
<title> this is a test </title>
</head>
<body>
<?
// Grabdetails.php:
//Takes all the details of the
//new file posted from the form
//and adds them to the lecfiles
//table of projectg DB.
//Make sure both a description and
//file have been entered
if (!$ModCode | | !$Title | | !$Lecturer | | !Week | | !$Topics)
{
echo "You have not completed the form correctly,
Please go back and try again.";
exit;
}
$ModCode = addslashes($ModCode);
$Title = addslashes($Title);
$Lecturer = addslashes($Lecturer);
$Week = addslashes($Week);
$Topics = addslashes($Topics);
$db = mysql_pconnect("localhost", "root", "password");
if (!$db)
{
echo "Error: Gee could not connect to database";
exit;
}
mysql_select_db("lecfiles");
$query = "insert into lecfiles VALUES
('".$ModCode."', '".$Title."', '".$Lecturer."', '".$Week."', '".$Topics."')";
$result = mysql_query($query);
if ($result)
echo mysql_affected_rows()." Data inserted into Database.";
?>
</body>
</html>
[/UBB]
Any offers???????????????
Please?????????
I keep runnin into brick walls with this stuff!
Gee.