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
https://forums.phpfreaks.com/topic/116062-solved-errors-on-my-login-script/
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.