spiceydog Posted July 22, 2008 Share Posted July 22, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/116062-solved-errors-on-my-login-script/ Share on other sites More sharing options...
DeanWhitehouse Posted July 22, 2008 Share Posted July 22, 2008 Read this http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Quote Link to comment https://forums.phpfreaks.com/topic/116062-solved-errors-on-my-login-script/#findComment-596795 Share on other sites More sharing options...
spiceydog Posted July 22, 2008 Author Share Posted July 22, 2008 Ok it turns out there was one line (error_reporting(E_ALL) in my dblogin.php script that was causing all the problems. all fixed. Quote Link to comment https://forums.phpfreaks.com/topic/116062-solved-errors-on-my-login-script/#findComment-596796 Share on other sites More sharing options...
revraz Posted July 22, 2008 Share Posted July 22, 2008 Means you have undefined constants, just as it states. Quote Link to comment https://forums.phpfreaks.com/topic/116062-solved-errors-on-my-login-script/#findComment-596801 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.