So I have searched this site about this problem and have been tried and there is still no luck. I thought it was my 'server' (using KSWEB on my tablet, not a computer yet) so I created two normal files to split a session variable between two and it worked fine. I do not know why this is not working for both of these. I'm trying to create a login page (an unsafe, I know). The error is USED to work (this is what I have found), and now it is not. The files are below I just included the top part of admin.php because I have commented the rest. It should not really make any difference. Right now, if you submit the form without entering anything in the admin prompt, the error should be displayed next to Asteris, which says "Administrator needs to fill." Despite my best efforts, it does not work anymore and why I am completely stumped.
Log in. Php
& lt ;? Php session_start (); ? & Gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Style & gt; .error {color: # FF0000;} & lt; / Style & gt; & Lt; Script & gt; Submit function (form) {document.adminform.submit (); } & Lt; / Script & gt; & Lt; / Head & gt; & Lt ;? Php $ e_SESSION ["adminErr"] ;? & Gt; & Lt; H2 & gt; Administrator login page & lt; / H2 & gt; & Lt; Form method = "post" action = "admin.php" name = "adminform" & gt; Administrator: & lt; Input type = "text" name = "admin" style = "status: full; left: 100px" & gt; & Lt; Span class = "error" style = "position: absolute; left: 285px" & gt; * & Lt ;? Php echo $ _SESSION ["adminErr"] ;? & Gt; & Lt; / Span & gt; & Lt; Br> & Lt; Br> Password: & lt; Input type = "password" name = "password" style = "status: full; left: 100px" & gt; & Lt; Span class = "error" style = "position: absolute; left: 285px" & gt; * & Lt ;? Php echo $ _SESSION ["passwordErr"] ;? & Gt; & Lt; / Span & gt; & Lt; Br> & Lt; Br> & Lt; Button onclick = "submit form ()" & gt; Submit & lt; / Button & gt; & Lt; / Form & gt; & Lt; Br> & Lt; Br> & Lt; Br> & Lt; P & gt; & Lt ;? Php echo $ _SESSION ["flogin"] ;? & Gt; & Lt; / P & gt; & Lt; / Html & gt; & Lt ;? Php session_destroy (); ? & Gt;
Admin.php
& lt ;? Php session_start (); If ($ _SERVER ["REQUEST_METHOD"] == Post) {If (($ _ POST ["admin"])) Make sure to fill the Admin field {$ _SESSION ["adminErr"] = "admin field Should fill "; // Set error if not set header ("location: login.php"); // Return to the login page}}? & Gt;
Do not delete session at the end of the file.
& lt; / Html & gt; & Lt ;? Php session_destroy (); ? & Gt;
In addition, you should exit ;
after each header ('location: ...');
.
When sending a header, the browser is identified to change the location but the script does not end. In fact the browser does not have to follow the header, it can run with the script. You have to stop the script because the headers do not exit the script.
Comments
Post a Comment