Get global array issue

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
thisbl00d
Forum Newbie
Posts: 13
Joined: Sat Feb 14, 2009 1:17 pm

Get global array issue

Post by thisbl00d »

Code: Select all

<?php 
include 'dbc.php';
 
$user_email = mysql_real_escape_string($_POST['email']);
 
if (isset($_POST['Submit'])=='Login')
{
$md5pass = md5($_POST['pwd']);
$sql = "SELECT id,user_email FROM users WHERE 
            user_email = '$user_email' AND 
            user_pwd = '$md5pass'"; 
            
$result = mysql_query($sql) or die (mysql_error()); 
$num = mysql_num_rows($result);
 
    if ( $num != 0 ) { 
 
        // A matching row was found - the user is authenticated. 
       session_start(); 
       list($user_id,$user_email) = mysql_fetch_row($result);
        // this sets variables in the session 
        $_SESSION['user']= $user_email;  
[color=#BF0000] if (isset($_GET['ret']) && !empty($_GET['ret']))
        {
        header("Location: $_GET[ret]");
        } else
        {
        header("Location: myaccount.php");
        }[/color]
        //echo "Logged in...";
        exit();
    } 
 
header("Location: login.php?msg=Invalid Login");
//echo "Error:";
exit();     
}
 
?>
 
<link href="styles.css" rel="stylesheet" type="text/css">
 
<?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?>
 
 
<p>&nbsp;</p><table width="40%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td bgcolor="#d5e8f9" class="mnuheader" >
<div align="center"><font size="5"><strong>Login 
        Members</strong></font></div></td>
  </tr>
  <tr> 
    <td bgcolor="#e5ecf9" class="mnubody"><form name="form1" method="post" action="">
        <p>&nbsp;</p>
        <p align="center">Your Email 
          <input name="email" type="text" id="email">
        </p>
        <p align="center"> Password: 
          <input name="pwd" type="password" id="pwd">
        </p>
        <p align="center"> 
          <input type="submit" name="Submit" value="Login">
        </p>
        <p align="center"><a href="register.php">Register</a> | <a href="forgot.php">Forgot</a></p>
      </form></td>
  </tr>
</table>
    
 
If conditon marked in red

Q1. what is the If condition checking for?
Q2. when will the IF condition be true
Q3. $_get['ret'] is driving me nUTTS :banghead:
User avatar
aditya2071990
Forum Contributor
Posts: 106
Joined: Thu May 22, 2008 11:30 am
Location: Hyderabad, India
Contact:

Re: Get global array issue

Post by aditya2071990 »

Maybe the condition wasn't supposed to be there at all in this file, and was meant for the register.php file [or] maybe there is some other page that will communicate with this page via the GET method, and the name of the variable it is sending is 'ret' ?
Post Reply