searls03 Posted August 17, 2011 Share Posted August 17, 2011 I keep getting this error: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/searls03/public_html/index.php:117) in /home/searls03/public_html/index.php on line 119. please help me find out what I am doing wrong. I know something is being sent, but idk where. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <style type="text/css"> #apDiv1 { position:absolute; left:0px; top:0px; width:100%; height:50px; z-index:1; background-color: #000; padding: 0px; text-align: left; } #menu { position:absolute; top:6px; width:411px; height:34px; z-index:41; right: 148px; } .jkljl { color: #FFF; } .adfasd { color: #FFF; } #apDiv1 #menu table #logform tr .style7 div { color: #FFF; } </style> <style type="text/css"> #apDiv2 { position:absolute; left:5px; top:75px; width:591px; height:284px; z-index:2; } #apDiv3 { position:absolute; left:111px; top:198px; width:466px; height:369px; z-index:2; } #apDiv3 div #form1 p { text-align: right; } .fullname { position:relative; left:0px; width:100px; height:30px; z-index:4; top:25px; background-color:black; color:white; text-align: center; } .fullname1 { position:relative; left:0px; width:100px; height:20px; z-index:4; top:px; background-color:white; color:Black; text-align: center; } </style> <script type="text/javascript"> function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> </head> <body onload="MM_preloadImages('/hover.png')"><div id="apDiv1"> <div id="menu"><table align="center" cellpadding="5"> <form action="index.php" method="post" enctype="multipart/form-data" name="logform" id="logform" onsubmit="return validate_form ( );"> <tr> <td class="style7"><div align="right"><span class="jkljl">Username</span>:</div></td> <td><input name="username" type="text" id="username" size="15" maxlength="64" /></td> <td><div align="right" class="adfasd">Password:</div></td> <td><input name="password2" type="password" id="password2" size="15" maxlength="24" /> </td> <td><input name="login" type="submit" value="Login" class="fullname1" id="login" /></td> </tr> </form> </table> <?php if ($_POST['login']) {include_once "connect_to_mysql_1.php"; session_start(); //Connect to the database through our include $username = stripslashes($_POST['username']); $username = strip_tags($username); $username = mysql_real_escape_string($username); $password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password2']); $password = md5($password); $sql = mysql_query("select * FROM sessions WHERE username='$username' AND password='$password'"); $login_check = mysql_num_rows($sql); if($login_check > 0){ while($row = mysql_fetch_array($sql)){ $id = $row["id"]; session_register('id'); $_SESSION['id'] = $id; $username = $row["username"]; session_register('username'); $_SESSION['username'] = $username; $name = $row["name"]; session_register('name'); $_SESSION['name'] = $name; $userlevel = $row["userlevel"]; session_register('userlevel'); $_SESSION['userlevel'] = 9; if ($_POST['username']) { $sql = mysql_query("UPDATE sessions SET loggedin='1' where username='$username'")or die(mysql_error()); } // Print success message here if all went well then exit the script $errorMsg = ''; $pass = ''; $remember = ''; if (isset($_POST['Submit'])) { $pass = $_POST['password']; if (isset($_POST['remember'])) { $remember = $_POST['remember']; } $pass = stripslashes($pass); $pass = strip_tags($pass); if($remember == "yes"){ $encryptedID = base64_encode("g4enm2c0c4y3dn3727553$id"); setcookie("idCookie", $encryptedID, time()+60*60*24*100, "/"); // Cookie set to expire in about 30 days setcookie("passCookie", $password, time()+60*60*24*100, "/"); // Cookie set to expire in about 30 days } // All good they are logged in, send them to homepage then exit script header("location: main.php"); exit(); }} // close while } else { // Print login failure message to the user and link them back to your login page print '<br /><br /><font color="#FF0000">Sorry, incorrect username or password, please try again! </font><br />'; }} ?> </div> <a href="main.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image1','','/hover.png',1)"><img src="/main.png" name="Image1" width="600" height="50" border="0" id="Image1" /></a> </div> <div id="apDiv3"><label for="day"></label> <label for="day"></label> <div align="left"> <div align="right"> <p>Sign up for a new account!</p> </div> <form id="form1" name="form1" method="post" action="loginred.php"> <p> <label for="first ">First Name</label> <input type="text" name="first" id="first" /> </p> <p> <label for="last">Last Name</label> <input type="text" name="last" id="last" /> </p> <p> <label for="email">Your email</label> <input type="text" name="email" id="email" /> </p> <p> <label for="email2">Re-enter Email</label> <input type="text" name="email2" id="email2" /> </p> <p> <label for="password">Password</label> <input type="password" name="password" id="password" /><br /><br /><label for="username">Username </label><input name="username" id="username" type="text" /> </p> <p>Gender <select name="gender"> <option value="Male">Male</option> <option value="Female">Female</option> </select> <br /> <select name="month" id="month"> <option value="January" selected="selected">January</option> <option value="February">February</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <select name="day" id="day"> <option value="1" selected="selected">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <?php echo '<select name="year" id="year">'; for( $i = 1900; $i <= date('Y', strtotime( '- 0 year')); $i++ ) { echo '<option>'; echo $i; echo '</option>';} echo '</select>'; ?></p> <p> <input type="submit" name="register" id="register" class="fullname" value="Sign up" /> </p> </form> <p> </p> <p> <label for="year"></label> </p> </div></div> <img src="lettering.png" width="150" height="525" /> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/245060-session_register/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 17, 2011 Share Posted August 17, 2011 session_start(); must be before you send any characters to the browser. Everything in your file from line 1 to line 117 must come after the session_start statement. Quote Link to comment https://forums.phpfreaks.com/topic/245060-session_register/#findComment-1258725 Share on other sites More sharing options...
Maq Posted August 17, 2011 Share Posted August 17, 2011 Have you read the sticky? - http://www.phpfreaks.com/forums/index.php?topic=37442.0 Quote Link to comment https://forums.phpfreaks.com/topic/245060-session_register/#findComment-1258727 Share on other sites More sharing options...
searls03 Posted August 17, 2011 Author Share Posted August 17, 2011 yes i did thank you. how do I make it then so that my message will display where I want it at? eg. where I put it at in the script Quote Link to comment https://forums.phpfreaks.com/topic/245060-session_register/#findComment-1258737 Share on other sites More sharing options...
searls03 Posted August 23, 2011 Author Share Posted August 23, 2011 so does anyone know how to make my error message display in the place I would like it to on the page since the code cant go in the middle of the page? Quote Link to comment https://forums.phpfreaks.com/topic/245060-session_register/#findComment-1261074 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.