0
$myusername=mysql_real_escape_string($_POST['myusername']);

Has to be that way - you must sanitize input.

{
echo "<tr>";
echo "<td>" .$row['firstname'] ."</td>";
echo "<td>" .$row['lastname'] ."</td>";
echo "<td>" .$row['Age'] ."</td>";
echo "<td>" .$row['gender'] ."</td>";
echo "<td>" .$row['address'] ."</td>";
echo "<td>" .$row['email'] ."</td>";
echo "<td>" .$row['username'] ."</td>";
echo "<td>" .$row['typeofbusiness'] ."</td>";
echo "<td>" .$row['businessname'] ."</td>";
echo "<td>" .$row['businesslocation'] ."</td>";
echo "<td>" .$row['typesofservices'] ."</td>";
 
echo "</tr>";
}

get rid of the braces { } - they serve no purpose.

You mentioned that some code worked - show that too.

Edited by diafol: n/a

0

Ok i tried it, it stills gives me an empty row.

And what i just said its working im using the same codes i posted. But you now what i did i went to the database added a row with nothing in it, so whatever username or password i write it just shows me that row with age and address 0 since that what the database has.

Edited by Jollyyy100: n/a

0

Ok i tried it, it stills gives me an empty row.

And what i just said its working im using the same codes i posted. But you now what i did i went to the database added a row with nothing in it, so whatever username or password i write it just shows me that row with age and address 0 since that what the database has.

Post the form Code as well as your table and its contents

0

This is the form part:

<body>

<div id="Layer5">
  <table width="750" border="0" align="center">
    <tr>
      <td><img src="../Pictures/Header - png.png" alt="1" width="995" height="226" /></td>
    </tr>
    <tr>
      <td><form id="form1" name="form1" method="post" action="checklogin.php">
          <table width="996" border="0">
            <tr>
              <td width="561"><div align="right"><span class="style6">USERNAME: </span></div></td>
              <td width="157"><div align="right"><span class="style6">
                  <input name="myusername" type="text" id="myusername" size="26" />
              </span></div></td>
              <td width="92"><div align="right"><span class="style6">PASSWORD:</span></div></td>
              <td width="158"><div align="right">
                  <input name="mypassword" type="password" id="mypassword" size="26" />
              </div></td>
            </tr>
            <tr>
              <td colspan="4"><div align="right"><a href="Register.html" class="style16" onmouseover="MM_swapImage('Upload','','../Pictures/Uploadro.png',1)" onmouseout="MM_swapImgRestore()"></a>
                      <input name="Submit" type="submit" onclick="MM_validateForm('myusername','','R','mypassword','','R');return document.MM_returnValue" value="Login" />
                </div>
                  <label>
                  <div align="right" class="style17"><span class="style18"><a href="Register.html">Signup Here</a> </span></div>
                  </label></td>
            </tr>
            <tr>
              <td colspan="4"><div align="right"></div></td>
            </tr>
          </table>
      </form></td>
    </tr>
    <tr>
      <td align="right"><div align="right">
	  
        <style type="text/css">
.clockStyle {
	background-image: url(../Pictures/Background%20-%20png.png)
	border:0;
	padding:6px;
	color:#FFFFFF;
	font-family:"FootLight MT Light", Gadget, sans-serif;
        font-size:100px;
        font-weight:bold;
	letter-spacing: 2px;
	display:inline;
}
      </style>
      </div>

And this is the code for the button in the form:

<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="cascadeglobal"; // Database name
$tbl_name="registration"; // Table name


mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");


$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];


$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);


$count=mysql_num_rows($result);


if($count==1){

session_register("myusername");
session_register("mypassword");
header("location:login_success.php");

}
?>
}
else {
"Wrong username and password";
}
?>

And this is the code for the table i want data to display:

<?php

$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' .mysql_error());
}
mysql_select_db("cascadeglobal", $con);

$myusername=mysql_real_escape_string($_POST['myusername']);

$result = mysql_query("Select * from registration where username = '$myusername'");

echo "<table border='1'>
<tr>
<th> First Name </th>
<th> Last Name </th>
<th> Age </th>
<th> Gender </th>
<th> Address </th>
<th> Email </th>
<th> Username </th>
<th> Type of Business </th>
<th> Business Name </th>
<th> Business Location </th>
<th> Types of Services </th>
</tr>";
$row = mysql_fetch_array($result);

echo "<tr>";
{
echo "<td>" .$row['firstname'] ."</td>";
echo "<td>" .$row['lastname'] ."</td>";
echo "<td>" .$row['Age'] ."</td>";
echo "<td>" .$row['gender'] ."</td>";
echo "<td>" .$row['address'] ."</td>";
echo "<td>" .$row['email'] ."</td>";
echo "<td>" .$row['username'] ."</td>";
echo "<td>" .$row['typeofbusiness'] ."</td>";
echo "<td>" .$row['businessname'] ."</td>";
echo "<td>" .$row['businesslocation'] ."</td>";
echo "<td>" .$row['typesofservices'] ."</td>";
}
echo "</tr>";

echo "</table>";
mysql_close ($con);

?>

<html>
<body>
Login Successful

<p><a href="logout.php\">Click here to logout!</a></p>

</body>
</html>
0

Your last page will never display anything because $_POST doesn't exist. It is only valid for the page it is sent to originally. For this you need sessions, as I suggested in my second post. You HAVE to have session_start() at the top of EVERY page or the session will die a horrible death.

I'll give you my take:

FORM PAGE

session_start();
...
<form ...attribute as you've done...>
...controls with username and pw as you've done...
</form>

FORM HANDLER

<?php
session_start();
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="cascadeglobal"; // Database name
$tbl_name="registration"; // Table name
  
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
 
$myusername = mysql_real_escape_string($_POST['myusername']);
$mypassword = mysql_real_escape_string($_POST['mypassword']);
 
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
  $d = mysql_fetch_assoc($result);
  $_SESSION['username'] = $d['username'];
  header("location:login_success.php");
}
?>

DISPLAY PAGE

<?php
session_start();
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' .mysql_error());
}
mysql_select_db("cascadeglobal", $con);
 
$myusername=$_SESSION['username'];
 
$result = mysql_query("Select * from registration where username = '$myusername'");
$row = mysql_fetch_array($result);
$output = "<table border='1'>
<tr>
<th> First Name </th>
<th> Last Name </th>
<th> Age </th>
<th> Gender </th>
<th> Address </th>
<th> Email </th>
<th> Username </th>
<th> Type of Business </th>
<th> Business Name </th>
<th> Business Location </th>
<th> Types of Services </th>
</tr>
<tr><td>{$row['firstname']}</td>
<td>{$row['lastname']}</td>
<td>{$row['Age']}</td>
<td>{$row['gender']}</td>
<td>{$row['address']}</td>
<td>{$row['email']}</td>
<td>{$row['username']}</td>
<td>{$row['typeofbusiness']}</td>
<td>{$row['businessname']}</td>
<td>{$row['businesslocation']}</td>
<td>{$row['typesofservices']}</td>
</tr>
</table>";
mysql_close ($con);
?>
 
<html><!-- you need a proper DTD before this and a head area -->
<body>
Login Successful
 
<?php echo $output;?> 
<p><a href="logout.php\">Click here to logout!</a></p>
</body>
</html>
0

Hey thank you so very much, thank you so much...
One main error in my codes was spellings, the spelling for session was incorrect.
I had sessoin instead of sessions and didnt have the start after the session on my forms.

THANK YOU SO VERY MUCH :D

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.