Php 将数据插入MySQL不起作用

Php 将数据插入MySQL不起作用,php,mysql,sql,database,Php,Mysql,Sql,Database,我有一个简单的学生注册到一些大学取决于他们的学生ID和密码 在他们登录后,它会向他们显示一些他们必须填写的信息,如“名字、姓氏、生日、学位等”。当我试图插入这些信息项时,它不起作用 数据库名称:users,表名:members\u info。以下是我使用的代码: index.php <?php session_start(); ?> <form action="login.php?login=yes" method="post" name="login"> <inp

我有一个简单的学生注册到一些大学取决于他们的
学生ID
密码

在他们登录后,它会向他们显示一些他们必须填写的信息,如“名字、姓氏、生日、学位等”。当我试图插入这些信息项时,它不起作用

数据库名称:
users
,表名:
members\u info
。以下是我使用的代码:

index.php

<?php session_start(); ?>
<form action="login.php?login=yes" method="post" name="login">
<input type='text' name='username' id='userid' placeholder='Your ST_ID' >
<input type='password' name='password' required='required'>
</form>
 <input type='submit' name='resultbtn'  id='submit' value='Log In' >
<?php
error_reporting(0);
$username = $_POST['username'];
$password= $_POST['password'];
$login = $_GET['login'];

setcookie("username","$username",time()+86400);

if($login=='yes') {
    $con = mysql_connect("localhost","root","");
    mysql_select_db("users");
    $get = mysql_query("SELECT count(id) FROM members_info WHERE username='$username' and password='$password' ");
    $result = mysql_result($get,0);

if($result !=1){
    echo "error with login";
}
else {
$_SESSION['username'] = $username;

$sqll = "SELECT * FROM members_info WHERE username='$username' ";
$myqu = mysql_query($sqll,$con);
    include 'info.php';
  }
}
?>
...
<form method='post' action='mmbrs_inf.php'>
<input type='text' name='stname' placeholder='Your Name'>
<input type='text' name='stfname' placeholder='Father's Name'>
<input type='date' name='birthday'>
<input type='text' name='city'  placeholder='Your City'>
<select name='Select1'>
                <option>50</option>
                <option>60</option>
                <option>70</option>
                <option>80</option>
                <option>90</option>
                <option>100</option>
</select>

<input type='Reset' value='Reset' name='resetall'/>
    <input type='submit' value='Send'  name='submit'/>

</form>
...
$stname = $_POST['stname'];
$stfname = $_POST['stfname'];
$birthday = $_POST['birthday'];
$city = $_POST['city'];
$english_dgree =$_POST['eng_dgree'];
//connect
mysql_connect("localhost", "root", "");
mysql_select_db("users");


//check if submit is pressed 
if(isset($_POST['submit'])){
    //inserting
    $query = mysql_query("INSERT INTO members_info (student_name,student_father,birthdate,mycity,english) VALUES($stname,$stfname,$birthday,$city,$english_dgree) 
WHERE username='$_COOKIE[username]' ");
    echo"Your Informations Has Been Sent Successfully,....";        
}
else{
echo"An Error Has Accoure ";
}

它向我显示消息“您的信息已成功发送,…”,但没有在我的数据库中插入任何内容。

INSERT
语句没有
WHERE
子句。您正在插入新行或更新新行。你不能同时做这两件事

此外,字符串值周围缺少引号

我们也要这样做:

INSERT INTO members_info 
(student_name,student_father,birthdate,mycity,english_dgree) 
VALUES('$stname','$stfname','$birthday','$city','$english_dgree');
或:


INSERT
语句没有
WHERE
子句。您正在插入新行或更新新行。你不能同时做这两件事

此外,字符串值周围缺少引号

我们也要这样做:

INSERT INTO members_info 
(student_name,student_father,birthdate,mycity,english_dgree) 
VALUES('$stname','$stfname','$birthday','$city','$english_dgree');
或:


INSERT
语句没有
WHERE
子句。您正在插入新行或更新新行。你不能同时做这两件事

此外,字符串值周围缺少引号

我们也要这样做:

INSERT INTO members_info 
(student_name,student_father,birthdate,mycity,english_dgree) 
VALUES('$stname','$stfname','$birthday','$city','$english_dgree');
或:


INSERT
语句没有
WHERE
子句。您正在插入新行或更新新行。你不能同时做这两件事

此外,字符串值周围缺少引号

我们也要这样做:

INSERT INTO members_info 
(student_name,student_father,birthdate,mycity,english_dgree) 
VALUES('$stname','$stfname','$birthday','$city','$english_dgree');
或:



首先,表单没有名称属性,元素有。好的,谢谢你的提示:)不客气。既然John的答案解决了问题,请访问下面的内容,然后返回给出的答案,并执行相同的操作thanx@fred ii^^我总是按“投票赞成”按钮,我是“接受答案”我的错,谢谢help@halferthanx bro我不会使用此代码,对我的老师来说这只是一个小项目首先,表单没有名称属性,好的,谢谢你的留言:)不客气。既然John的答案解决了问题,请访问下面的内容,然后返回给出的答案,并执行相同的操作thanx@fred ii^^我总是按“投票赞成”按钮,我是“接受答案”我的错,谢谢help@halferthanx bro我不会使用此代码,对我的老师来说这只是一个小项目首先,表单没有名称属性,好的,谢谢你的留言:)不客气。既然John的答案解决了问题,请访问下面的内容,然后返回给出的答案,并执行相同的操作thanx@fred ii^^我总是按“投票赞成”按钮,我是“接受答案”我的错,谢谢help@halferthanx bro我不会使用此代码,对我的老师来说这只是一个小项目首先,表单没有名称属性,好的,谢谢你的留言:)不客气。既然John的答案解决了问题,请访问下面的内容,然后返回给出的答案,并执行相同的操作thanx@fred ii^^我总是按“投票赞成”按钮,我是“接受答案”我的错,谢谢help@halferthanx bro我不会使用此代码,这对我的老师来说只是一个小项目!我们能在这里提一提乱石般的伟大SQL注入vuln吗!我们能在这里提一提乱石般的伟大SQL注入vuln吗!我们能在这里提一提乱石般的伟大SQL注入vuln吗!我们能在这里提一提强大的SQL注入vuln吗?