Jump to content

My session is not working


Jragon

Recommended Posts

My session is not working for somereaseon

 

My index code:

<!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>
  <title>VisualUpload Share what you see</title>
</head>

<body bgcolor="#f1f1f1" text="#000000" link="33cc00" vlink="33cc00" alink="33cc00">
  <table align="center" width="95%" bgcolor="#ffffff" style="border-color: #999999; border-style:solid;border-width:1px" border="0">
   <tr>
    <td>
     <table>
      <tr>
       <td width="50%">
        <img src="images/logo.png" />
       </td>
       <td>
        <form method="post" action="login.php" >
        <table width="100%">
         <tr>
          <td>
           Username:
          </td>
          <td>
           <input type="text" name="user" size="16" maxlength="25"/> <a href="register.php">Register</a>
          </td>
          </tr><tr>
           <td>
            Password:
           </td>
           <td>
            <input type="password" name="pass" size="16" maxlength="25"/> <input type="submit" value="Log in"/>
           </td>
         </tr>
        </table>
        </form>
       </td>
      </tr>
     </table>
<?php
if (isset($_SESSION['user'])){
echo '<tr>
       <td>
        <table width="100%">
         <tr>
          <td width="20%" valign="top">
           <font size="4">
            <a href="upload.php"><strong>Upload</strong></a><br />
            <a href="albums.php"><strong>Albums</strong></a><br />
            <a href="profile.php"><strong>Profile</strong></a><br />
           </font>
          </td>
          <td valign="top">
           <font size="4">
            <b>Recant Images</b><br />
            <font size="2">
             You Haven\'t uploaded any picturs!<br />
            </font>
            </font>
            <font size="4">
             <b>Recant Videos</b><br />
             <font size="2">
              You Haven\'t uploaded any videos!<br />
            </font>
           </font>
          </td>
         </tr>
        </table>
       </td>
      </tr>';

}
?>
    </td>
   </tr>
  </table>
</body>
</html>

 

my login code:

<?php
session_start;
include("getsalt.php");
require("connect.php");
include("getname.php");

$post_username = $_POST['user'];
$post_password = $_POST['pass'];

if (isset($post_password) && isset($post_username)){
    if(strlen($post_username)>25||strlen($post_password)>25){
        die('Username or password character length too long!');
    }else{
        //convert pass to md5
        $salt = getsalt($post_username);
        $post_password = md5($salt.$post_password);
        $login = sprintf("SELECT * FROM user WHERE username='%s' AND password = '%s'", mysql_real_escape_string($post_username), mysql_real_escape_string($post_password));
        $rowcount = mysql_num_rows(mysql_query($login));
        if ($rowcount == 1){
            $_SESSION['user'] = $post_username;
            $name = getname($post_username);
            echo 'Welcome ' . $name . '!<br /> Please click <a href="index.php">here</a> to go back to the main page.';
        }
    }
}else{
    die('Please enter a useranme and password');
}
?>

 

Please help

 

Thanks

Jragon

Link to comment
https://forums.phpfreaks.com/topic/208535-my-session-is-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.