Sorry for posting again. :| I'm working on this simple evaluation system for our final requirement in this subject. it's working now. my problem is I want to have an error checking (if it's the right term for that). if they leave one textbox blank?
the flow will be, if one textbox leaves blank and when you click submit the output will be "All fields required." then if all fields are filled the output will be "Thank you for your cooperation" then the data entered will be saved to the database.
The action of my submit button is RESULT.PHP
here is the code for it
<?php
$a=$_POST['a'];
$b=$_POST['b'];
$c=$_POST['c'];
$d=$_POST['d'];
$totala=($a+$b+$c+$d/4)*.10;
$e=$_POST['e'];
$f=$_POST['f'];
$g=$_POST['g'];
$h=$_POST['h'];
$i=$_POST['i'];
$j=$_POST['j'];
$totalb=($e+$f+$g+$h+$i+$j/6)*.25;
$l=$_POST['l'];
$m=$_POST['m'];
$n=$_POST['n'];
$o=$_POST['o'];
$p=$_POST['p'];
$q=$_POST['q'];
$r=$_POST['r'];
$s=$_POST['s'];
$t=$_POST['t'];
$totalc=($l+$m+$n+$o+$p+$q+$r+$s+$t/9)*.25;
$u=$_POST['u'];
$v=$_POST['v'];
$w=$_POST['w'];
$x=$_POST['x'];
$totald=($u+$v+$w+$x/4)*.15;
$y=$_POST['y'];
$z=$_POST['z'];
$aa=$_POST['aa'];
$totale=($y+$z+$aa/3)*.15;
$bb=$_POST['bb'];
$cc=$_POST['cc'];
$dd=$_POST['dd'];
$ee=$_POST['ee'];
$ff=$_POST['ff'];
$gg=$_POST['gg'];
$totalf=($bb+$cc+$dd+$ee+$ff+$gg/6)*.10;
$totalg=($totala+$totalb+$totalc+$totald+$totale+$totalf)/6;
$con = mysql_connect("localhost","-----","-----");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("----", $con);
$sql="INSERT INTO evaluate (Fname, Date, Subject, TotalA, TotalB, TotalC, TotalD, TotalE, TotalF, TotalG)
VALUES ('$_POST[faculty]','$_POST[date]','$_POST[subject]',$totala,$totalb,$totalc,$totald,$totale,$totalf,$totalg)";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Sucessful! Thank you very much for Your kind cooperation";
mysql_close($con)
?>
<br /><br />
<a href="evaluate.html">Back</a>
my problem is. how will i enter the code for error checking? with those multiple fields? Sorry i can't quite figure out how. i have this idea :
<?php
$e=$_POST['a'];
$f=$_POST['b'];
if ($e=="" && $f==""){
echo"All fields required";}
else{
echo "Thank you for your kind cooperation!";
}
?>
but then it's for 2 textbox only and i don't use database here. aww.