Pop up With PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
enemeth
Forum Commoner
Posts: 66
Joined: Tue Mar 27, 2007 8:55 am

Pop up With PHP

Post by enemeth »

I dont no if this is considered a PHP issue or a JAVA issue but it is $msg function so im thinking PHP

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

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

heres the code for it :

Code: Select all

<?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(\"".$msga."\");</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<admin@thetruthdiscovered.com>\n 
        X-Mailer: PHP/" . phpversion()); 
    echo "<script langauge=\"javascript\">alert(\"".$msgb."\");</script>"; 
    include 'login.php'; 
} 
?>
you can go and look at what it does on http://www.thetruthdiscovered.com/lostpw.php

if you hit get password without putting an email it pops a box up but there is nothing in the box , but on the other hand , you go to
http://www.thetruthdiscovered.com/login.php hit the button to log in and a pop up box comes up and tells you to put in ALL the information, now the code is the exact way in both pages, i dont get it

Thanks for the help :)

Elaine
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You have a scope issue. It would also suggest you have PHP set to not display E_NOTICE level errors.

http://php.net/language.variables.scope
enemeth
Forum Commoner
Posts: 66
Joined: Tue Mar 27, 2007 8:55 am

Post by enemeth »

you are completely right !

it worked i placed it with the echo and it worked ! thanks a million :)

Elaine
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Also,

Javascript != Java
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply