Jump to content

[SOLVED] Login script


ninedoors

Recommended Posts

This login script worked for me for the past 4 months but now my server has changed over to PHP 5 and now I am getting an error message.  This is what I get:

 

Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home/barrie/public_html/stats/statsconfig.php:9) in /home/barrie/public_html/stats/check_login.php on line 18

 

Warning: Cannot modify header information - headers already sent by (output started at /home/barrie/public_html/stats/statsconfig.php:9) in /home/barrie/public_html/stats/check_login.php on line 20

 

My script to check the usename and password is below:

 

<?php

include 'statsconfig.php';

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// Get values from form 
$username=$_POST['username'];
$password=$_POST['password'];
$md5password = md5($password);

//Check to see if the user and pass exist in the database
$check= mysql_query("SELECT * FROM reglogin WHERE username = '$username' AND password = '$md5password'");
$returned = mysql_fetch_array($check);
if(!empty($returned))	{
					session_register("username");
					session_register("password"); 
					header("Location: ../stats/statform.php");
					mysql_close();
					Die();
					}
					else 	{
							header("Location: ../stats/stat-login.php");
							mysql_close();
							Die();
							}

?>

 

Any help would be great.  Thanks

 

Nick

Link to comment
https://forums.phpfreaks.com/topic/83643-solved-login-script/
Share on other sites

try as posted please

<?php
ob_start();
include 'statsconfig.php';
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form 
$username=$_POST['username'];
$password=$_POST['password'];
$md5password = md5($password);
//Check to see if the user and pass exist in the database
$check= mysql_query("SELECT * FROM reglogin WHERE username = '$username' AND password = '$md5password'");
$returned = mysql_fetch_array($check);
if(!empty($returned))	{session_register("username");
					session_register("password"); 
					header("Location: ../stats/statform.php");
					mysql_close();
					Die();
					}
					else 	{header("Location: ../stats/stat-login.php");
							mysql_close();
							Die();
ob_flush();
							}?>

Link to comment
https://forums.phpfreaks.com/topic/83643-solved-login-script/#findComment-425490
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.