Jump to content

[SOLVED] Errors on my login script!


spiceydog

Recommended Posts

It used to work and now it randomly doesn't. I'm getting the following errors:

Notice: Use of undefined constant ID_my_site - assumed 'ID_my_site' in /home/website/public_html/index.php on line 45

 

Warning: Cannot modify header information - headers already sent by (output started at /home/website/public_html/index.php:45) in /home/website/public_html/index.php on line 45

 

Notice: Use of undefined constant Key_my_site - assumed 'Key_my_site' in /home/website/public_html/index.php on line 46

 

Warning: Cannot modify header information - headers already sent by (output started at /home/website/public_html/index.php:45) in /home/website/public_html/index.php on line 46

 

Warning: Cannot modify header information - headers already sent by (output started at /home/website/public_html/index.php:45) in /home/website/public_html/index.php on line 49

 

Here is the relevant code (Lines 1-52):

<?php 
// Connects to your Database 
include 'dblogin.php'; {

///if the login form is submitted
if(isset($_POST['submit']) || (isset($_POST['submit_x']) && (isset($_POST['submit_y'])))) { // if form has been submitted
// makes sure they filled it in
if(!$_POST['username'] | !$_POST['pass']) {
echo "<script language='JavaScript' type='text/javascript'>alert('You forgot to fill in a required field!'); 
  location = 'nosession.php';</script>";
exit;
}
// checks it against the database

if (!get_magic_quotes_gpc()) {
$_POST['email'] = addslashes($_POST['email']);
}
$check = mysql_query("SELECT * FROM accounts WHERE username = '".$_POST['username']."'")or die(mysql_error());

//Gives error if user dosen't exist
$check2 = mysql_num_rows($check);
if ($check2 == 0) {
echo "<script language='JavaScript' type='text/javascript'>alert('We don't have anyone registered with that username! You should register it and become a member! Redirecting to registeration page...'); 
  location = 'register.php';</script>";
exit;
}
while($info = mysql_fetch_array( $check )) 
{
$_POST['pass'] = stripslashes($_POST['pass']);
$info['password'] = stripslashes($info['password']);
$_POST['pass'] = md5($_POST['pass']);

//gives error if the password is wrong
if ($_POST['pass'] != $info['password']) {
echo "<script language='JavaScript' type='text/javascript'>alert('Incorrect Password! Try AGAIN!'); 
  location = 'nosession.php';</script>";
exit;
}
else 
{ 

// if login is ok then we add a cookie 
$_POST['username'] = stripslashes($_POST['username']); 
$hour = time() + 3600; 
setcookie(ID_my_site, $_POST['username'], $hour); 
setcookie(Key_my_site, $_POST['pass'], $hour);	
header("Location: index.php");

} 
}
}
?>

 

And here is my login form:

<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
		<input type="text" id="username" name="username" onFocus="clearu();" value="username" style="font-size:15px" size="15">
<input type="image" value="Login" name="submit" src="images/login.jpg">
<a href="register.php">register account</a><br>
      <br>
      <a href="recovery.php">lost you password?</a>
<input id="password" type="password" onFocus="clearp();" name="pass" value="password" style="font-size:15px" size="15">
</form>

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.