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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.