Show Source Code


<?php
include("include/inc_controlstructures.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Chinese Zodiac Log in</title>
<link href="vedic.css" rel="stylesheet" type="text/css" media="screen, projection" />
<style>

form {
padding-Left 100px;
}



a:link {color: #b4dff7;}
a:visited {color: #00FF00;}
a:hover {color: #FF00FF;}
a:active {color: #0000FF;}
</style>

</head>

<body>
<h1 style="text-align: center; margin-top: 100px; ">Chinese Zodiac Log In</h1>

<?php
session_start
();


        if( isset(
$_SESSION['loginPassed3']) )
        {
            echo 
"<META http-equiv='refresh' content='0;URL=main.php'>";
        }
        else
        {

                if ( !empty(
$_POST["username"]) AND !empty( $_POST["password"]) )
                {
                    
$Username stripslashes($_POST['username']);
                    
$Password stripslashes($_POST['password']);
                    if (
verifyLogin($Username$Password))
                    {
                        
$_SESSION['loginPassed3'] = 100;
                        
$_SESSION['user_name'] = $Username;
                        
$_SESSION['user_password'] = $Password;
                        echo 
"<META http-equiv='refresh' content='0;URL=main.php'>";
                    }
                    else 
                    {
                        
                        echo
                            
"<html>".
                            
"<body text=\"black\" link=\"blue\" vlink=\"blue\" bgcolor=\"white\">".


                            
"<center><br><br>".
                            
"<center><form method=\"post\" action=\"login.php\">".
                            
"Username: <input type=\"text\" name=\"name\" value=\"\" size=\"20\"><BR>".
                            
"Password: <input type=\"password\" name=\"password\" value=\"\" size=\"15\"><BR>".
                            
"<input type=\"Submit\" value=\"Submit\">".
                            
"</center>".
                            
"</form></center>".

                            
"<center><p>Invalid Username and Password</center></p>" .
                            
"</body>".
                            
"</html>";    
                        
                    } 
                }else
                {


                    echo
                    
"<html>".
                    
"<body text=\"black\" link=\"blue\" vlink=\"blue\" bgcolor=\"white\">".


                    
"<center><br><br>".
                    
"<form method=\"post\" action=\"log_in.php\">".
                    
"Username: <input type=\"text\" name=\"username\" value=\"\" size=\"20\"><BR>".
                    
"Password: <input type=\"password\" name=\"password\" value=\"\" size=\"15\"><BR>".
                    
"<input type=\"Submit\" value=\"Submit\">".
                    
"</center>".
                    
"</form>".

                    
"<center><p>Username and Password are required fields.</p></center>" .
                    
"</body>".
                    
"</html>";
                }







        }
function 
verifyLogin($Username$Password) {
    
$retval FALSE;
   
$DBConnect mysql_connect("lumenlightnet.ipagemysql.com""user_1""zodiac");
    if (
$DBConnect === FALSE) {
        echo 
"<p>Unable to connect to the database server.</p>" "<p>Error code " mysql_errno() . ": " mysql_error() . "</p>";
    }
    else {
        
$DBName "practice_zodiac";
//        $DBName = "sample";
        
mysql_select_db($DBName$DBConnect);
        
$TableName="chinese_zodiac";
        
$SQLstring="SHOW TABLES LIKE '$TableName'";
        
$QueryResult=@mysql_query($SQLstring$DBConnect);
        
        if (
mysql_num_rows($QueryResult) == 0) {
            echo 
"<p>Unable to verify username and password.</p>";
        }
        else
        {
            
$SQLstring "SELECT * FROM $TableName WHERE user_name='$Username'";
            
$QueryResult=@mysql_query($SQLstring$DBConnect);
            if (
$QueryResult === FALSE) {
                echo 
"<p>Unable to execute the query.</p>";
            } else
            {
                
$Row mysql_fetch_row($QueryResult);
                if (
$Password == $Row[1]) {
                    
$retval TRUE;
                }
            }
        }
        
mysql_free_result($QueryResult);
        
mysql_close($DBConnect);
    }
    echo (
$retval);
    return (
$retval);
}
?>


</body>
</html>