enemeth Posted April 12, 2007 Share Posted April 12, 2007 I dont no if this is considered a PHP issue or a JAVA issue but on my site i have pop up boxes to notify people if they do not enter certain information in the fields, etc... and it works great on checkuser.php , but i created the forgot password page , which is a whole other story ! ugh! put the exact code from the checkuser.php file to the new file , and i mean i checked it with a fine tooth comb!! to make sure it was exact ! and it works and all the pop up box comes up ! lovely! but with no words in it LOL i dont no what it is ! and variables are set for what the popup box should say! its flawless ! is there a known issue about the words not showing up on the pop up boxes sometimes, cause i go back to the other pages that have them and see the message just fine! so i no it isnt my browser! Help ! Thanks , Elaine Quote Link to comment https://forums.phpfreaks.com/topic/46673-solved-pop-up-boxes/ Share on other sites More sharing options...
Glyde Posted April 12, 2007 Share Posted April 12, 2007 1) Stop with the exclamation marks, it's a little overbearing. 2) Post this in the JavaScript forum. 3) We'll need to see your HTML output and JS source to be able to give you real help. Quote Link to comment https://forums.phpfreaks.com/topic/46673-solved-pop-up-boxes/#findComment-227383 Share on other sites More sharing options...
Psycho Posted April 12, 2007 Share Posted April 12, 2007 the pop up box comes up ... but with no words in it variables are set for what the popup box should say Yes, this does belong in the JavaScript forum. But, sounds like it could be an issue of variable scope to me. Would need to see the code though. Quote Link to comment https://forums.phpfreaks.com/topic/46673-solved-pop-up-boxes/#findComment-227389 Share on other sites More sharing options...
mmarif4u Posted April 12, 2007 Share Posted April 12, 2007 It seems to be a javascript q but if u r using it with php variable to echo then ok. By my self i am using this pop boxes for errors. Quote Link to comment https://forums.phpfreaks.com/topic/46673-solved-pop-up-boxes/#findComment-227400 Share on other sites More sharing options...
enemeth Posted April 12, 2007 Author Share Posted April 12, 2007 here is the code <?php include 'db.php'; $msg = "You forgot to enter your Email address"; $msga = "No records found matching your email address"; $msgb = "Your password has been sent! Please check your email!"; switch($_POST['recover']){ default: include 'lostpsw.php'; break; case "recover": recover_pw($_POST['email_address']); break; } function makeRandomPassword() { $salt = "abchefghjkmnpqrstuvwxyz0123456789"; srand((double)microtime()*1000000); $i = 0; while ($i <= 7) { $num = rand() % 33; $tmp = substr($salt, $num, 1); $pass = $pass . $tmp; $i++; } return $pass; } function recover_pw($email_address){ if(!$email_address){ echo "<script langauge=\"javascript\">alert(\"".$msg."\");</script>"; include 'lostpsw.php'; exit(); } $sql_check = mysql_query("SELECT * FROM users WHERE email_address='$email_address'"); $sql_check_num = mysql_num_rows($sql_check); if($sql_check_num == 0){ echo "<script langauge=\"javascript\">alert(\"".$msga."\");</script>"; include 'lostpsw.php'; exit(); } $random_password = makeRandomPassword(); $db_password = md5($random_password); $sql = mysql_query("UPDATE users SET password='$db_password' WHERE email_address='$email_address'"); $subject = "Your Password at The Truth Discovered!"; $message = "Hi, we have reset your password. New Password: $random_password http://www.thetruthdiscovered.com/login.php Thanks! The Webmaster This is an automated response, please do not reply!"; mail($email_address, $subject, $message, "From: The Truth Discovered Webmaster<[email protected]>\n X-Mailer: PHP/" . phpversion()); echo "<script langauge=\"javascript\">alert(\"".$msgb."\");</script>"; include 'login.php'; } ?> and let me remind you , this is EXACTLY how it is used on one of my other pages , on the same site , and it works fine Elaine Quote Link to comment https://forums.phpfreaks.com/topic/46673-solved-pop-up-boxes/#findComment-227505 Share on other sites More sharing options...
enemeth Posted April 12, 2007 Author Share Posted April 12, 2007 and are the exclamation marks REALLY that overbearing LOL !! come on now , just need some help on the pop up Elaine Quote Link to comment https://forums.phpfreaks.com/topic/46673-solved-pop-up-boxes/#findComment-227519 Share on other sites More sharing options...
Psycho Posted April 12, 2007 Share Posted April 12, 2007 Well, I can't see the code on the pages where it's working, but the reason it is not working here is exactly what I stated above: variable scope. A given variable used outside a function and inside a function are two different entities unless you define the variable to have global scope. You need to either pass the message variables to the functions using them or define the variables as global inside the functions. However, you are only using those mesasge variables once. So, I see no reason to even create variables. Why not just put the error messages directly where they are used? Here are some examples of the issues of variable scope and how to overcome: <?php $val = 1; function echoVal() { echo $val } echoVal(); //Output -nothing- // This will produce NO output because // $val has no value inside the function ?> <?php $val = 1; function echoVal() { global $val; echo $val } echoVal(); //Output 1 // This WILL display 1 because $val has been // defined to have the same value it does globally ?> <?php $val = 1; function echoVal($val) { echo $val $val = $val + 1; } echoVal($val); //Output 1 echo $val; //Output 1 // This will first display 1 because the $val variable // is being passed to the function. But then it will // output 1 again because $val inside the function and // $val outside the function are two different entities ?> Quote Link to comment https://forums.phpfreaks.com/topic/46673-solved-pop-up-boxes/#findComment-227745 Share on other sites More sharing options...
enemeth Posted April 12, 2007 Author Share Posted April 12, 2007 yup i got it , working great now Thank you Elaine Quote Link to comment https://forums.phpfreaks.com/topic/46673-solved-pop-up-boxes/#findComment-227845 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.