Jump to content

Little help pls


Sorrow

Recommended Posts

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] <?php
session_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">&nbsp;</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] <?php
session_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!!";

else

while($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
Link to comment
https://forums.phpfreaks.com/topic/36239-little-help-pls/#findComment-173814
Share on other sites

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... but

try this
[code]
<?php
session_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">&nbsp;</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]
Link to comment
https://forums.phpfreaks.com/topic/36239-little-help-pls/#findComment-173910
Share on other sites

you are trying to set the session var to the value of your submit button, set it to the username field

change [code]$_SESSION['login'] = $_POST["login"];[/code]


to [code]$_SESSION['login'] = $_POST["Username"];[/code]


and it works fine

I 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
Link to comment
https://forums.phpfreaks.com/topic/36239-little-help-pls/#findComment-174321
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.