Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot modify header information - headers already sent
    text
    copied!<p>I know that this is well known problem but I've tried all solutions with no avail :(</p> <p>Here is my code: </p> <pre><code>&lt;?php ob_start(); if (!empty($_POST)) { // if submit $username = $_POST['username']; $userpass = $_POST['userpass']; mysql_connect('localhost', 'root', 'root') or die(mysql_error()); mysql_select_db('ita4') or die($connection_error); function login($username, $userpass) { $sqlQuery = "SELECT COUNT(userid) FROM users WHERE name='$username' AND password='$userpass' AND admin='t'"; $runQuery = mysql_query($sqlQuery); return (mysql_result($runQuery, 0) == 1) ? TRUE : FALSE; } if(login($username, $userpass)) { setcookie("username", $username, time()+60*60*24*30); $_COOKIE['username'] = $username; echo "Me:".$_COOKIE['username']; //echo "&lt;script&gt; location.replace('done.html'); &lt;/script&gt;"; } else { echo "&lt;script&gt; alert('Your input data is not found!'); &lt;/script&gt;"; } } ?&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Login&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="style.css"&gt; &lt;meta http-equiv=content-type content="text/html; charset=UTF-8"/&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="upper"&gt; &lt;a href="index.html"&gt;Home&lt;/a&gt; &amp;nbsp;•&amp;nbsp; &lt;a href="login.html"&gt;Login&lt;/a&gt; &amp;nbsp;•&amp;nbsp; &lt;a href="about.html"&gt;About&lt;/a&gt; &lt;/div&gt; &lt;div id="container"&gt; &lt;div id="loginDiv"&gt; &lt;form action="login.php" onsubmit="return checkEmpty()" method="post" name="loginForm"&gt; &lt;table&gt; &lt;tr&gt; &lt;td style="width:100px"&gt;Name: &lt;/td&gt; &lt;td&gt; &lt;input name="username" id="username" type="text" style="width:250px"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="width:100px"&gt;Password: &lt;/td&gt; &lt;td&gt; &lt;input name="userpass" id="userpass" type="password" style="width:250px"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2" style="text-align:center"&gt;&lt;input id="loginImg" type="image" src="images/loginButton.png"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="lower"&gt; &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;p style="text-align:center"&gt;COPYRIGHTS © 2013 &amp;nbsp;&amp;nbsp;•&amp;nbsp;&amp;nbsp; WWW.HISHAM.WS&lt;/p&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; function checkEmpty() { var username = document.getElementById("username").value; var userpass = document.getElementById("userpass").value; if(username=="" || username==null) { alert("You've to enter your name!"); } else if(userpass=="" || userpass==null) { alert("You've to enter a password!"); } else { return true; } return false; } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload