I never did claim to be an expert????
Anyway, I have made the changes suggested above and the script still doesnt work & I cant see why. Anyone?
<HTML>
<BODY>
<?php
if(isset($addfood)):
?>
<FORM ACTION="<?php echo $_SERVER
['PHP_SELF'];?>" METHOD="POST">
<P>Food name<BR>
<TEXTAREA NAME="Food" Rows="1" COLS="40" WRAP></TEXTAREA>
<P>Energy (Kcals)<BR>
<TEXTAREA NAME="Energy" Rows=1 COLS="40" WRAP></TEXTAREA><BR>
<P>Protein (g)<BR>
<TEXTAREA NAME="Protein" Rows=1 COLS="40" WRAP></TEXTAREA><BR>
<P>Fat (g)<BR>
<TEXTAREA NAME="Fat" Rows=1 COLS="40" WRAP></TEXTAREA><BR>
<P>Carbohydrates (g)<BR>
<TEXTAREA NAME="Carbo" Rows=1 COLS="40" WRAP></TEXTAREA><BR>
<P>Calcium (g)<BR>
<TEXTAREA NAME="Calcium" Rows=1 COLS="40" WRAP></TEXTAREA><BR>
<P>Iron (mg)<BR>
<TEXTAREA NAME="Iron" Rows=1 COLS="40" WRAP></TEXTAREA><BR>
<P>Sodium (mg)<BR>
<TEXTAREA NAME="Sodium" Rows=1 COLS="40" WRAP></TEXTAREA><BR>
<P>Vitimin A (mmg)<BR>
<TEXTAREA NAME="VitA" Rows=1 COLS="40" WRAP></TEXTAREA><BR>
<P>Vitimin C (mg)<BR>
<TEXTAREA NAME="VitC" Rows=1 COLS="40" WRAP></TEXTAREA><BR>
<INPUT TYPE="SUBMIT" NAME="Submitfood" VALUE="SUBMIT">
</FORM>
<?php
else:
//connect to the database server
$dbcnx = @mysql_connect();
if(!$dbcnx) {
echo("<P>Unable to connect</P>");
exit();
}
//select the food database
if(! @mysql_select_db("Foods")) {
echo("<P>Unable to locate the food database</P>");
exit();
}
//if a food has been submitted, add it in
if("SUBMIT" == "submitfood") {
$sql = "INSERT INTO breakfast SET".
"Food = '$food',".
"Energy = '$Energy',".
"Protein = '$Protein',".
"Fat = '$Fat',".
"Carbo = '$Carbo',".
"Calcium = '$Calcium',".
"Iron = '$Iron',".
"Sodium = '$Sodium',".
"VitA = 'VitA',".
"VitC = 'VitC'";
if(mysql_query($sql)) {
echo("<P>The food item has been successfully added</P>");
}else{
echo("<P>Error adding food to the database:" .mysql_error(). "<P>"); }
}
echo("<P>HERE ARE THE BREAKFAST FOODS IN THE DATABASE</P>");
$result=mysql_query(
"SELECT * FROM Breakfast");
while($row = mysql_fetch_array($result)){
echo("<P>" .$row["Food"]. "<P>");
}
echo('<P><A HREF="'.$_SERVER['PHP_SELF'].'?addfood=1">add a food!</A></P>');
endif;
?>
</BODY>
</HTML>