Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial 请帮帮忙,我贴代码了,现在不用下载文件看了。

请帮帮忙,我贴代码了,现在不用下载文件看了。

Jun 23, 2016 pm 01:56 PM
download code document

a.php  包含一个删除选中书签的复选框function display_user_urls($url_array){  // display the table of URLs  // set global variable, so we can test later if this is on the page  global $bm_table;  $bm_table = true;?>  <br />  <form name='bm_table' action='delete_bms.php' method='post'>  <table width=300 cellpadding=2 cellspacing=0>  <?php  $color = "#cccccc";  echo "<tr bgcolor='$color'><td><strong>Bookmark</strong></td>";  echo "<td><strong>Delete?</strong></td></tr>";  if (is_array($url_array) && count($url_array)>0)  {    foreach ($url_array as $url)    {      if ($color == "#cccccc")        $color = "#ffffff";      else        $color = "#cccccc";      // remember to call htmlspecialchars() when we are displaying user data      echo "<tr bgcolor='$color'><td><a href=\"$url\">".htmlspecialchars($url)."</a></td>";      echo "<td><input type='checkbox' name=\"del_me[]\"             value=\"$url\"></td>";      echo "</tr>";     }  }  else    echo "<tr><td>No bookmarks on record</td></tr>";?>  </table>   </form><?php}
Copy after login


点击上面删除的复选框后,需要点击下方的删除书签<?php  // only offer the delete option if bookmark table is on this page  global $bm_table;  if($bm_table==true)    echo "<a href='#' onClick='bm_table.submit();'>Delete BM</a> | ";   else    echo "<font color='#cccccc'>Delete BM</font> | "; ?>
Copy after login


delete_bms.php 删除函数如下<?php  require_once('bookmark_fns.php');  session_start();   //create short variable names  $del_me = $HTTP_GET_VARS['del_me'];  $valid_user = $HTTP_GET_VARS['valid_user'];   do_html_header('Deleting bookmarks');  check_valid_user();  if (!filled_out($HTTP_GET_VARS))  {    echo 'You have not chosen any bookmarks to delete.         Please try again.';    display_user_menu();    do_html_footer();      exit;  }  else   {    if (count($del_me) >0)    {      foreach($del_me as $url)      {        if (delete_bm($valid_user, $url))          echo 'Deleted '.htmlspecialchars($url).'.<br />';        else          echo 'Could not delete '.htmlspecialchars($url).'.<br />';      }      }    else      echo 'No bookmarks selected for deletion';  }  // get the bookmarks this user has saved  if ($url_array = get_user_urls($valid_user))    display_user_urls($url_array);  display_user_menu();   do_html_footer();?>
Copy after login


delete_bm函数的代码如下function delete_bm($user, $url){  // delete one URL from the database  $conn = db_connect(); //此处已经包含在另一个php文件中,连接数据库是正常的  // delete the bookmark  if (!$conn->query( "delete from bookmark                        where username='$user' and bm_url='$url'"))    throw new Exception('Bookmark could not be deleted');  return true;  }
Copy after login


我按照:http://bbs.csdn.net/topics/390801785这张贴中2位大牛的建议,将delete_bms.php中所有的 $HTTP_GET_VARS改为$_GET,测试之后,显示删除书签成功,调用代码“        echo 'Deleted '.htmlspecialchars($url).'.
';”但是刷新F5刷新网页书签还在,根本没有删除,请各位指点。我进入数据库查看,发现2个书签还在。。

还有个问题就是:为什么没有书签的时候,Delete BM 是不可以点状态,有书签的时候就会显示可用状态?这个代码有写没有书签就不可用吗?请指点。

 echo "Delete BM | ";  这一句代码bm_table.submit()是什么意思?我的php中好像没有submit函数。


回复讨论(解决方案)

bm_table.submit() 就是提交表单,bm_table是表单名,submit是表单方法。



明显是用$_POST获取传递的参数,而不是用$_GET。

$del_me = $_POST['del_me'];
$valid_user = $_POST['valid_user'];

基础还是需要先了解下,不然别人很难给予帮助。

你只判断了delete的query返回结果,而没有去执行mysql_query(“delete”)。

bm_table.submit() 就是提交表单,bm_table是表单名,submit是表单方法。



明显是用$_POST获取传递的参数,而不是用$_GET。

$del_me = $_POST['del_me'];
$valid_user = $_POST['valid_user'];

基础还是需要先了解下,不然别人很难给予帮助。
真是亮瞎我的眼睛了,原来问题出在这里。。测试通过。。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to download episodes of Hongguo short drama How to download episodes of Hongguo short drama Mar 11, 2024 pm 09:16 PM

Hongguo Short Play is not only a platform for watching short plays, but also a treasure trove of rich content, including novels and other exciting content. This is undoubtedly a huge surprise for many users who love reading. However, many users still don’t know how to download and watch these novels in Hongguo Short Play. In the following, the editor of this website will provide you with detailed downloading steps. I hope it can help everyone in need. Partners. How to download and watch the Hongguo short play? The answer: [Hongguo short play] - [Audio book] - [Article] - [Download]. Specific steps: 1. First open the Hongguo Short Drama software, enter the homepage and click the [Listen to Books] button at the top of the page; 2. Then on the novel page we can see a lot of article content, here

What should I do if I download other people's wallpapers after logging into another account on wallpaperengine? What should I do if I download other people's wallpapers after logging into another account on wallpaperengine? Mar 19, 2024 pm 02:00 PM

When you log in to someone else's steam account on your computer, and that other person's account happens to have wallpaper software, steam will automatically download the wallpapers subscribed to the other person's account after switching back to your own account. Users can solve this problem by turning off steam cloud synchronization. What to do if wallpaperengine downloads other people's wallpapers after logging into another account 1. Log in to your own steam account, find cloud synchronization in settings, and turn off steam cloud synchronization. 2. Log in to someone else's Steam account you logged in before, open the Wallpaper Creative Workshop, find the subscription content, and then cancel all subscriptions. (In case you cannot find the wallpaper in the future, you can collect it first and then cancel the subscription) 3. Switch back to your own steam

How to download links starting with 115://? Download method introduction How to download links starting with 115://? Download method introduction Mar 14, 2024 am 11:58 AM

Recently, many users have been asking the editor, how to download links starting with 115://? If you want to download links starting with 115://, you need to use the 115 browser. After you download the 115 browser, let's take a look at the download tutorial compiled by the editor below. Introduction to how to download links starting with 115:// 1. Log in to 115.com, download and install the 115 browser. 2. Enter: chrome://extensions/ in the 115 browser address bar, enter the extension center, search for Tampermonkey, and install the corresponding plug-in. 3. Enter in the address bar of 115 browser: Grease Monkey Script: https://greasyfork.org/en/

Introduction to how to download and install the superpeople game Introduction to how to download and install the superpeople game Mar 30, 2024 pm 04:01 PM

The superpeople game can be downloaded through the steam client. The size of this game is about 28G. It usually takes one and a half hours to download and install. Here is a specific download and installation tutorial for you! New method to apply for global closed testing 1) Search for "SUPERPEOPLE" in the Steam store (steam client download) 2) Click "Request access to SUPERPEOPLE closed testing" at the bottom of the "SUPERPEOPLE" store page 3) After clicking the request access button, The "SUPERPEOPLECBT" game can be confirmed in the Steam library 4) Click the install button in "SUPERPEOPLECBT" and download

