seksislav Posted February 18, 2008 Share Posted February 18, 2008 Hello everybody, I feel a bit embarrassed now for asking the most retarded questions ever. So my problem is when I check if the user is logged it i echo a welcome message to the user. If not then i'll proc a login form. Till there everything is OK but when i press the "LOGIN" button it dose not process the form. <? if(!$session->logged_in){ echo ' <tr class="user_menu"> <td height="26" ><div align="left"> <form action="process.php" method="post"> <input type="text" class="login" name="user" maxlength="30" value="Username"> <input type="password" class="login" name="pass" maxlength="30" value="Password"> <input type="hidden" name="sublogin" value="1"> <input type="button" class="login_button" value="Login" > </form></div></td> <td height="26" colspan="2" class="messages">Forgot password? Register<div align="right"></div></td> </tr>';} else { echo '<tr class="user_menu"> <td height="26" ><div align="left"> Welcome '.$session->username.' </div></td> <td> <a href="process.php">Logout</a> </td> <td height="26" colspan="2" class="messages"><div align="right">You have (0) new messages. </div></td> </tr>'; } ?> .. -.- please do help me Quote Link to comment Share on other sites More sharing options...
uniflare Posted February 18, 2008 Share Posted February 18, 2008 how are you processing the form? if its all in one file you could try this: <?php // Process Login if a form is submitted if($_POST['sublogin']){ // ive oput user/passes in the file to make my reply simple, not sure if your using a mysql db to store usernames or not. $users = array( "Username" => "Password", "Username2" => "Password2", "Username3" => "Password3" ); if(@$users[$_POST['username']] == $_POST['password']){ // the @ symbol supresses a T_NOTICE being displayed if a username is not found. $session->logged_in = true; $session->username = $_POST['username']; }else{ exit("Details do not match"); } } if(!$session->logged_in){ echo ' <tr class="user_menu"> <td height="26" ><div align="left"> <form action="process.php" method="post"> <input type="text" class="login" name="user" maxlength="30" value="Username"> <input type="password" class="login" name="pass" maxlength="30" value="Password"> <input type="hidden" name="sublogin" value="1"> <input type="button" class="login_button" value="Login" > </form></div></td> <td height="26" colspan="2" class="messages">Forgot password? Register<div align="right"></div></td> </tr>'; }else{ echo '<tr class="user_menu"> <td height="26" ><div align="left"> Welcome '.$session->username.' </div></td> <td> <a href="process.php">Logout</a> </td> <td height="26" colspan="2" class="messages"><div align="right">You have (0) new messages. </div></td> </tr>'; } ?> this is a very simple solution to a login, i see your using a class stored in $session. Quote Link to comment Share on other sites More sharing options...
seksislav Posted February 18, 2008 Author Share Posted February 18, 2008 I just wanna figure out why when I press the login button nothing happens when the syntax is correct :/ Quote Link to comment Share on other sites More sharing options...
suttercain Posted February 18, 2008 Share Posted February 18, 2008 Change <input type="button" class="login_button" value="Login" > to <input type="submit" class="login_button" value="Login" name="submit"> Quote Link to comment Share on other sites More sharing options...
seksislav Posted February 18, 2008 Author Share Posted February 18, 2008 Change <input type="button" class="login_button" value="Login" > to <input type="submit" class="login_button" value="Login" name="submit"> nope mate. Not working. is it possible the problem to be cuz i have class-es? Quote Link to comment Share on other sites More sharing options...
uniflare Posted February 18, 2008 Share Posted February 18, 2008 do you get a completely blank page when you click login? if so check your php.ini (or use ini_get() ) and see if "display_errors" is on or off. ---------------- also, i tyhink we need more information like the classes your using? the session class and any class that session class uses would be quite helpful in diagnosing the problem... Quote Link to comment Share on other sites More sharing options...
seksislav Posted February 19, 2008 Author Share Posted February 19, 2008 do you get a completely blank page when you click login? if so check your php.ini (or use ini_get() ) and see if "display_errors" is on or off. ---------------- also, i tyhink we need more information like the classes your using? the session class and any class that session class uses would be quite helpful in diagnosing the problem... nope. The login is working on another page but not on this one. I started by doing the mysql tables , then the code and finaly the design. I'm at the design stage. If i use the old shit without any tables, images or whatever its working :/ if u put tables and other stuff it dosnt. Quote Link to comment Share on other sites More sharing options...
seksislav Posted February 19, 2008 Author Share Posted February 19, 2008 Change <input type="button" class="login_button" value="Login" > to <input type="submit" class="login_button" value="Login" name="submit"> Ok i'm sorry i need to start reading. It worked ofc!! thx 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.