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
While running this script it cuts out with an "else" ???
Old 01-29-2012, 03:35 PM While running this script it cuts out with an "else" ???
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
Hi,
the code below is live at:
www.activityx.co.uk/dynamic/activate.php

a URL you can use to see a live example is:
http://www.activityx.co.uk/dynamic/a....php?u=1&key=d

It is an activation script for when a user signs up, if they use the wrong code they are able to input their email address again and a new code will be sent out.
The problem I am having is, when they input the incorrect email, it displays the correct message BUT if they input the correct email, it times out??

You can use email: tom@activityx.co.uk

Thanks

PHP Code:
<?php
                     $emailSQL 
"SELECT * FROM `table` WHERE `email` = '$email'";
                        while(
$row mysql_fetch_array($database->getData($emailSQL))) {
                              
$id $row['id'];  
                        }
                     
                     if(
$database->numRows($emailSQL) != 1) {
                        
                        print 
"<h1>Invalid E-Mail Address</h1>";
                        print 
"<p>There seems to be an error in the information you have posted.</p>";
                        print 
"<p>Please request a new activation link by typing your email below.</p>";

            
?>
                <form action="activate.php" method="post">
                    <input type="text" name="email" class="email" onclick="this.value='';" onblur="this.value=!this.value?'<?php print $email?>':this.value;" value="<?php print $email?>" /> 
                    <input type="submit" value="Send Activation Code" name="new-code" class="submit" />
                </form>
        <?php
                                
                     
} else {
                                            
                    
$curDir dirname($_SERVER['PHP_SELF']);
                    
$curLoc $_SERVER['SERVER_NAME'];
                    
                    
$url $curLoc;
                    
$url .= $curDir;
                    
                    
$key generateRandomString(20);
                                                           
                    
$activationLinkText "<a href='http://www.$url/activate.php?u=$lastID&key=$key'>activation link</a>";
                    
$activationLink "http://www.$url/activate.php?u=$lastID&key=$key";
                                             
                      
$fromEmail "accounts@activityx.co.uk";
                      
$headers "MIME-Version: 1.0" "\r\n";
                      
$headers .= "Content-type:text/html;charset=iso-8859-1" "\r\n";
                        
                      
// More headers
                      
$headers .= "From: Activity X<$fromEmail>\r\n";
                      
$headers .= "Reply-To: $fromEmail\r\n";
                        
                        
                           
// send the email
                    
                    
print "<p class='main_text' style='text-align:left;'>We have sent a new confirmation e-mail to the address that you supplied (<strong>$email</strong>).</p>";
                    print 
"<p class='main_text' style='text-align:left;'>Please follow the link in the e-mail to activate your account.";
                    
                        

    } 
// end else
feraira is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-29-2012, 04:02 PM Re: While running this script it cuts out with an "else" ???
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
I don't see anything in the code that would cause the script to time out. The only function call in that else block is generateRandomString. Can you post the code for that function?

Also, this isn't technically causing a problem, but it looks like you are executing the same query twice here:

PHP Code:

                     $emailSQL 
"SELECT * FROM `table` WHERE `email` = '$email'";
                        while(
$row mysql_fetch_array($database->getData($emailSQL))) {
                              
$id $row['id'];  
                        }
                     
                     if(
$database->numRows($emailSQL) != 1) { 
Once the get the result then again to count the rows. This is a better approach:

PHP Code:

                     $emailSQL 
"SELECT * FROM `table` WHERE `email` = '$email'";
                        if(
$row mysql_fetch_array($database->getData($emailSQL))) {
                              
$id $row['id'];  
                        }
                     
                     if(!isset(
$id)) { 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 01-29-2012, 04:47 PM Re: While running this script it cuts out with an "else" ???
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
Cool, thanks for that. Can you get the script to run correctly in your browser? I still can't figure out what the problem is.
feraira is offline
Reply With Quote
View Public Profile
 
Old 01-29-2012, 05:31 PM Re: While running this script it cuts out with an "else" ???
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
PHP is server side code. The issue has nothing to do with what browser is sending the request.

As I pointed out before, I don't see anything in that else block that can cause a timeout, unless there is something in the generateRandomString. Can you post that code?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Reply     « Reply to While running this script it cuts out with an "else" ???
 

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.14205 seconds with 12 queries