Hi,
I have copied this script: add entry but my problem is after running it is suppose to generate the entered new info however, submit=add to database should not be generated. such as:
ID = 12
first = juan
last = carlos
address = davao
position = trainee
submit = add to database
<?php
if($submit){
$db=mysql_connect("localhost","root");
mysql_select_db("mydb",$db);
echo "$count\n";
$sql="INSERT INTO employees (id,first,last,address,position) VALUES ('$ID','$first','$last','$address','$position')";
$result=mysql_query($sql);
echo "<font size=4 face=arial color=#330066>\n";
while (list($name,$value)= each($HTTP_POST_VARS)){
echo "$name = $value<br><br>\n";
}
echo "<font size=5 face=arial color=red>";
echo "<center>Thank you! Information has been added to database.</font>\n";
echo "<br><br><Br>\n";
echo "<form method=\"post\" action=\"$PHP_SELF\">\n";
echo "<input type=\"submit\" value=\"add again\">\n";
echo "</form>\n";
echo "<form method=\"post\" action=\"testing6.php\">\n";
echo "<input type=\"submit\" value=\"back to main\">\n";
echo "</form>\n";
}
else{
$count=1;
$db=mysql_connect("localhost","root");
mysql_select_db("mydb",$db);
$temp=mysql_query("SELECT * FROM employees");
while($myrow=mysql_fetch_array($temp)){
$count=$count+1;//test how many records have been in database.
}
echo "<Br><Br>\n";
echo "<table boarder=0><tr><td align=right>\n";
echo "<font size=4 face=arial color=#330066>\n";
echo "<form method=post action=\"$PHP_SELF\">\n";
echo " <font color=red>Your ID will be $count\n</font><br>";
echo "<input type=\"hidden\" value=$count name=\"ID\"><br>\n";
echo "First Name: <input type=\"text\" name=\"first\"><Br><Br>\n";
echo "Last Name: <input type=\"text\" name=\"last\"><Br><Br>\n";
echo "Address: <input type=\"text\" name=\"address\"><Br><Br>\n";
echo "Position: <input type=\"text\" name=\"position\"><Br><br>\n";
echo "<input type=\"submit\" name=\"submit\" value=\"add to database\">\n";
echo "</form>\n";
echo "</td></tr></table>\n";
}
?>
hoping for all your patience since I'm a newbie.
thanks:😕