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
https://forums.phpfreaks.com/topic/65286-solved-can-someone-see-a-dumb-mistake/
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());
} ?>

 

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!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.