Jump to content

[SOLVED] Login not working?


Warptweet

Recommended Posts

I put this code in the <body> area of my page...

 

<?php

if ($_POST['username']) {

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

if ($password==NULL) {
echo "You did not supply a password.";
}

else

{

$query = mysql_query("SELECT username,password FROM warp_users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($query);

if($data['password'] != $password) {
echo "The supplied login is incorrect";
}

else

{
$query = mysql_query("SELECT username,password,user_level,user_id FROM warp_users WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($query);

   setcookie("username", "Warptweet", time()+3600, "/","", 0);

echo "You are now logged in, " . $COOKIE['username'] . "!";

}
}
}

echo "<center><h1>Login</h1>
<form action='login.php' method='POST'>
<table style='border:1px solid #000000;'>
<tr>
<td align='right'>
Username: <input type='text' size='15' maxlength='25' name='username'>
</td>
</tr>
<tr>
<td align='right'>
Password: <input type='password' size='15' maxlength='25' name='password'>
</td>
</tr>
<tr>
<td align='center'>
<input type=\"submit\" value=\"Login\">
</td>
</tr>
<tr>
<td align='center'>
<a href='register.php'>Register Here</a>
</td>
</tr>
</table>
</form>
</center>";

?>

 

I don't understand, I get this error when I try logging in:

 

Warning: Cannot modify header information - headers already sent by (output started at /home/warp/public_html/new/login.php:10) in /home/warp/public_html/new/login.php on line 66

 

LINE 66:

   setcookie("username", "Warptweet", time()+3600, "/","", 0);

 

What is wrong with my code? Can somebody please tip me in the right direction? I think there is something I may be missing, and I have no clue what.

 

Thanks,

-Warptweet

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.