Jump to content

[SOLVED] Can someone see a dumb mistake?


piznac

Recommended Posts

OK,.. I have this:

<?php function del_art($path,$num){
	echo "<script language=\"JavaScript\">var answer = confirm(\"Are you sure you want to delete this file?\");if (answer){alert(\"File will now be deleted\");set = 1;}else{set = 0;}</script>";

	$set = "<script language=\"JavaScript\"> document.write(set) </script>";
	echo $set;
	if($set != "0"){
	//get just the file name
	$filename = explode("/", $path);
	//delete the file
	$do = unlink("/var/www/html/logo/$filename[4]"); 
	//delete the file from db records
	$del_art_query = "DELETE FROM `or_logo` WHERE `path` = '$path' AND `num` = '$num'";
	$del_art = mysql_query($del_art_query) or die ("del query error:" . mysql_error());
} ?>

 

Now you will see that I threw some JS in there,.. this is for a confirm box. Now the $set variable is working. I echo it and it does change depending on which choice I make at confirm box. But no matter what $set is set to ,.. 0 or 1. It still preforms the rest of the function. Im a bit confused here,.. stupid mistake? Here is where Im calling it:

 

<?php case "delart";
$path = mysql_real_escape_string(trim(stripslashes($_GET['path']))); 
$num = mysql_real_escape_string(trim(stripslashes($_GET['num'])));
require_once("my path");
$this = new Confirm();
$this->del_art($path,$num);
$this->dis_order($num);
break; ?>

 

Anyone have any ideas?

Link to comment
Share on other sites

<?php function del_art($path,$num){
	echo "<script language=\"JavaScript\">var answer = confirm(\"Are you sure you want to delete this file?\");if (answer){alert(\"File will now be deleted\");set = 1;}else{set = 0;}</script>";

	$set = "<script language=\"JavaScript\"> document.write(set) </script>";
	echo $set;
	if($set != "0"){
	//get just the file name
	$filename = explode("/", $path);
	//delete the file
	$do = unlink("/var/www/html/logo/$filename[4]"); 
	//delete the file from db records
	$del_art_query = "DELETE FROM `or_logo` WHERE `path` = '$path' AND `num` = '$num'";
	$del_art = mysql_query($del_art_query) or die ("del query error:" . mysql_error());
} ?>

 

Link to comment
Share on other sites

AHHHHH HA ;D

 

note: Im one of those guys who is hardheaded,..LOL

 

But I figure out a way to do it,.. if I simply pass the php vars into the function,.. in a link it works:

 

<a href=\"javascript:confirmation($nums,'$paths')\" border=\"0\">

 

<script type="text/javascript">
<!--
function confirmation(num,path) {
var answer = confirm("Are you sure you want to delete this artwork?")
if (answer){
	alert("Entry Deleted")
	window.location = "confirm.php?action=delart&path="+path+"&num="+num;
}
else{
	alert("No action taken")
}
}
//-->
</script>

 

Thanks for the help guys!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.