Jump to content

[SOLVED] Login script help


echocpt

Recommended Posts

Hi, basicly i have a login script that i have already used for one of my sites and it worked fine but when i moved it over to a new site it is'nt working. Could someone please point me in the correct direction? Thanks alot.

 

This is the login php code for "login2.php":

<?php 
// login2.php

session_start();
include("connection.php");


if(isset($_POST['submit'])) {
if(empty($_POST['username']) || empty($_POST['password'])) {
	header("Location: login.php");
	exit;
}

$username = $_POST['username'];
$password = $_POST['password'];

$password = md5($password);


$query = "SELECT username,password 
		  FROM	 `user`
		  WHERE	 username='$username'";

$result = mysql_query($query);
if(!$result) { 

	echo "The query failed " . mysql_error();
} else {

	$row = mysql_fetch_object($result);

	if($row->password != $password) {
	echo "The password is fucked" . mysql_error();
	}

	$_SESSION['username'] = $username;
	$_SESSION['sid'] = session_id(); 
	$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];

	header("Location: welcome.php");
	exit;
}
}
?>

 

This is the html form code:

<form id="form6" name="form6" method="post" action="login2.php">
					<table width="638" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="190">Username:</td>
							<td width="449"><label>
							<input name="username" type="text" class="area" id="username" value="" />
							</label></td>
						</tr>
						<tr>
							<td> </td>
							<td> </td>
						</tr>
						<tr>
							<td>Password:</td>
							<td><label>
							<input name="password" type="password" class="area" id="password" value="" />
                                
							</label></td>
						</tr>
						<tr>
							<td> </td>
							<td> </td>
						</tr>
						<tr>
							<td> </td>
							<td><label>
							  <input type="submit" name="submit" id="submit" value="Login" /></form>

 

Thanks for any help.

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

Sorry for the double post but it seems u can't edit posts for some crazy reason.

 

Completly forgot to post the error message displayed which was:

Warning: Cannot modify header information - headers already sent by (output started at /home/zerosite/public_html/ccf/redo/pages/login2.php:39) in /home/zerosite/public_html/ccf/redo/pages/login2.php on line 49

Thanks

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.