PHP develops simple voting system administrator function module (4)
The main purpose here is to add the name of the new voting title in the <input> text box
Then when you click "Add New Item", it will be displayed in the voting title bar The newly added title,
and adds new data in the database.
<input name="newitem" type="text" id="newitem" /> <input type="submit" name="Submit2" value="添加新項" />
Add new items to the database table by operating the database SQL language INSERT INTO.
<?php if(isset($_POST["Submit2"])) { $newitem=$_POST["newitem"]; $SQL="INSERT INTO vote (titleid,item,count) VALUES (1,'$newitem',1)"; mysqli_query($link,$sql); } ?>
Add "Exit management" after "Add new item" and jump to the voting page index.php
Exit the management main operation session, delete the session file corresponding to the current user and release session to log out as administrator.
HTML code:
<a href="?tj=out">退出管理</a>
PHP code:
<?php if(isset($_GET['tj']) == 'out'){ session_destroy();//刪除當前用戶對應(yīng)的session文件以及釋放session echo "<script language=javascript>alert('退出成功!');window.location='index.php'</script>"; } ?>