
05-12-2009, 23:57
|
|
|
|
חבר מתאריך: 17.10.05
הודעות: 161
|
|
|
לא מצליח ליצור session
יש לי את הקוד הבא:
קוד PHP:
<?php $con= mysql_connect(*******,*****,'*******'); if(!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("******", $con); $encoding = 'utf-8'; mb_detect_order($encoding); mb_internal_encoding($encoding); mysql_query("SET NAMES utf8;"); $password=mysql_query("SELECT password FROM mailpassword"); $password=mysql_fetch_array($password); $password=$password['password']; $userpassword=$_POST['pw']; if($userpassword==$password) { session_start(); $_SESSION['loginok']=1; echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> '; echo "<html> "; echo "<head> "; echo ' <style type="text/css"> '; echo " .adg {COLOR:#0066CC; FONT-SIZE: 14px;font-weight:bold;font-family:arial; text-decoration: none; } "; echo " .piska {COLOR: #033763; FONT-SIZE: 15px;font-family:arial; text-decoration: none; } "; echo " BODY{margin:0px;padding:0px;} "; echo " </style> "; echo ' <SCRIPT type="text/javascript"> '; echo "var xmlhttp; "; echo "function ajaxFunction(x) "; echo "{ "; echo "var x=x "; echo "if (window.XMLHttpRequest) "; echo "{ "; // code for IE7+, Firefox, Chrome, Opera, Safari echo " xmlhttp=new XMLHttpRequest(); "; echo " } "; echo "else "; echo " { "; // code for IE6, IE5 echo ' xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); '; echo "} "; echo "xmlhttp.onreadystatechange=function() "; echo "{ "; echo "if(xmlhttp.readyState==4) "; echo "{ "; echo " var data=xmlhttp.responseText; "; echo ' document.getElementById("divp").innerHTML = data; '; echo " } "; echo "} "; echo 'var url="deletmail.php"; '; echo 'url += "?id=" + encodeURIComponent(x); '; echo 'url += "&ignoreMe=" + Math.random(); '; echo 'xmlhttp.open("GET",url,true); '; echo "xmlhttp.send(null); "; echo "}; "; echo " function hs(x) "; echo " { "; echo ' var x="tafn"+x '; echo " if (navigator.appName=='Netscape') "; echo ' if (document.getElementById(x).style.visibility == "hide") '; echo ' document.getElementById(x).style.visibility="show"; '; echo " else "; echo ' document.getElementById(x).style.visibility="hide"; '; echo " else"; echo ' if (document.getElementById(x).style.display=="none") '; echo ' document.getElementById(x).style.display="block"; '; echo " else "; echo ' document.getElementById(x).style.display="none"; '; echo " }; "; echo " </script> "; echo "</head> "; echo "<body> "; $result=mysql_query("SELECT firstname ,id,lastname,email,subject,details FROM mail"); echo '<div id="divp" >'; echo '<table align=center border=0 style="width:600px;">'; echo '<tr><td colspan=2 align=right><font style="COLOR: #26679E; FONT-SIZE: 45px;font-family:arial;font-weight:bold;text-decoration: none;">פישפיק</font><font style="COLOR: #ACACAC; FONT-SIZE: 40px;font-family:arial; text-decoration: none;">דואר</font> </td></tr>'; echo "</table>"; echo '<table align=center cellspacing=0 cellpadding=0 border=0 style="width:600px;border-left: 1px solid #26679E;border-right: 1px solid #26679E;border-bottom: 1px solid #26679E;">'; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo '<td align=center style="height:25px;border-top:1px solid #26679E;"><form ><input type="hidden" id="id" name="id" value="'.$row['id'].'"/><input type="button" onclick="ajaxFunction('.$row['id'].')" value="מחק"/></form></td><td onClick="hs('.$row['id'].')" style="height:25px;border-top:1px solid #26679E;"><table align=right style="width:100%;"><tr><td align=right><font class="adg">'.$row['email'].'</font></td><td align=right style="width:100px;"><font class="adg">'.$row['subject'].' </font></td> <td align=right style="width:140px;"><font class="adg">'.$row['firstname'].' '.$row['lastname'].' </font></td></tr></table></td>'; echo "</tr>"; echo '<tr><td></td><td><table align=right style="width:100%;"><td></td><td align=right dir="rtl" style="width:400px;"><div id="tafn'.$row['id'].'" style="display:none;"> <p class="piska">'.$row['details']. '</p></div></td> </table></td></tr>'; } echo "</table> "; echo "</div> "; mysql_close($con); } else { echo "<br><br>"; echo '<table align=center cellpadding=1 cellspacing=0 style="vertical-align:top;width:200px;height:100px;border: 1px solid #26679E;"> '; echo '<tr><td align=center> <font> סיסמה שגוייה</font> <a href="login.html" class="adg">נסה שנית</a></td></tr>'; echo "</table>"; } echo "</body> "; echo "</html> "; ?>
הוא נותן לי הודעת שגיאה כזאת:
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/www/fishpic.atwebpages.com/mail.php:3) in /home/www/fishpic.atwebpages.com/mail.php on line 25
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/www/fishpic.atwebpages.com/mail.php:3) in /home/www/fishpic.atwebpages.com/mail.php on line 25
מחיפוש קצר בפורם הבנתי שכנראה המהדר שולח משהו לפניי שהוא באמת מתחיל כיצד אפשר לתקן זאת?
תודה מראש 
|