php在线打分

来源:互联网 发布:dos返回windows 编辑:程序博客网 时间:2024/05/16 17:51
<html>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<body>
<div id="formbackground" style="position:absolute; width:100%; height:45%; z-index:-1"><img src="head.png" width="100%" height="45%" /></div>
    <br><br><br>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
    <?php 
    session_start();
    echo $_SESSION['Student_Name'];
    ?>
 <?php 
   // session_start();
    header("Content-Type:text/html;charset=gbk");
    $link0="链  接  :";
    $link00=iconv("UTF-8","gbk",$link0);
    echo "<br><br><br><br><br>&nbsp&nbsp&nbsp&nbsp$link00";
    $link1="综合考评细则";
    $link11=iconv("UTF-8","gbk",$link1);
    echo "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<a href='/school/studentA/detail/detail1.html' style='text-decoration:none'>$link11</a>";
    $link2="德育考评细则";
    $link22=iconv("UTF-8","gbk",$link2);
    echo "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<a href='/school/studentA/detail/detail2.html' style='text-decoration:none'>$link22</a>";
    $link3="额外加分细则";
    $link33=iconv("UTF-8","gbk",$link2);
    echo "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<a href='/school/studentA/detail/detail3.html' style='text-decoration:none'>$link33</a>";
 ?>
 <div style="margin-left:0px; margin-top:20px; width:30px; height:30px;"><a href="/school/studentA/apply/apply.php"><img src="1.png"></a></div>
<div style="margin-left:0px; margin-top:75px; width:30px; height:30px;"><a href="/school/studentA/check/check.php"><img src="2.png"></a></div>
<div style="margin-left:0px; margin-top:70px; width:30px; height:30px;"><img src="3.png"></a></div>
<div style="margin-left:0px; margin-top:70px; width:30px; height:30px;"><a href="/school/studentA/sum/sum.php"><img src="4.png"></a></div>
<div style="margin-left:0px; margin-top:70px; width:30px; height:30px;"><a href="/school/studentA/exam/exam.php"><img src="5.png"></a></div>
<form  action="1103.php" method="post"> 
<table  style="margin-left:304px;margin-top:-480px;" border=1 bordercolor="#6E6E6E" cellpadding="7" frame="box" rules="all">
    <br><br>
    <?php
   // session_start();
    header("Content-Type: text/html;charset=gbk");
    $con=mysql_connect("localhost","root","9277");  
            mysql_select_db("School",$con);  
            mysql_query("set names 'gbk'");  
            $moral=$_SESSION['username'];
            $i=0;
            $result=mysql_query("select * from Moralfromstudent left join Student on Moralfromstudent.Class=Student.Class where Student.Username='$moral'");//mysql_query 查询数据库的函数
            $status1="文明行为";$status11=iconv("UTF-8","gbk",$status1);
            $status2="思想品德";$status22=iconv("UTF-8","gbk",$status2);
            $status3="文明行为";$status33=iconv("UTF-8","gbk",$status3);
            $status4="法纪观念";$status44=iconv("UTF-8","gbk",$status4);
            $status5="心理素质";$status55=iconv("UTF-8","gbk",$status5);
            $status6="扣分";$status66=iconv("UTF-8","gbk",$status6);
            $status7="备注";$status77=iconv("UTF-8","gbk",$status7);
                echo "<tr align=\"center\"  bgcolor=\"#DCDCDC\">
                <td>Class</td><td>Name</td><td>ID</td>
                <td>$status11</td><td>$status22</td><td>$status33</td><td>$status44</td><td>$status55</td>
                <td>$status66</td><td>$status77</td></tr>";
            while($row=mysql_fetch_array($result)){
                $i=$i+1;
                if($i%2==1){
                    echo "<tr align=\"center\">
                <td>$row[2]</td><td>$row[0]</td><td>$row[1]</td>
                <td><input type=\"text\" name=h1$i /></td> <td><input type=\"text\" name=h2$i /></td> 
                <td><input type=\"text\" name=h3$i /></td> <td><input type=\"text\" name=h4$i /></td> 
                <td><input type=\"text\" name=h5$i /></td> <td><input type=\"text\" name=h6$i /></td> 
                <td><input type=\"text\" name=h7$i /></td> 
                </tr>";
                $_SESSION["Student_ID".$i]=$row[1];
                }else{
                    echo "<tr  bgcolor=\"#DCDCDC\" align=\"center\">
                    <td>$row[2]</td><td>$row[0]</td><td>$row[1]</td>
                    <td><input type=\"text\" name=h1$i /></td> <td><input type=\"text\" name=h2$i /></td> 
                    <td><input type=\"text\" name=h3$i /></td> <td><input type=\"text\" name=h4$i /></td> 
                    <td><input type=\"text\" name=h5$i /></td> <td><input type=\"text\" name=h6$i /></td> 
                    <td><input type=\"text\" name=h7$i /></td> 
                    </tr>";
                    $_SESSION["Student_ID".$i]=$row[1];
                }
            }
