您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php删除用户

2025/1/16 4:21:37发布15次查看
<?php # script 10.2 - delete_user.php// this page is for deleting a user record.// this page is accessed through view_users.php.$page_title = 'delete a user';echo '<h1>delete a user</h1>';// check for a valid user id, through get or post:if ( (isset($_get['id'])) && (is_numeric($_get['id'])) ) { // from view_users.php$id = $_get['id'];} elseif ( (isset($_post['id'])) && (is_numeric($_post['id'])) ) { // form submission.$id = $_post['id'];} else { // no valid id, kill the script.echo '<p class="error">this page has been accessed in error.</p>';exit();}require ('c.php');// check if the form has been submitted:if ($_server['request_method'] == 'post') {if ($_post['sure'] == 'yes') { // delete the record.// make the query:$q = "delete from user where user_id=$id limit 1";$r = @mysqli_query ($dbc, $q);if (mysqli_affected_rows($dbc) == 1) { // if it ran ok.// print a message:echo '<p>the user has been deleted.</p>';} else { // if the query did not run ok.echo '<p class="error">the user could not be deleted due to a system error.</p>'; // public message.echo '<p>' . mysqli_error($dbc) . '<br />query: ' . $q . '</p>'; // debugging message.}} else { // no confirmation of deletion.echo '<p>the user has not been deleted.</p>';}} else { // show the form.// retrieve the user's information:$q = "select concat(last_name, ', ', first_name) from user where user_id=$id";$r = mysqli_query ($dbc, $q);if (mysqli_num_rows($r) == 1) { // valid user id, show the form.// get the user's information:$row = mysqli_fetch_array ($r, mysqli_num);// display the record being deleted:echo "<h3>name: $row[0]</h3>are you sure you want to delete this user?";// create the form:echo '<form action="delete_user.php" method="post"><input type="radio" name="sure" value="yes" /> yes聽<input type="radio" name="sure" value="no" checked="checked" /> no<input type="submit" name="submit" value="submit" /><input type="hidden" name="id" value="' . $id . '" /></form>';} else { // not a valid user id.echo '<p class="error">this page has been accessed in error.</p>';}} // end of the main submission conditional.mysqli_close($dbc);?>
本文讲解了php删除用户的相关操作,更多内容清关注。
相关推荐:
mysql数据库多表操作
mysql数据库单表查询
oracle数据库输出输入
以上就是php删除用户的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product