How to download Quark network disk to local? How to save files downloaded from Quark Network Disk back to the local computer How to download Quark network disk to local? How to save files downloaded from Quark Network Disk back to the local computer Mar 13, 2024 pm 08:31 PM

Many users need to download files when using Quark Network Disk, but we want to save them locally, so how to set this up? Let this site introduce to users in detail how to save files downloaded from Quark Network Disk back to the local computer. How to save files downloaded from Quark network disk back to your local computer 1. Open Quark, log in to your account, and click the list icon. 2. After clicking the icon, select the network disk. 3. After entering Quark Network Disk, click My Files. 4. After entering My Files, select the file you want to download and click the three-dot icon. 5. Check the file you want to download and click Download.

What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. Mar 21, 2024 pm 09:17 PM

When deleting or decompressing a folder on your computer, sometimes a prompt dialog box &quot;Error 0x80004005: Unspecified Error&quot; will pop up. How should you solve this situation? There are actually many reasons why the error code 0x80004005 is prompted, but most of them are caused by viruses. We can re-register the dll to solve the problem. Below, the editor will explain to you the experience of handling the 0x80004005 error code. Some users are prompted with error code 0X80004005 when using their computers. The 0x80004005 error is mainly caused by the computer not correctly registering certain dynamic link library files, or by a firewall that does not allow HTTPS connections between the computer and the Internet. So how about

How to download foobar2000? -How to use foobar2000 How to download foobar2000? -How to use foobar2000 Mar 18, 2024 am 10:58 AM

foobar2000 is a software that can listen to music resources at any time. It brings you all kinds of music with lossless sound quality. The enhanced version of the music player allows you to get a more comprehensive and comfortable music experience. Its design concept is to play the advanced audio on the computer The device is transplanted to mobile phones to provide a more convenient and efficient music playback experience. The interface design is simple, clear and easy to use. It adopts a minimalist design style without too many decorations and cumbersome operations to get started quickly. It also supports a variety of skins and Theme, personalize settings according to your own preferences, and create an exclusive music player that supports the playback of multiple audio formats. It also supports the audio gain function to adjust the volume according to your own hearing conditions to avoid hearing damage caused by excessive volume. Next, let me help you

How to transfer files from Quark Cloud Disk to Baidu Cloud Disk? How to transfer files from Quark Cloud Disk to Baidu Cloud Disk? Mar 14, 2024 pm 02:07 PM

Quark Netdisk and Baidu Netdisk are currently the most commonly used Netdisk software for storing files. If you want to save the files in Quark Netdisk to Baidu Netdisk, how do you do it? In this issue, the editor has compiled the tutorial steps for transferring files from Quark Network Disk computer to Baidu Network Disk. Let’s take a look at how to operate it. How to save Quark network disk files to Baidu network disk? To transfer files from Quark Network Disk to Baidu Network Disk, you first need to download the required files from Quark Network Disk, then select the target folder in the Baidu Network Disk client and open it. Then, drag and drop the files downloaded from Quark Cloud Disk into the folder opened by the Baidu Cloud Disk client, or use the upload function to add the files to Baidu Cloud Disk. Make sure to check whether the file was successfully transferred in Baidu Cloud Disk after the upload is completed. That's it

See all articles