?>
</table>
<table style="margin-left:1750px;margin-top:0px;">
<tr><br><br>
<?php 
    echo "<td><input type=\"submit\" name=\"submit\" value=\"submit\"></td>";
?>


</tr>
</table>
</form> 
</body>

</html>

后台处理


<?php  
session_start();
header("Content-Type:text/html;charset=gbk");
$i=1;
//$stu_ID="";
while($i<=20){
   if(isset($_POST["submit"])&&$_POST["submit"] =="submit"){
      $str1= $_POST["h1".$i];  
      $str2= $_POST["h2".$i];
      $str3= $_POST["h3".$i];
      $str4= $_POST["h4".$i];  
      $str5= $_POST["h5".$i];
      $str6= $_POST["h6".$i];
      $str7= $_POST["h7".$i];
      $stu_ID= $_SESSION["Student_ID".$i];
      echo "<br>";
      if($_POST["h1".$i]=="" || $_POST["h2".$i] == ""||$_POST["h3".$i] == ""//表格的内容为空
         ||$_POST["h4".$i]=="" || $_POST["h5".$i] == ""||$_POST["h6".$i] == ""){  
         echo "<script LANGUAGE='javascript'>alert('content should be null'); history.go(-1);</script>";
      }else if($_POST["h1".$i]>5.00001||$_POST["h1".$i]<0||$_POST["h2".$i]>5.00001||$_POST["h2".$i]<0||$_POST["h3".$i]>5.00001||$_POST["h3".$i]<0||$_POST["h4".$i]>5.00001||$_POST["h4".$i]<0||$_POST["h5".$i]>5.00001||$_POST["h5".$i]<0||$_POST["h6".$i]>0){
         echo "<script LANGUAGE='javascript'>alert('content is illegal'); history.go(-1);</script>";
      }else{
            $con=mysql_connect("localhost","root","9277");  
            mysql_select_db("School",$con);  
            mysql_query("set names 'gbk'");  
           $sql="UPDATE `Moralfromstudent` SET `Political attitudes`=\"$str1\" ,`Moral`=\"$str2\" ,`Civilized behavior`=\"$str3\",`Legal Records`=\"$str4\",`Psychological Quality`=\"$str5\",`Marking`=\"$str6\",`Remark`=\"$str7\" WHERE ID=\"$stu_ID\"";
           $result=mysql_query($sql);  
           $addsum="update Moralfromstudent set Sum = `Political attitudes`+`Civilized behavior` + `Moral`+`Legal Records`+`Psychological Quality`+`Marking`";   
           $result=mysql_query($addsum);      
      }   
    }
    $i++;
 }
echo "<script LANGUAGE='javascript'>alert('sucecessfully'); history.go(-1);</script>";  //弹出提示框返回上一
?>




 

0 0