Register for your free account! | Forgot your password?

You last visited: Today at 00:27

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Help] PHP

Discussion on [Help] PHP within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
Beta Limit's Avatar
 
elite*gold: 0
Join Date: Dec 2008
Posts: 493
Received Thanks: 72
[Help] PHP

Hey, im trying to make a web based using PHP, but I cannot seem to keep within a "session" or the session is not registering properly.

loginapp.php
PHP Code:
<?php 
require("config.php");
include(
"session.php");
ob_start();
?>
HTML Code:
<form id="form1" name="form1" method="post" action="">
  <table width="300" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="30" align="left" valign="middle">Username :</td>
      <td height="30" align="center" valign="middle"><input type="text" name="Username" id="Username" /></td>
    </tr>
    <tr>
      <td height="30" align="left" valign="middle">Password :</td>
      <td height="30" align="center" valign="middle"><input type="password" name="Password" id="Password" /></td>
    </tr>
    <tr>
      <td height="30" colspan="2" align="center" valign="middle"><label>
        <input type="submit" name="Login" id="Login" value="Login" />
      </label></td>
    </tr>
  </table>
</form>
PHP Code:
<?php
if(isset($_POST[Login]))
{
    
$session_username$_POST['Username']; 
    
$session_password$_POST['Password'];
    
$session_username stripslashes($session_username);
    
$session_password stripslashes($session_password);
    
$session_username mysql_real_escape_string($session_username);
    
$session_password mysql_real_escape_string($session_password);
    
$session_password MD5($session_password);
    
$result mysql_query("SELECT * FROM Users WHERE User_Name='$session_username' and User_Password='$session_password'");
    
$count=mysql_num_rows($result);
    if(
$count==1)
    {
        
session_register($session_username);
        
session_register($session_password);
        echo 
'<META HTTP-EQUIV="Refresh" Content="0;
        URL=home.php">'
;
    }
    else 
    {
        echo 
"Wrong Username or Password";
    }
}
ob_end_flush();
?>


home.php
PHP Code:
<?php 
require("config.php");
include(
"session.php");
session_start();
if(!
session_is_registered())
{    
    echo 
'<META HTTP-EQUIV="Refresh" Content="0;
        URL=access.php">'
;
}
?>
just cannot seem to keep within a session.

Beta
Beta Limit is offline  
Old 11/13/2009, 15:26   #2
 
elite*gold: 20
Join Date: Nov 2005
Posts: 622
Received Thanks: 5
The PHP function session_register() is deprecated and no longer availabe after PHP v6.0.0.

Instead you should put session_start(); at the top of the page, and use the global $_SESSION[] variables like:

PHP Code:
$_SESSION['username'] = $_POST['username']; 
Lightning73 is offline  
Reply




All times are GMT +1. The time now is 00:28.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.