Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP page appears completely blank.
Old 08-24-2007, 12:24 PM PHP page appears completely blank.
Extreme Talker

Posts: 170
Location: Canada
Trades: 0
I'm designing a password reset screen for users using my system and everything was going great until all of a sudden the browser page went blank.

I eventually worked out that my if statement is the problem, but for some reason it's blocking ALL the code on the page. Nothing renders in the browser window as long as I include this if statement no code, no text, no source whatsoever it just ceases to be.

I searched through the whole page many times and cannot see any errors.

PHP Code:
<?php
if($_POST["email"]) {
    
$email $_POST["email"];
    
$newpassword randompass();
    
    function 
randompass() {
        
$count 1;
        
$chars "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPRQSTUVWXYZ0123456789";
        
$totalchars strlen($chars)-1;
        do {
            
$randomnum mt_rand(0,$totalchars);
            
$randomchar substr($chars, -$randomnum1)
            
$newpass $newpass
            $count 
$count+1;
        } while (
$count 10);
        
        return 
$newpass;
    }
    
    include(
"includes/connection.php");
    
$query "UPDATE user SET password='$newpassword' WHERE email='$email'";
    
$table mysql_query($query$connection) or die(header('Location: index.php?error=mysql'));
    
$row mysql_fetch_assoc($table);
}

$title "Password Recovery";
include(
"includes/header.php");

?>
<form action="user_reset.php" method="post">
<fieldset>
    <label for="email">Email:</label><input type="text" name="email" id="email" maxlength="50" size="30" />&emsp;
    <label>&nbsp;</label><input type="submit" value="Reset My Password" /></p>
</fieldset>
</form>

<?php include("includes/footer.php"); ?>
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE

Last edited by collyer_1; 08-24-2007 at 12:38 PM..
collyer_1 is offline
Reply With Quote
View Public Profile Visit collyer_1's homepage!
 
 
Register now for full access!
Old 08-24-2007, 12:32 PM Re: PHP page appears completely blank.
Extreme Talker

Posts: 182
Trades: 0
Whoa, Nellie!

What is this?
PHP Code:
    echo = $totalchars;
    echo = 
$newpass
Try taking out those equal signs and get back to me.
bhgchris is offline
Reply With Quote
View Public Profile
 
Old 08-24-2007, 12:34 PM Re: PHP page appears completely blank.
Extreme Talker

Posts: 182
Trades: 0
wait, wait, wait...I posted that w/o looking too close.

What are those lines even for? Just delete them.
bhgchris is offline
Reply With Quote
View Public Profile
 
Old 08-24-2007, 12:38 PM Re: PHP page appears completely blank.
Extreme Talker

Posts: 170
Location: Canada
Trades: 0
The equal signs were me being metal for a minute there.
The lines were me testing variables before the whole thing broke. I just forgot to remove them.

My problem still persists, the page is blank.
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE

Last edited by collyer_1; 08-24-2007 at 12:51 PM..
collyer_1 is offline
Reply With Quote
View Public Profile Visit collyer_1's homepage!
 
Old 08-24-2007, 01:26 PM Re: PHP page appears completely blank.
Extreme Talker

Posts: 182
Trades: 0
My first thought would be to perhaps comment out the mysql code and see what happens.

PHP Code:
/*
    include("includes/connection.php");
    $query = "UPDATE user SET password='$newpassword' WHERE email='$email'";
    $table = mysql_query($query, $connection) or die(header('Location: index.php?error=mysql'));
    $row = mysql_fetch_assoc($table);
*/ 
If your page works after you comment that stuff out, I would say there may be a problem in your connection.php.....maybe?

If not, narrow it down to the problem line of code inside the if statement.

Also, you can really eliminate the entire randompass function by replacing it with something like this:
PHP Code:
$length     10// length of password to generate
$password substrmd5 uniqid microtime ( ) ) ), 0$length ); 
There are many ways to generate a random password, this is the method I use.

On a side note, the $newpass and $totalchars variables should be local to the randompass() function. Meaning, after the function is finished, those variables no longer exist. Just figured I would not that because you were trying to echo them outside of the function.
bhgchris is offline
Reply With Quote
View Public Profile
 
Old 08-24-2007, 02:19 PM Re: PHP page appears completely blank.
Ultra Talker

Posts: 483
Trades: 0
I'd add:
error_reporting( E_ALL );

as your absolute first line of PHP and see if that shows up anything...
__________________

Please login or register to view this content. Registration is FREE
TwistMyArm is offline
Reply With Quote
View Public Profile
 
Old 08-24-2007, 02:29 PM Re: PHP page appears completely blank.
Extreme Talker

Posts: 170
Location: Canada
Trades: 0
It appears my function is to blame for the errors... I'm going to replace it with something different. Thanks very much for your help, I really do appreciate it.
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
collyer_1 is offline
Reply With Quote
View Public Profile Visit collyer_1's homepage!
 
Old 08-24-2007, 04:25 PM Re: PHP page appears completely blank.
shivaji's Avatar
Ultra Talker

Posts: 321
Trades: 0
Did you solve this problem. If you don't, I think this two lines missed ; on the end.
Quote:
$randomchar = substr($chars, -$randomnum, 1)
$newpass = $newpass
Shivaji
__________________

Please login or register to view this content. Registration is FREE
- uncommon free scripts

Please login or register to view this content. Registration is FREE
- Städte, Sport, Party, Gourment, Apartments, Hotels
shivaji is offline
Reply With Quote
View Public Profile Visit shivaji's homepage!
 
Old 08-24-2007, 04:28 PM Re: PHP page appears completely blank.
Extreme Talker

Posts: 170
Location: Canada
Trades: 0
Once the function was removed and the semi colons were repaired the page loaded properly. I was just rushing through my code and got sloppy.

Thanks very much for all your input.
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
collyer_1 is offline
Reply With Quote
View Public Profile Visit collyer_1's homepage!
 
Old 08-25-2007, 08:34 AM Re: PHP page appears completely blank.
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Always the problem with coding, you can right something and it dont work and you never spot the mistake, and as far as your concerd its the best way to code it

and then someone looks and goes thats wrong so is that, and u would be beeter doing it like this
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to PHP page appears completely blank.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.38832 seconds with 12 queries