473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How to add script :"Are you sure to delete data?"

Hello PHP Friends,

I think this is just if else statement problem but im kinda lose to it.
The whole code is succesful in deleting the data from database the problem is i wanted to put a script that remind the user if he/she really sure to delete the data. By the way this is the script.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.     // connect to the database
  4.          include 'Connect.php';
  5.  
  6.     // confirm that the 'student_id' variable has been set
  7.          if (isset($_GET['student_id']) && is_numeric($_GET['student_id']))
  8.         {
  9.     // get the 'student_id' variable from the URL
  10.          $student_id = $_GET['student_id'];
  11.  
  12.     // delete record from database
  13.         if ($stmt = $mysql->prepare("DELETE FROM student_information WHERE student_id = ? LIMIT 1")) 
  14.         {
  15.             $stmt->bind_param("i",$student_id);    
  16.             $stmt->execute();
  17.             $stmt->close();
  18.         }
  19.         else
  20.         {
  21.             echo "ERROR: could not prepare SQL statement.";
  22.         }
  23.         $mysql->close();
  24.  
  25.     // redirect user after delete is successful
  26.         header("Location: Admin_Home.php");
  27.     }
  28.     else
  29.     // if the 'student_id' variable isn't set, redirect the user
  30.         {
  31.             header("Location: Admin_Home.php");
  32.         }
  33. ?>
  34.  
Please help me modify these codes and where to put the missing line/s of codes.
May 28 '14 #1
1 1760
Dormilich
8,658 Expert Mod 8TB
not possible in PHP as PHP runs on the server and has no connection to the client.

the only thing you can do is ask the user before calling the PHP script (you might make PHP check for a certain flag to prevent accidental execution).
May 30 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Tim Morrison | last post by:
SQL Server 2000 Is there any way to take sample data in my database and create an INSERT INTO script? I have a commercial application that I would like to include sample data, and instead of...
10
by: solosnake | last post by:
Whilst browsing Flipcode I noticed this code: class CConsole: public I_TextOutput { public: ... void Release() { delete this; } ... };
2
by: Peter CCH | last post by:
I encounter one weird problem, I have a database with around 7 GB ... when I delete a bunch of data from it, it suppose to reduce the database file size, but weirdly, the file size increase to 8...
6
by: alederer | last post by:
Hallo! I have a table tstest(ts char(13) for bit data constraint a unique). This column is filled in a trigger with generate_unique(). In a application (CLI), I have the values of this...
2
by: Mark Jones | last post by:
I'm trying to delete data from a DataGrid using a ButtonColumn with a CommandName="Delete" but it's not working a the min. I'm using session data which fills a DataTable which then fills the...
1
by: Dino Buljubasic | last post by:
Hi, I am using VS2005 (C#) and SQL Server 2000. How can I make sure that: 1. Client A queries info from database and displays it in a list view or other controls on a form. If Client B...
1
by: tilt | last post by:
Hello, I use an object element to replace the iframe element in ie, like this: <object id="x_obj" data="http://.../" type="text/html"> <iframe name="x_if" id="x_if"...
1
by: kang jia | last post by:
hi now i would like user to delete what they don;t want to buy after they already put it in shopping cart. i would like to have a pop up box to alert users that they are going to delete what they...
3
by: prigupta2 | last post by:
frontend vb6.0 backend Ms Aaccess how to delete data from database connection "adodc"
2
by: txbeachgirl | last post by:
How do I delete data from my iCloud from my iPhone?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.