Sorrow Posted January 29, 2007 Share Posted January 29, 2007 Hi here is what i need to do. There is a login on my page and it is in one of the table row. The thing i need to do is when i login, the input boxes needs to disappear and infos from the member appears instead. how is the best thing to do this. Quote Link to comment Share on other sites More sharing options...
chronister Posted January 29, 2007 Share Posted January 29, 2007 [code]<?phpif($_SESSION['login']){ // you may need to change this to reflect your login variable //user is logged in, query and get their information}else{//show login form}?>[/code] Quote Link to comment Share on other sites More sharing options...
trq Posted January 29, 2007 Share Posted January 29, 2007 A simple example.[code]<?php if (isset($_SESSION['logged_in'])) { // echo user details. } else { // echo form }?>[/code] Quote Link to comment Share on other sites More sharing options...
Sorrow Posted January 29, 2007 Author Share Posted January 29, 2007 ty Quote Link to comment Share on other sites More sharing options...
Sorrow Posted January 31, 2007 Author Share Posted January 31, 2007 ok I got one part working.. But i still can't get the login input box to disappear here is the code from my first page.[code] <?phpsession_start(); $_SESSION['login'] = $_POST["login"];if ($_SESSION['login'] > 0){echo "<table border='0' align='center'> <tr> <td>Username : </td> <td>" . $_SESSION['Username'] . "</td> </tr> <tr> <td>Game Handle : </td> <td>" . $_SESSION['Game_Handle'] . "</td> </tr> <tr> <td>Steam_ID : </td> <td>" . $_SESSION['Steam_ID'] . "</td> </tr> </table>";}else{echo '<form action="/profil.php" method="post"> <table width="232" border="0" cellspacing="0" cellpadding="0"> <tr valign="top"> <td width="21"> <p style="margin-top: 0; margin-bottom: 0"><img src="images/index_12.gif" width=21 height=20 alt=""></td> <td> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="95%" id="table3"> <tr> <td width="63"> <p style="margin-top: 0; margin-bottom: 0"> <font face="Tahoma" style="font-size: 8pt; font-weight: 700" color="#FFFFFF"> Username:</font></td> <td> <p style="margin-top: 0; margin-bottom: 0"> <font face="Tahoma"><span style="font-size: 8pt"> <font face="Tahoma" color="#FFFFFF"> <input name="Username" size="16" style="font-weight: 700"></font></span></font></td> </tr> <tr> <td width="63"> <p style="margin-top: 0; margin-bottom: 0"> <font face="Tahoma" style="font-size: 8pt; font-weight: 700" color="#FFFFFF"> Password:</font></td> <td> <p style="margin-top: 0; margin-bottom: 0"> <font face="Tahoma"><span style="font-size: 8pt"> <font face="Tahoma" color="#FFFFFF"> <input name="Password" size="16" style="font-weight: 700"></font></span></font></td> </tr> <tr> <td colspan="2"> <p style="margin-top: 0; margin-bottom: 0" align="center"> <font face="Tahoma" style="font-size: 8pt; font-weight: 700" color="#FF9933"> Forgot Password?</font><font face="Tahoma" style="font-size: 8pt; font-weight: 700" color="#FFFFFF"> | </font> <font face="Tahoma" style="font-size: 8pt; font-weight: 700" color="#FF9933"> <a href = "/Register.html">Register</a></font></p> <p style="margin-top: 0; margin-bottom: 0" align="center"> </p> <p style="margin-top: 0; margin-bottom: 0" align="center"> <font face="Tahoma"><span style="font-size: 8pt"> <input type="submit" value="Login" name="B2" style="font-weight: 700"></span></font></td> </tr> </table> </div> </td> </tr> </form>';}?>[/code]and this is the code for the second page cause when you login you get to the profile page:[code] <?phpsession_start();include 'db_conn.php';$_SESSION['Username']=$_POST["Username"];$_SESSION['Password']=$_POST["Password"];$result = mysql_query("SELECT * FROM users WHERE Username = '" .$_SESSION['Username']."' AND Password = '".$_SESSION['Password']."' " );$Userv = mysql_num_rows($result);if($Userv == 0)echo "There was an error in your login!!";elsewhile($row = mysql_fetch_array($result)) {$_SESSION['Username']=$row['Username'];$_SESSION['Game_Handle']=$row['Game_Handle'];$_SESSION['Steam_ID']=$row['Steam_ID'];echo '<form action="/index.php" method="post"><input type="hidden" name="login" value="1" /></form>'; echo " <table border='0' align='center'> <tr> <td>Username : </td> <td>" . $_SESSION['Username'] . "</td> </tr> <tr> <td>Game Handle : </td> <td>" .$_SESSION['Game_Handle'] . "</td> </tr> <tr> <td>Steam_ID : </td> <td>" . $_SESSION['Steam_ID'] . "</td> </tr> </table>"; }?>[/code]Anyone can help me out here pls Quote Link to comment Share on other sites More sharing options...
chronister Posted January 31, 2007 Share Posted January 31, 2007 The usernames are not integers so they are never going to be > 0 You could use strlen to see if the login string length is greater than 0... buttry this[code]<?phpsession_start(); $_SESSION['login'] = $_POST["login"];if (isset($_SESSION['login'])){echo "<table border='0' align='center'> <tr> <td>Username : </td> <td>" . $_SESSION['Username'] . "</td> </tr> <tr> <td>Game Handle : </td> <td>" . $_SESSION['Game_Handle'] . "</td> </tr> <tr> <td>Steam_ID : </td> <td>" . $_SESSION['Steam_ID'] . "</td> </tr> </table>";}else{echo '<form action="/profil.php" method="post"> <table width="232" border="0" cellspacing="0" cellpadding="0"> <tr valign="top"> <td width="21"> <p style="margin-top: 0; margin-bottom: 0"><img src="images/index_12.gif" width=21 height=20 alt=""></td> <td> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="95%" id="table3"> <tr> <td width="63"> <p style="margin-top: 0; margin-bottom: 0"> <font face="Tahoma" style="font-size: 8pt; font-weight: 700" color="#FFFFFF"> Username:</font></td> <td> <p style="margin-top: 0; margin-bottom: 0"> <font face="Tahoma"><span style="font-size: 8pt"> <font face="Tahoma" color="#FFFFFF"> <input name="Username" size="16" style="font-weight: 700"></font></span></font></td> </tr> <tr> <td width="63"> <p style="margin-top: 0; margin-bottom: 0"> <font face="Tahoma" style="font-size: 8pt; font-weight: 700" color="#FFFFFF"> Password:</font></td> <td> <p style="margin-top: 0; margin-bottom: 0"> <font face="Tahoma"><span style="font-size: 8pt"> <font face="Tahoma" color="#FFFFFF"> <input name="Password" size="16" style="font-weight: 700"></font></span></font></td> </tr> <tr> <td colspan="2"> <p style="margin-top: 0; margin-bottom: 0" align="center"> <font face="Tahoma" style="font-size: 8pt; font-weight: 700" color="#FF9933"> Forgot Password?</font><font face="Tahoma" style="font-size: 8pt; font-weight: 700" color="#FFFFFF"> | </font> <font face="Tahoma" style="font-size: 8pt; font-weight: 700" color="#FF9933"> <a href = "/Register.html">Register</a></font></p> <p style="margin-top: 0; margin-bottom: 0" align="center"> </p> <p style="margin-top: 0; margin-bottom: 0" align="center"> <font face="Tahoma"><span style="font-size: 8pt"> <input type="submit" value="Login" name="B2" style="font-weight: 700"></span></font></td> </tr> </table> </div> </td> </tr> </form>';}?>[/code] Quote Link to comment Share on other sites More sharing options...
Sorrow Posted February 1, 2007 Author Share Posted February 1, 2007 i tried it but not working ty anyway Quote Link to comment Share on other sites More sharing options...
chronister Posted February 1, 2007 Share Posted February 1, 2007 you are trying to set the session var to the value of your submit button, set it to the username fieldchange [code]$_SESSION['login'] = $_POST["login"];[/code]to [code]$_SESSION['login'] = $_POST["Username"];[/code]and it works fineI tested it on my server and the form disappeared and I got Username : Game Handle : Steam_ID:You may want to change $_SESSION['login'] to $_SESSION['Username'] because having a session var with the value of a submit button makes no sense to me.Nate Quote Link to comment Share on other sites More sharing options...
Sorrow Posted February 1, 2007 Author Share Posted February 1, 2007 ty very much it is working now 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.