javascript not returning?
the javascript function isn't bringing up a confirm dialogue. it's just going ahead as if it's been confirmed. i think i did something wrong but i'm not sure what. php rendeirng page:
<?php
function misc(){ # misc controls
include(\"/home/joshua/includes/fyd.altincs.php\"); # includes file (precautionary measure)
$un=$_COOKIE['un']; $pw=$_COOKIE['pw']; # variables to talk to the db
$db=mysql_connect($host, $login3, $pass3) or die(\"cannot access mysql\");
# connect to the db
$fyd=mysql_select_db('findyourdesire', $db) or die(\"cannot access db\");
# get the db
$memfind=mysql_query(\"SELECT uid FROM users WHERE username='$un'
AND password='$pw'\", $db);
if(mysql_num_rows($memfind)==0){ # problem
echo '<h1>We cannot find you. Are you sure you <a href=\\"join.php\\">Joined?</a>';
}else{ # we found the user
$maininf=mysql_fetch_array($memfind); $uid=$maininf['uid']; $result=''; $worked=0;
if(isset($_POST['act'])&&($_POST['act']=='reset')){ # reset the votes on the user
$rstat=mysql_query(\"UPDATE stats SET pvt='0', pvc='0' WHERE uid='$uid'\", $db);
if(mysql_affected_rows($db)>'-1'){ $worked=1; } // did stats get reset
else{ // there was a problem
$errno=mysql_errno($db); $error=mysql_error($db); $result=\"<br />stats:$errno:
$error\";
} // error has been recorded
$rvote=mysql_query(\"DELETE FROM votes WHERE voteeuid='$uid'\", $db);
if((mysql_affected_rows($db)>'-1')&&($worked)){ $result=\"Your desirability has
been reset.\"; }
else{ // there was a problem
$errno=mysql_errno($db); $error=mysql_error($db); $result.=\"<br />votes:
$errno: $error\";
} // error has been recorded
}elseif(isset($_POST['act'])&&($_POST['act']=='delete')){ // deleting your profile
echo \" <p>Deleting $un...\n\"; $imgbase=$faup; $npib=$fuup;
foreach($images as $key=>$value){ # for each possible picture
echo \" <br />Checking for $value\n\"; flush(); $pica=$imgbase.$key.$un.
'.jpg';
$picb=$imgbase.'old.'.$key.$un.'.jpg'; $picc=$npib.$key.$un.'.jpg';
/* delete the pics if they exist */
if(is_file($pica)){ unlink($pica); echo \" <br />Removing $pica\n\"; }
if(is_file($picb)){ unlink($picb); echo \" <br />Removing $picb\n\"; }
if(is_file($picc)){ unlink($picc); echo \" <br />Removing $picc\n\"; }
}
echo \" <br />Deleting you from table BIO\"; flush();
$dfs=mysql_query(\"DELETE FROM bio WHERE uid='$uid'\", $db);
if(mysql_affected_rows($db)==1){ // successful deletion
echo \" <br />Removed $un (user # $uid) from table BIO\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db); $delerr=1;
$result.=\"<br />Bio:$errno: $error\";
}
echo \" <br />Deleting you from table COMMENTS\"; flush();
$dfs=mysql_query(\"DELETE FROM comments WHERE uid='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table COMMENTS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
$result.=\"<br />Comments:$errno: $error\";
}
echo \" <br />Deleting you from table FRIENDS\"; flush();
$dfs=mysql_query(\"DELETE FROM friends WHERE uid='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table FRIENDS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
$result.=\"<br />Friends:$errno: $error\";
}
echo \" <br />Deleting you from table INTERESTS\"; flush();
$dfs=mysql_query(\"DELETE FROM interests WHERE uid='$uid\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table INTERESTS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db); $delerr=1;
$result.=\"<br />Interests:$errno: $error\";
}
echo \" <br />Deleting you from table MAIL\"; flush();
$dfs=mysql_query(\"DELETE FROM mail WHERE to_id='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table MAIL\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
$result.=\"<br />Mail:$errno: $error\";
}
echo \" <br />Deleting you from table MSGS\"; flush();
$dfs=mysql_query(\"DELETE FROM msgs WHERE to_id='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table MSGS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
$result.=\"<br />Msgs:$errno: $error\";
}
echo \" <br />Deleting you from table PESTS\"; flush();
$dfs=mysql_query(\"DELETE FROM pests WHERE uid='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table POSTS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
$result.=\"<br />Posts:$errno: $error\";
}
echo \" <br />Deleting you from table POSTS\"; flush();
$dfs=mysql_query(\"DELETE FROM posts WHERE author='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table POSTS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
$result.=\"<br />Posts:$errno: $error\";
}
echo \" <br />Deleting you from table STATS\"; flush();
$dfs=mysql_query(\"DELETE FROM stats WHERE uid='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table STATS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db); $delerr=1;
$result.=\"<br />Stats:$errno: $error\";
}
echo \" <br />Deleting you from table THREADS\"; flush();
$dfs=mysql_query(\"DELETE FROM threads WHERE thread_auth='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table THREADS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
$result.=\"<br />Threads:$errno: $error\";
}
echo \" <br />Deleting you from table TOPS\"; flush();
$dfs=mysql_query(\"DELETE FROM tops WHERE memuid='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table TOPS\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
$result.=\"<br />Tops:$errno: $error\";
}
echo \" <br />Deleting you from table VOTES\"; flush();
$dfs=mysql_query(\"DELETE FROM votes WHERE voteeuid='$uid'\", $db); // votes on
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table VOTES\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
$result.=\"<br />Votes:$errno: $error\";
}
$dfs=mysql_query(\"DELETE FROM votes WHERE voteruid='$uid'\", $db);
// votes made this time period
if(mysql_affected_rows($db)==1){
echo \" <br />Removed $un (user # $uid) from table VOTES\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db);
$result.=\"<br />Votes:$errno: $error\";
}
$result.='</p>';
if(!($delerr)){ # stats,bio,interests did not result in an error
(may be expanded to more)
echo \" <br />Deleting you from table USERS\";
$dfs=mysql_query(\"DELETE FROM users WHERE uid='$uid'\", $db);
if(mysql_affected_rows($db)==1){
echo \" <br />Deletion complete.</p>\n$errs\";
}else{ // error
$errno=mysql_errno($db); $error=mysql_error($db); $delerr=1;
echo \"<br />Users:$errno: $error</p>\n$errs\";
}
}else{ // something is wrong
echo \" <br />Deletion encountered errors. uid=$uid username=$un\";
echo \" </p>\n$errs\";
}
}
// make the page
echo <<<END
<p>$result</p>
<h2>NOTICE: THE FOLLOWING OPTIONS <b>CANNOT</b> BE UNDONE</h2>
<script language=\"javascript\">
function doubleCheck(){
var what=document.misc.act.value;
if(what==\"reset\"){
confirm(\"Are you sure you want to reset your score?\");
}elseif(what==\"delete\"){
confirm(\"Are you sure you want to delete your account?
(This cannot be undone)\");
}else{
return FALSE;
}
}
</script>
<form action=\"{$_SERVER['PHP_SELF']}\" name=\"misc\" method=\"POST\"
onSubmit=\"return doubleCheck();\">
<input type=\"hidden\" name=\"fn\" value=\"misc\">
$tsnw
<tr>
<td align=\"center\">
<select name=\"act\" size=\"1\">
<option value=\"\">Choose an Option</option>
<option value=\"reset\">Reset Your Score</option>
<option value=\"delete\">Delete Your Profile</option>
</select>
</td>
</tr>
<tr>
<td align=\"center\"><input type=\"submit\" value=\"Let's Do It!\"></td>
</tr>
</table>
</form>
END;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>FindYourDesire.com -- Control Panel Subpage for neo</title>
<meta name="Author" content="Pages coded by Josh Perlmutter for Desired
Creations LLC">
<meta name="Author" content="Graphics created by ? for Desired Creations LLC">
<meta name="Author" content="Smileys created by Amber Beausoleil for
Desired Creations LLC">
<style type="text/css">
a {text-decoration:none}
</style> </head>
<body bgcolor="#878787" text="#ffffff" alink="#950c0c" vlink="#3347c5"
link="#000000">
<center> <p>Your desirability has been reset.</p>
<h2>NOTICE: THE FOLLOWING OPTIONS <b>CANNOT</b> BE UNDONE</h2>
<script language="javascript">
function doubleCheck(){
var what=document.misc.act.value;
if(what=="reset"){
confirm("Are you sure you want to reset your score?");
}elseif(what=="delete"){
confirm("Are you sure you want to delete your account? (This cannot
be undone)");
}else{
return FALSE;
}
}
</script>
<form action="/findyourdesire/control.php" name="misc" method="POST"
onSubmit="return doubleCheck();">
<input type="hidden" name="fn" value="misc">
<table frame="void" bgcolor="#878787" border="0" cellpadding="0"
cellspacing="0" text="#ffffff">
<tr>
<td align="center">
<select name="act" size="1">
<option value="">Choose an Option</option>
<option value="reset">Reset Your Score</option>
<option value="delete">Delete Your Profile</option>
</select>
</td>
</tr>
<tr>
<td align="center"><input type="submit" value="Let's Do It!"></td>
</tr>
</table>
</form>
<font size="-2">
<p>Pages coded by Josh Perlmutter for Desired Creations LLC
<br />Graphics created by ? for Desired Creations LLC
<br />Smileys created by Amber Beausoleil for Desired Creations LLC
<br />All creations copyrighted by their respective Creators. Reproduction
Requires Consent of the Creator and Desired Creations LLC.
</p>
</font>
</center>
</body>
</html>
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
wheaties_box posted this at 14:34 — 16th September 2003.
They have: 20 posts
Joined: Sep 2003
ehh... that's a lot of code to just rummage through, but I think you may just need to put a return in front of your confirms... That way the function will actually return true if the user hits OK or false if the user hits cancel.
tell us how it works out
Cold.....so..cold!!!
m3rajk posted this at 18:20 — 16th September 2003.
They have: 461 posts
Joined: Jul 2003
heh. i'll try that if it doesn't work after this fix pointed out at the oter forum that's proven useful:
Regards,
Scorphus.
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
m3rajk posted this at 18:27 — 16th September 2003.
They have: 461 posts
Joined: Jul 2003
well. with scorphus' fix it gives the dialogue and ignores it.
with wheaties_box's addition it works perfectly. apparently i needed both fixes
thank you wheaties_box
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
wheaties_box posted this at 20:30 — 16th September 2003.
They have: 20 posts
Joined: Sep 2003
no problemo. I also noticed the FALSE, but I wasn't sure if it was in fact case sensitive.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.