Not getting my data inserted into mysql database using html

There isn’t any mistake in my code but still am not getting my data inserted into mysql database using html … please guide me if there is any mistake within it

<html>
<head>
<title>
STUDENTS RECORD
</title>
</head>
<body>
<form action="students.php" method="post ">
<table width="600" border="10" align="center" >
<tr>
<td bgcolor="blue" align="center" colspan="5" ><h2>STUDENT'S REGISTRATION</h2></td>
</tr>
<tr>
<td align="right" >STUDENT NAME:</td>
<td  ><input type="text" name="student_name" ></td>
</tr>

<tr>
<td align="right" >SCHOOL NAME:</td>
<td><input type="text" name="school_name"></td>
</tr>

<tr>
<td align="right" >ROLL NO:</td>
<td><input type="text" name="roll_number"></td>
</tr>

<tr>
<td align="right" >STATUS:</td>
<td><input type="text" name="status"></td>
</tr>

<tr>
<td align="right" colspan="5" ><input type="submit" name="submit" value="SUBMIT"</td>
</tr>

</table>
</form>  

<table width="600" border="10" align="center">
<tr>
<th>Serial No.</th>
<th>STUDENT NAME</th>
<th>SCHOOL NAME</th>
<th>ROLL NO</th>
<th>STATUS</th>
<th>Delete</th>
<th>Edit</th>
</tr>
<?php
mysql_connect("localhost","root","");
mysql_select_db("school");

$query1="select * from students";
$run=mysql_query($query1);
while($row=mysql_fetch_array($run))
{
	$id=$row['ID'];
	$s_name=$row['NAME'];
	$school=$row['SCHOOL_NAME'];
	$roll=$row['ROLL_NUMBER'];
	$result=$row['STATUS'];


?>
<tr align="center" >
			<td><?php echo $id; ?></td>
		    <td><?php echo $s_name; ?></td>
			<td><?php echo $school; ?></td>
			<td><?php echo $roll; ?></td>
			<td><?php echo $result; ?></td>
			<td>Delete</td>
			<td> Edit</td>
<?php } ?>
</tr> 
</table>
</body>
</html>
<?php
mysql_connect("localhost","root","");
mysql_select_db("school");
if (isset($_POST['submit']))
{
     $name=$_POST['student_name'];
     $school=$_POST['school_name'];
     $roll=$_POST['roll_number'];
     $result=$_POST['status'];	
     $query ="insert into students(NAME,SCHOOL_NAME,ROLL_NUMBER,STATUS) values ('$name','$school','$roll','$result')";

}

?>

There are mistakes, as you know/don’t know. :slight_smile:
The insert query is never executed, it just gets put in a variable.
But, that is not all that is wrong, there is more, but it’s late here and I’m not at best right now to deal with it, so just the main point.

these calls no longer exist - they were removed from PHP last year - the mySQLI and PDO interfaces were introduced in 2004 to replace it.

Also there is no need to connect to the database multiple times - once per script is sufficient unless you are connecting to more than one server.

I am sure others will come along to tell you about more of the errors.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.