Hi,how can I use confirmation here..?
I want to check if there are records that exist in database using pop up confirmation..this is my code.. -
<?php
-
if(isset($_POST['upload'])){
-
if($_FILES['file']['name'] == "") {
-
?>
-
<script type="text/javascript" >
-
alert("Please specify a file to upload.");
-
window.location = "uploadExam_part1.php";
-
</script>
-
<?php
-
}
-
else {
-
include "config.php";
-
$sel = "SELECT * from questionpart1";
-
$result = mysql_query($sel);
-
-
if(mysql_num_rows($result) > 0) {
-
?>
-
<script type="text/javascript">
-
var check = confirm("Are you sure you want to replace the questions?");
-
if(check) {
-
//i don't know what to do in here
-
}
-
else {
-
//and in here
-
}
-
-
</script>
-
<?php
-
}
-
-
-
require_once('DB.php');
-
-
-
-
$data = array();
-
-
-
-
$db =& DB::connect("mysql://root@localhost/aptitude", array());
-
-
if (PEAR::isError($db)) { die($db->getMessage()); }
-
-
-
function add_person( $type, $question, $choice1, $choice2, $choice3, $choice4, $answer )
-
-
{
-
-
global $data, $db;
-
-
-
-
$sth = $db->prepare( "INSERT INTO questionpart1 VALUES(0, ?, ?, ?, ?, ?, ?, ? )" );
-
-
$db->execute( $sth, array( $type, $question, $choice1, $choice2, $choice3, $choice4, $answer ) );
-
-
-
-
$data []= array(
-
'type' => $type,
-
-
'question' =>$question,
-
-
'choice1' => $choice1,
-
-
'choice2' => $choice2,
-
-
'choice3' => $choice3,
-
-
'choice4' => $choice4,
-
-
'answer' => $answer
-
-
);
-
-
}
-
-
-
-
if ( $_FILES['file']['tmp_name'] )
-
-
{
-
-
$dom = DOMDocument::load( $_FILES['file']['tmp_name'] );
-
-
$rows = $dom->getElementsByTagName( 'Row' );
-
-
$first_row = true;
-
-
foreach ($rows as $row)
-
-
{
-
-
if ( !$first_row )
-
-
{
-
$type = "";
-
-
$question = "";
-
-
$choice1 = "";
-
-
$choice2 = "";
-
-
$choice3 = "";
-
-
$choice4 = "";
-
-
$answer = "";
-
-
-
-
$index = 1;
-
-
$cells = $row->getElementsByTagName( 'Cell' );
-
-
foreach( $cells as $cell )
-
-
{
-
-
$ind = $cell->getAttribute( 'Index' );
-
-
if ( $ind != null ) $index = $ind;
-
-
-
if ( $index == 2 ) $type = $cell->nodeValue;
-
-
if ( $index == 3 ) $question = $cell->nodeValue;
-
-
if ( $index == 4 ) $choice1 = $cell->nodeValue;
-
-
if ( $index == 5 ) $choice2 = $cell->nodeValue;
-
-
if ( $index == 6 ) $choice3 = $cell->nodeValue;
-
-
if ( $index == 7 ) $choice4 = $cell->nodeValue;
-
-
if ( $index == 8 ) $answer = $cell->nodeValue;
-
-
-
-
$index += 1;
-
-
}
-
-
add_person( $type, $question, $choice1, $choice2, $choice3, $choice4, $answer );
-
-
}
-
-
$first_row = false;
-
-
}
-
-
}
-
}
-
}
-
-
?>
-
Any help will be greatly appreciated..
1 1335
If the check has already been made, add the confirmation when the user submits.
If you're making the database check after the page load, but want to display the confirmation before the page is submitted, you'll need to make an Ajax request.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: laurie |
last post by:
Hi all,
I'm trying to help out a friend who has inherited a client with a PHP
shopping cart application. Neither of us know PHP, but I've been
muddling my way through, trying to get these old...
|
by: Fred |
last post by:
Hi.
How does one display a confirmation message of either 'Record Updated' or
'Recorded Added"?
I've tried the form afterupdate and afterinsert but the afterupdate occurs
on an insert too?
So...
|
by: Brandon Mackie |
last post by:
I am incredibly new to access and trying to learn as I go. I have set up a
few queries one of which is executed by a docmd.runsql in visual basic.
Because it is an update query it asks for...
|
by: Stephen |
last post by:
Hello People,
Using MS Access 2003 VBA I get the error 3020 Update or CancelUpdate
without AddNew or Edit when I run through the following code. Can
anyone help suggest anything to try? Thanks....
|
by: Marc Robitaille |
last post by:
Hello,
I use a server side button to delete or update data in my database. To have
a confirmation from the user I use this code that I have found here.
cmdOk.Attributes.Add("OnClick", "return...
|
by: irene |
last post by:
Hi, I am trying to update the checkbox value in a datagrid. I am using
TemplateColumn to add the checkbox to the datagrid and it is showing
correct data from the database now. Ideally, the end user...
|
by: Elton W |
last post by:
Hi Peter,
You use
DeleteButton.Attributes.Add("onclick", "return confirm
('Are you sure you want to delete?');");
in datagrid_ItemDataBound event to add confirmation for
delete button.
|
by: Simon Rigby |
last post by:
Hi all,
I was of the impression that setting the DefaultMode property of a
FormView would force the EditMode back to the defaut mode after
clicking update or cancel. However, the FormView stays...
|
by: rsht |
last post by:
I am new to the ASP.Net and need some helps.
In ASP, page one can have a button event "confirm()" to pop-up a yes
or no window:
<form ... action="page2" >
....
<input onClick="confirm();">...
|
by: beemomo |
last post by:
Hi everyone. I used the BeforeUpdate event procedure to display a confirmation prompt and handle a user's response to either cancel or continue with the save as described in MSDN:
Private Sub...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |