rsalumpit Posted August 2, 2009 Share Posted August 2, 2009 <?php include('connection.php'); ?> <head> <title>checklogin</title> <link href="style.css" rel="stylesheet" type="text/css" /> <link rel="icon" type="image/png" href="favicon.ico"> </head><?php // Connect to server and select databse. mysql_connect("$xhost", "$xusername", "$xpassword")or die("cannot connect"); mysql_select_db("$xdb_name")or die("cannot select DB"); // username and password sent from form $myusername=$_POST['username']; $mypassword=$_POST['password']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $xtbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row //$obj = @mysql_fetch_object($result) if ($obj = @mysql_fetch_object($result)) { $_SESSION["confirm"] = $obj->status; if ($_SESSION["confirm"] == "activated"){ // Login good, create session variables $_SESSION["valid_id"] = $obj->id; $_SESSION["valid_user"] = $_POST["username"]; $_SESSION["valid_zip"] = $obj->zipcode; $_SESSION["valid_eml"] = $obj->email; $_SESSION["valid_time"] = time(); Header("Location: index.php"); } else{$checklog = "1"; $logme ='Sorry you need to confirm first your Email Address'; } // Redirect to member page } else{ // Login not successful if ($checklog != "1") {$logme = 'Sorry, could not log you in. Wrong login information.<a href="login.php" title="Login" target="_self">BACK</a>';} } ?> <body> <!-- header start --> <div id="header"> <a href="index.html" title="DegraciaWeather"><img src="images/logo.jpg" alt="DegraciaWeather" border="0" /></a> <ul> <li><a href="#" title="Home" class="hover">home</a></li> <li><a href="#" title="Contact">contact</a></li> </ul> </div> <!-- header end --> <!-- future pannel start --> <div id="future"> <div align="center" id="msgme"> <!--DISPLAY THE MSG OF THE LOGIN--> <?php echo $logme;?> </div> </div> <!-- future pannel start --> <!-- body start --> <div id="body"> <div id="bodyLeft"> </div> <br class="spacer" /> </div> <div id="footer"> <div id="footerContainer"> <ul> <li><a href="index.php" title="Home"> home</a></li> <li>|</li> <li><a href="#" title="Contact">contact</a></li> </ul> <br /> <p>©www.degraciaweather.com. All Rights Reserved.</p> <div id="footerContainerValidation"> <a "http://validator.w3.org/check?uri=referer" target="_blank" title="Valid XHTML" class="xhtml">XHTML</a><a "http://jigsaw.w3.org/css-validator/check/referer" target="_blank" title="Valid CSS" class="css">CSS</a> </div><br class="spacer" /> <p class="tworld">Designed By : <a href="http://www.google.com/" title="DeGracia Team" target="_blank">DEGRACIA TEAM</a></p><br class="spacer" /> </div> </div> <!-- footer end --> </body> Whats wrong with my code im having a problem with the header Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\4cast\checklogin.php: in C:\xampp\htdocs\4cast\checklogin.php on line 39 Quote Link to comment https://forums.phpfreaks.com/topic/168494-header-error/ Share on other sites More sharing options...
wildteen88 Posted August 2, 2009 Share Posted August 2, 2009 You cannot have any ouput form of before using header. To fix this change this <?php include('connection.php'); ?> <head> <title>checklogin</title> <link href="style.css" rel="stylesheet" type="text/css" /> <link rel="icon" type="image/png" href="favicon.ico"> </head><?php // Connect to server and select databse. To this <?php include('connection.php'); // Connect to server and select databse. Now change <body> <!-- header start --> to <head> <title>checklogin</title> <link href="style.css" rel="stylesheet" type="text/css" /> <link rel="icon" type="image/png" href="favicon.ico"> </head> <body> <!-- header start --> Quote Link to comment https://forums.phpfreaks.com/topic/168494-header-error/#findComment-888829 Share on other sites More sharing options...
shadiadiph Posted August 2, 2009 Share Posted August 2, 2009 also check your connection.php i have had alot of header problems in php 5 if you have a blank whitespace space or line under the final ?> it will not work and will produce a header error for example on the final ?> there is an extra line like this one that is blank or a space after the ?> Quote Link to comment https://forums.phpfreaks.com/topic/168494-header-error/#findComment-888852 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.