$20 PayPal For Code Fix

Discussion in 'Programming' started by WPPJames, Sep 16, 2009.

  1. #1
    I'll pay $20 via PayPal to anyone that can provide a fix for this:

    I have a website, www.prizetoad.com. I'm getting quite a few reports by members of the inability to login to their members area. The login page is at http://www.prizetoad.com/login.php. What seems to be happening is that after entering their Username and Password, then clicking the "Log Me In" button, the login.php page just refreshes/reloads with the Username and Password fields now empty. This appears to be browser specific, although I can't tell you exactly what all browsers have problems. Might be a combination of the browser and sessions/cookies in my code? User might have cookies turned off? Not really sure. Just need it to work for all users. Anyone wishing to test themselves can login with test account / buckydent.

    Login.php code is shown below:

    
    <?php
    include('config.php');
    
    //Checks if there is a login cookie
    if(isset($_COOKIE['ID_my_site']))
    
    //if there is, it logs you in and directes you to the members page
    {
      $username = $_COOKIE['ID_my_site'];
      $pass = $_COOKIE['Key_my_site'];
      $check = mysql_query("SELECT * FROM prize_members WHERE uUserEmail = '$username'")or die(mysql_error());
      while($info = mysql_fetch_array( $check ))
        {
          if ($pass != $info['uPassword'])
          {
          }
          else
          {
          header("Location:http://www.prizetoad.com/ members.php");
          }
        }
    }
    
    //if the login form is submitted
    if (isset($_POST['submit']) || isset($_POST['submit_x']))
    { 
        // checks if the useremail exists
        if (!get_magic_quotes_gpc())
         {
            $_POST['useremail'] = addslashes($_POST['useremail']);
         }
        //Gives error if user dosen't exist
        $usercheck = $_POST['useremail'];
        $check = mysql_query("SELECT * FROM prize_members WHERE uUserEmail = '$usercheck'") or die(mysql_error());
        $check2 = mysql_num_rows($check);
        if ($check2 == 0)
        {
           $error_msg = "That Username does not exist in our database. Your Username is the email address you registered with.";
        }
    
        while($info = mysql_fetch_array( $check ))
        {
           $_POST['pass'] = stripslashes($_POST['pass']);
           $info['uPassword'] = stripslashes($info['uPassword']);
           $_POST['pass'] = md5($_POST['pass']);
           //gives error if the password is wrong
           if ($_POST['pass'] != $info['uPassword'])
            {
               $error_msg = "Incorrect password, please try again.";
            }
        }
        
        // if login is ok then we add a cookie
        if ($error_msg == "")
        {
           $_POST['useremail'] = stripslashes($_POST['useremail']);
           $hour = time() + 3600;
           setcookie(ID_my_site, $_POST['useremail'], $hour);
           setcookie(Key_my_site, $_POST['pass'], $hour);
           //set Last_Login field
           $res = mysql_query("UPDATE prize_members SET Last_Login = NOW() WHERE uUserEmail = '$usercheck'");
           //then redirect them to the members area
           header("Location:http://www.prizetoad.com/members.php");
        }
        else
        {
        }
    }
    ?>
    
    <?php include('header.php'); ?>
    	<div class="body">
    		<div class="content">
    			<div class="content_top" align="center">
    			<strong><br /><br />
    			<span class="style2">MEMBER LOGIN</span><br /></strong>
    			</div>
    			<div class="content_middle" align="center">
    				<div class="content_middle_text_privacy">
    				<br />
    				Not a member yet? - <a href="index.php" style="text-decoration: none;">Click Here To Register</a>
    				<div class="error" align="center"><font color="#ff0000"><?php echo "$error_msg"; ?></font></div>
    				<form name="registrationform" action="<?php echo $_SERVER['PHP_SELF']; ?>"  method="post" />
    					<br />
    				  <div class="name" align="left">
    					  Username:<br />
    					  <div class="form"><input class="textarea" name="useremail" maxlength="60" size="24"  type="text" style="border: none;" /></div>
    				  </div>
    				  <div class="password1" align="left">
    					Password:<br />
    						<div class="form"><input class="textarea" name="pass" maxlength="20" size="24"  type="password" style="border: none;" /></div>
    				  </div>
    				  <br />
    <!--				 
     <span style="color: #000000; font-size: 9px; text-decoration: underline;"><a href="index.php">Forgot Password? 
                      - Click Here</a></span>
                      <br />
    				  <br />
    -->
    				  <input onclick="return validate();" name="submit" size="20" src="images/login.gif" type="image" value="Log Me In!" width="100" height="25" />
    				  </form>
    				  <br />
    				  <br />
    				</div>
    			</div>
    			<div class="content_bottom" align="right">
    			Back to <a href="index.php">Homepage</a>
    			</div>
    		</div>
    	</div>
    <?php include('footer.php'); ?>
    
    Code (markup):
    Thanks,
    James
     
    WPPJames, Sep 16, 2009 IP
  2. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 2
    #2
    Check your messages. Send you the answer to your problem. :D
     
    stephan2307, Sep 16, 2009 IP
  3. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    As Seller:
    100% - 0
    As Buyer:
    100% - 2
    #3
    Hey cool the above was my 100th Post here on dp.
    And one that was hopefully worth $20 :D :D
     
    stephan2307, Sep 16, 2009 IP
  4. WPPJames

    WPPJames Well-Known Member

    Messages:
    281
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    153
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    Thanks stephan2307. Haven't had time to fully test out, but looks good so far. PayPal sent.
     
    WPPJames, Sep 16, 2009 IP
  5. archis

    archis Member

    Messages:
    124
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    hi i can fix it
    i want details and pls pm me
     
    archis, Sep 16, 2009 IP
  6. WPPJames

    WPPJames Well-Known Member

    Messages:
    281
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    153
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    Turns out that stephan2307's fix, while helpful, wasn't the solution to my particular problem. Anyone else out there want to give it a try?
     
    WPPJames, Sep 21, 2009 IP