0

hello.i need help form you all. i am beginner in php and my english is not good..
my problem is when the pop up message proceed delete, although i click cancel. my data is delete ? this is my coding

<?php session_start(); 

$noC = $_REQUEST['noC'];      
include("db_connect.php");    
mysql_select_db($database_localhost, $conn)or trigger_error(mysql_error(),E_USER_ERROR);

$sql="DELETE FROM cek1a WHERE noC='".$noC."'";  

mysql_select_db($database_localhost, $conn);
                    $Result1 = mysql_query($sql, $conn);
                    if($Result1){
                        echo "<script>confirm('proced delete?')</script>";    
                        echo '<META HTTP-EQUIV="Refresh" CONTENT="0.01; URL=p1f3(delete).php">';
                    }
                    else  
                        echo "<script>alert('Sorry, the data you entered was failed to save.')</script>";
?>

i hope you all can help me.. thank you

Edited by Dani: Formatting fixed

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by lalaka90
0

seem to be your beginner in PHP and html, please try AJAX for it.

Java-script is Client Side Language.


Following code always delete your row without ask permission or processed.

$sql="DELETE FROM cek1a WHERE noC='".$noC."'";

mysql_select_db($database_localhost, $conn);
$Result1 = mysql_query($sql, $conn);
if($Result1){
echo "<script>confirm('proced delete?')</script>";
echo '<META HTTP-EQUIV="Refresh" CONTENT="0.01; URL=p1f3(delete).php">';
}
else
echo "<script>alert('Sorry, the data you entered was failed to save.')</script>";

0

thank you for you advise.I appreciate it. but is there are other ways to solve it in php?
your cooperation is greatly appreciated

0

problem is that following logic is Client Side ..

mysql_select_db($database_localhost, $conn);
$Result1 = mysql_query($sql, $conn);
if($Result1){
echo "<script>confirm('proced delete?')</script>";
echo '<META HTTP-EQUIV="Refresh" CONTENT="0.01; URL=p1f3(delete).php">';
}
else
echo "<script>alert('Sorry, the data you entered was failed to save.')</script>";


you have to make java-script function and confirm box on link where Delete button is placed.

for example :

<script>
function showpoup('ab){
//bla bla alert script of javascript , when user click on true; return to windows.location = "delete.php?id="+.ab.+";
}
</script>


<a onclick="showpoup('23');">Delete Record</a>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.