php接收html页面提交过来的值,能接收的到,但是进不去数据库
html页面------------------------------------------------------<HTML><HEAD><TITLE>添加学生成绩...
html页面------------------------------------------------------<HTML> <HEAD> <TITLE>添加学生成绩界面</TITLE> <meta charset="utf-8"> </HEAD> <BODY> <h1>添加学生界面</h1> <script type="text/javascript"></script> <form action="http://localhost/mysql/insertStudent.php" method="post"> 学生编号<input type="text" name="stuId"><br> 学生姓名<input type="text" name="stuName"><br> 语文成绩<input type="text" name="stuChinese"><br> 数学成绩<input type="text" name="stuMath"><br> 英语成绩<input type="text" name="stuEnglish"><br> <input type="submit" value="添加成绩"> </form></BODY> </HTML>php页面---------------------------------------------------------<?php header("Content-type:text/html;charset=utf-8"); $stuId=$_POST['stuId']; $stuName=$_POST['stuName']; $stuChinese=$_POST['stuChinese']; $stuMath=$_POST['stuMath']; $stuEnglish=$_POST['stuEnglish']; echo $stuMath; $con=mysql_connect('localhost','root',''); if(!$con){ echo '连接失败'; exit; }else{ echo '连接成功'; } mysql_select_db('db_student'); $sql = "INSERT INTO table_student VALUES($stuId,'$stuName',$stuChinese,$stuMath,$stuEnglish)"; // $sql = "INSERT INTO table_student(id,name,chinses,math,english)VALUES($stuId,'$stuName',$stuChinese,$stuMath,$stuEnglish)"; echo $sql; $is_ok = mysql_query($sql); if($is_ok == true){ echo '添加成功'; }else{ echo '添加失败'; }?>
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询