Monshery Posted June 27, 2006 Share Posted June 27, 2006 Well i will show the code. its simple - its check if session is set for the user -then if notits puts out a Login form and when the form is been sent it checks the sql database etcs. and if all is correctits set a session thats defain the user. and then on the reload its suppost to be logged in but .. not working somewhy . well please help ya you can it will be realy appriciated. even Extemly :-)[code]<?PHPif(isset($_SESSION['SUSERNAME'])){echo "welcome" .$_SESSION['SUSERNAME'];}else{?><FORM action="INDEX.PHP" method="POST"><p align="center">Username:</p><p align="center"> <input name="USERNAME" type="text" id="USERNAME" size="30" maxlength="30"></p><p align="center">Password:</p><p align="center"> <input name="PASSWORD" type="password" id="PASSWORD" size="30" maxlength="30"></p><p align="center"> <input name="LOGIN" type="submit" id="LOGIN" value="Login"> <span class="style8">-------------- </span></FORM> </p><span class="style8"><input name="REGISTER" type="submit" id="REGISTER" value="Register"></span><p> <?$MMO_LINK=mysql_connect('xxxxx','xxxxx','xxxxx') or die("Connection fail");mysql_select_db('mmodate',$MMO_LINK);$MMO_USERD = mysql_query("SELECT * FROM USERDETAIL WHERE USERNAME = '$_POST[USERNAME]'",$MMO_LINK);$MMO_LOGin = mysql_fetch_array($MMO_USERD);$CHANGEV = $_POST['USERNAME'];if(($CHANGEV == $MMO_LOGin['USERNAME']) && ($MMO_LOGin['PASSWORD'] == $_POST['PASSWORD']) && ($_POST['PASSWORD'] != null)){session_start();$_SESSION['SUSERNAME'] = $MMO_LOGin['USERNAME'];$_SESSION['SADMINL'] = $MMO_LOGin['ADMINL'];}else{echo "wrong passward or username";}}?>[/code] I just saw i get 2 error massages :[code]Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\wamp\www\Yanivs\MMO-Date\INDEX.PHP:47) in C:\wamp\www\Yanivs\MMO-Date\INDEX.PHP on line 556[/code]and - which is the same but it gave me it 2 times[code]Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\Yanivs\MMO-Date\INDEX.PHP:47) in C:\wamp\www\Yanivs\MMO-Date\INDEX.PHP on line 556[/code]THnx in advanced for helpers will be realy appriciated.I have solved it allready thnx :-) Quote Link to comment https://forums.phpfreaks.com/topic/13029-simple-login-form-that-some-how-got-complicated/ Share on other sites More sharing options...
Orio Posted June 27, 2006 Share Posted June 27, 2006 Here:[code]<?PHPsession_start();if(isset($_SESSION['SUSERNAME'])){echo "welcome" .$_SESSION['SUSERNAME'];}else{if(isset($_POST['REGISTER'])){$MMO_LINK=mysql_connect('xxxxx','xxxxx','xxxxx') or die("Connection fail");mysql_select_db('mmodate',$MMO_LINK);$MMO_USERD = mysql_query("SELECT * FROM USERDETAIL WHERE USERNAME = '$_POST[USERNAME]'",$MMO_LINK);$MMO_LOGin = mysql_fetch_array($MMO_USERD);$CHANGEV = $_POST['USERNAME'];if(($CHANGEV == $MMO_LOGin['USERNAME']) && ($MMO_LOGin['PASSWORD'] == $_POST['PASSWORD']) && ($_POST['PASSWORD'] != null)){$_SESSION['SUSERNAME'] = $MMO_LOGin['USERNAME'];$_SESSION['SADMINL'] = $MMO_LOGin['ADMINL'];die("Welcome ".$_SESSION['SUSERNAME']."!");}else{die("wrong passward or username");};};?><FORM action="INDEX.PHP" method="POST"><p align="center">Username:</p><p align="center"> <input name="USERNAME" type="text" id="USERNAME" size="30" maxlength="30"></p><p align="center">Password:</p><p align="center"> <input name="PASSWORD" type="password" id="PASSWORD" size="30" maxlength="30"></p><p align="center"> <input name="LOGIN" type="submit" id="LOGIN" value="Login"> <span class="style8">-------------- </span></FORM> </p><span class="style8"><input name="REGISTER" type="submit" id="REGISTER" value="Register"></span><p> <?};?>[/code]I hope I got no errors.Btw, you should read about SQL injections, because there's a risk in your script.Orio. Quote Link to comment https://forums.phpfreaks.com/topic/13029-simple-login-form-that-some-how-got-complicated/#findComment-50128 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.