Twentyoneth Posted March 19, 2006 Share Posted March 19, 2006 The php in this file works, as long as the html is gone, whats wrong with the html?[code]<html><head><link rel='stylesheet' type='text/css' href='mreds.css' /><link rel='alternate stylesheet' type='text/css' media='screen' title='mmilds' href='mmilds.css' /><link rel='alternate stylesheet' type='text/css' media='screen' title='mmenthollights' href='mmenthollights.css' /><link rel='alternate stylesheet' type='text/css' media='screen' title='mno27s' href='mno27s.css' /></head><body onLoad='goforit()' align=center><table border=0 height=100% width=100%><tr><td vAlign=middle align=center><table border=0 cellspacing=0 cellpadding=0 bgcolor='#ffffff'><tr><td><img src='images/layout/cornerleft.png' height='26' width='31'></img></td><td><img src='images/layout/top.png' height='26' width='100%'></img></td><td><img src='images/layout/cornerright.png' height='26' width='31'></img></td></tr><tr><td class='loginoroutleft'></td><td align=center><!-- start shit --> <table border=0 width=300 cellspacing=0 cellpadding=0> <tr> <td align=left vAlign=top width=100% cellspacing=0 cellpadding=0> <table border=1 width=100% cellspacing=0 cellpadding=0><tr><td align=left vAlign=top class='menuheadertop' width=100%> <b>Status</b> </td></tr></table> </td> </tr> <tr> <td align=left width=100%> <table border=1 width=100% height=100 cellspacing=0 cellpadding=0><tr><td vAlign=top class='menuheaderbottom' width=100% align=center><?php$user = $_POST["UserName"];$pass = $_POST["PassWord"];$UID = 1;if ($_POST["UserName"] == "user" && $_POST["PassWord"] == "pass") { setcookie("UserName", $user, time()+3600); setcookie("Password", $pass, time()+3600); setcookie("UID", $UID, time()+3600); echo "Logged in as $user."; echo "<br><br><a href='index.php' align=left>Continue</a>"; } else { echo "Invalid username or password."; echo "<br><br><a href='index.php' align=left>Continue</a>"; }?> </td></tr></table> </td> </tr> </table><!-- end shit --></td><td class='loginoroutright'></td></tr><tr><td><img src='images/layout/cornerleftbottom.png' height='26' width='31'></img></td><td><img src='images/layout/bottom.png' height='26' width='100%'></img></td><td><img src='images/layout/cornerrightbottom.png' height='26' width='31'></img></td></tr></table></td></tr></table><center><font color='#ffffff'><b>Best Viewed In:: Mozilla Firefox - Resolution:: 1024x768</b></font></center></body></html>[/code] Quote Link to comment Share on other sites More sharing options...
Twentyoneth Posted March 19, 2006 Author Share Posted March 19, 2006 Fixed! This code works:[code]<?php$user = $_POST["UserName"];$pass = $_POST["PassWord"];$UID = 1;if ($_POST["UserName"] == "Thomas" && $_POST["PassWord"] == "**killedbyuse**") { setcookie("UserName", $user, time()+3600); setcookie("Password", $pass, time()+3600); setcookie("UID", $UID, time()+3600);echo "<html><head><link rel='stylesheet' type='text/css' href='mreds.css' /><link rel='alternate stylesheet' type='text/css' media='screen' title='mmilds' href='mmilds.css' /><link rel='alternate stylesheet' type='text/css' media='screen' title='mmenthollights' href='mmenthollights.css' /><link rel='alternate stylesheet' type='text/css' media='screen' title='mno27s' href='mno27s.css' /></head><body onLoad='goforit()' align=center><table border=0 height=100% width=100%><tr><td vAlign=middle align=center><table border=0 cellspacing=0 cellpadding=0 bgcolor='#ffffff'><tr><td><img src='images/layout/cornerleft.png' height='26' width='31'></img></td><td><img src='images/layout/top.png' height='26' width='100%'></img></td><td><img src='images/layout/cornerright.png' height='26' width='31'></img></td></tr><tr><td class='loginoroutleft'></td><td align=center><!-- start shit --> <table border=0 width=300 cellspacing=0 cellpadding=0> <tr> <td align=left vAlign=top width=100% cellspacing=0 cellpadding=0> <table border=1 width=100% cellspacing=0 cellpadding=0><tr><td align=left vAlign=top class='menuheadertop' width=100%> <b>Status</b>";if ($UID == 1) {echo "[admin]";} else {echo "[guest]";}echo " </td></tr></table> </td> </tr> <tr> <td align=left width=100%> <table border=1 width=100% height=100 cellspacing=0 cellpadding=0><tr><td vAlign=top class='menuheaderbottom' width=100% align=center>"; echo "Logged in as $user."; echo "<br><br><a href='index.php' align=left>Continue</a>"; } else {echo "<html><head><link rel='stylesheet' type='text/css' href='mreds.css' /><link rel='alternate stylesheet' type='text/css' media='screen' title='mmilds' href='mmilds.css' /><link rel='alternate stylesheet' type='text/css' media='screen' title='mmenthollights' href='mmenthollights.css' /><link rel='alternate stylesheet' type='text/css' media='screen' title='mno27s' href='mno27s.css' /></head><body onLoad='goforit()' align=center><table border=0 height=100% width=100%><tr><td vAlign=middle align=center><table border=0 cellspacing=0 cellpadding=0 bgcolor='#ffffff'><tr><td><img src='images/layout/cornerleft.png' height='26' width='31'></img></td><td><img src='images/layout/top.png' height='26' width='100%'></img></td><td><img src='images/layout/cornerright.png' height='26' width='31'></img></td></tr><tr><td class='loginoroutleft'></td><td align=center><!-- start shit --> <table border=0 width=300 cellspacing=0 cellpadding=0> <tr> <td align=left vAlign=top width=100% cellspacing=0 cellpadding=0> <table border=1 width=100% cellspacing=0 cellpadding=0><tr><td align=left vAlign=top class='menuheadertop' width=100%> <b>Status</b>";if ($UID == 1) {echo "[admin]";} else {echo "[guest]";}echo " </td></tr></table> </td> </tr> <tr> <td align=left width=100%> <table border=1 width=100% height=100 cellspacing=0 cellpadding=0><tr><td vAlign=top class='menuheaderbottom' width=100% align=center>"; echo "Invalid username or password."; echo "<br><br><a href='index.php' align=left>Continue</a>"; }?> </td></tr></table> </td> </tr> </table><!-- end shit --></td><td class='loginoroutright'></td></tr><tr><td><img src='images/layout/cornerleftbottom.png' height='26' width='31'></img></td><td><img src='images/layout/bottom.png' height='26' width='100%'></img></td><td><img src='images/layout/cornerrightbottom.png' height='26' width='31'></img></td></tr></table></td></tr></table><center><font color='#ffffff'><b>Best Viewed In:: Mozilla Firefox - Resolution:: 1024x768</b></font></center></body></html>[/code]But only if this is in there, for some odd reason:[code]if ($UID == 1) {echo "[admin]";} else {echo "[guest]";}[/code]Could anyone explain to me why? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 19, 2006 Share Posted March 19, 2006 Because you cant send headers/set cookies when something has been outputted before the uses of header/session_start or setcookie, ie HTML or spaces. Quote Link to comment 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.