Register_2018411.php
<body>
<form name = "frm" action ="insert_2018411.php" method = "post">
Name<input type = "text" name= "txtName"/>
<br/>
Age<input type = "text" name ="txtAge"/>
<br/>
Gender
<input type = "radio" name ="rdGender" value = "1">Male
<input type = "radio" name ="rdGender" value = "0">Female
<br/>
<input type = "submit" name ="sbtsubmit" value = "Register"/>
</form>
</body>
insert_2018411.php
<?php
$name = $_POST['txtName'];
$age = $_POST['txtAge'];
$gender = $_POST['rdGender'];
$db =mysqli_connect("localhost","root","1234");
mysqli_select_db($db,"studentdb");
$in="insert intostudentinfotbl(stuName,stuAge,stuGender)values('$name','$age','$gender')";
mysqli_query($db,$in);
header("location:show_2018411.php");
?>
show_2018411.php
<?php
$db =mysqli_connect("localhost","root","1234");
mysqli_select_db($db,"studentdb");
$select = "select * fromstudentinfotbl";
$result = mysqli_query($db,$select);
?>
<table border = 1>
<tr><td>stuName</td><td>stuAge</td><td>stuGender</td><td>delete</td><td>update</td></tr>
<?php
while($resArry=mysqli_fetch_array($result)){?>
<tr>
<td><?phpecho $resArry[1]; ?></td>
<td><?phpecho $resArry[2]; ?></td>
<td><?php
if($resArry[3]==1){
echo"男";
}else{
echo"女";
}
?></td>
<td><?phpecho "<a href = 'delete_2018411.php?id=$resArry[0]'> delete</a>"; ?></td>
<td><?phpecho "<a href = 'updateFirst.php?id=$resArry[0]'> update</a>"; ?></td>
</tr>
<?php
}
?>
</table>
delete_2018411.php
<?php
$db = mysqli_connect("localhost","root","1234");
mysqli_select_db($db,"studentdb");
$id = $_GET['id'];
$delete = "delete from studentinfotblwhere stuId = $id";
mysqli_query($db,$delete);
header("location:show_2018411.php");
?>
updateFirst.php
<?php
session_start();
$id = $_GET['id'];
echo $id;
$_SESSION['id']=$id;
?>
<body>
<form name = "frm" action ="update_2018411.php" method = "post">
Name<input type = "text" name= "txtName"/>
<br/>
Age<input type = "text" name ="txtAge"/>
<br/>
Gender
<input type = "radio" name ="rdGender" value = "1">Male
<input type = "radio" name ="rdGender" value = "0">Female
<br/>
<input type = "submit" name ="sbtsubmit" value = "OK"/>
</form>
</body>
update_2018411.php
<?php
session_start();
$db = mysqli_connect("localhost","root","1234");
mysqli_select_db($db,"studentdb");
$name = $_POST['txtName'];
$age = $_POST['txtAge'];
$gender = $_POST['rdGender'];
$id = $_SESSION['id'];
if(1){
$update= "update studentinfotbl setstuName = '$name',stuAge = $age,stuGender = $gender
wherestuId =$id;";
mysqli_query($db,$update);
}
session_destroy();
header("location:show_2018411.php");
?>