This example for you to share the PHP student management system source code for your reference, the specific content as follows
Function:
1. Add/Remove/Modify
2. Data storage.
Interface Distribution:
index.php---> Main interface
add.php--->stu add
Action---> SQL add/del/update (data store && page jumps that process HTML form-->mysql)
edit.php--->stu modification
menu.php--> Home
1. index.php
2. add.php
3. action.php
<?php/** * Created by Phpstorm. * USER:HYH * date:16-7-7 * Time: 9:37///1. Link database try{$pdo = new PDO ("Uri:mysqlPdo.ini", "Root", "1");}
catch (Pdoexception $e) {//Echo ' Connection failed: '. $e->getmessage ();
Die (' Connection failed '. $e->getmessage ());
The value of//2.action is done on the operation switch ($_get[' action ') {case ' add '://add $name = $_post[' name '];
$sex = $_post[' sex '];
$age = $_post[' age '];
$classid = $_post[' ClassID '];
$sql = "INSERT into stu (name, sex, age, ClassID) values (' {$name} ', ' {$sex} ', ' {$age} ', ' {$classid} ')";
$RW = $pdo->exec ($sql);
if ($rw > 0) {echo "<script>alter (' Add success ');</script>";
}else{echo "<script>alter (' Add failure ');</script>";
Header (' Location:index.php ');
Break
Case ' del '://get $id = $_get[' id '];
$sql = "Delete from Stu where id={$id}";
$RW = $pdo->exec ($sql); if ($rw > 0) {echo "<script>alter (' delete succeeded '));</script> ";
}else{echo "<script>alter (' delete failed ');</script>";
Header (' Location:index.php ');
Break
Case ' edit '://post $id = $_post[' id '];
$name = $_post[' name '];
$age = $_post[' age '];
$classid = $_post[' ClassID '];
$sex = $_post[' sex '];
Echo $id, $age, $age, $name;
$sql = "Update stu set Name= ' {$name} ', age={$age},sex= ' {$sex} ', classid={$classid} where id={$id};";
$sql = "Update myapp.stu set name= ' Jike ', sex= ' female ', age=24,classid=44 where id=17";
Print $sql;
$RW = $pdo->exec ($sql);
if ($rw > 0) {echo "<script>alter (' update successful ');</script>";
}else{echo "<script>alter (' update failed ');</script>";
Header (' Location:index.php ');
Break
Default:header (' Location:index.php ');
Break
}
4.edit.php
5. menu.php
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.