Hi everybody,
I am new to MySQL. It's been almost 3 days to find a solution. Actually I have a member's area.
I want to display the current user's details. Like when someone logs in, he see his specific code that is defined at the database. I managed to display the username and id .
I had made a column say val in my database, If i put val's value to 1 The user should see "verified" or else "not verified"
Please help me, any help will be strongly appreciated
Thanks in advance.
Here are my codes
Login.php:
<?php
session_start();
include "dbConfig.php";
if ($_GET["op"] == "login")
{
if (!$_POST["username"] || !$_POST["password"])
{
die("You need to provide a username and password.");
}
$username = $_POST['username'];
$password = $_POST['password'];
$q = "SELECT * FROM `master_users` WHERE e_mail = '$username' AND pass = MD5('$password')";
$r = mysql_query($q);
if ( $obj = @mysql_fetch_object($r) )
{
$_SESSION["valid_id"] = $obj->id;
$_SESSION["valid_user"] = $_POST["username"];
Header("Location: members.php");
}
else
{
die("Sorry, could not log you in. Wrong login information.");
}
}
else
{
echo '<html>';
echo '<head>';
echo '<title>Login To Your Status Account</title>';
echo '</head>';
echo '<body style="background-color:#0189c3">';
echo "<p> </p>";
echo "<p> </p>";
echo '<center><h1><font face="Tahoma" color="#FFFFFF"><font="Tahoma"> <font size="6">';
echo '<body id="login"><div class="login-container"><div id="Loginbox">';
echo "<p> </p>";
echo "<p> </p>";
echo '<font color="black">LOGIN</font>';
echo "<form action=\"?op=login\" method=\"POST\">";
echo "Username: <input name=\"username\" size=\"15\" class=\"text big\" value=\" Your Email\" onBlur=\"if (this.value == '')
{this.value = ' Your Email';}\"
onfocus=\"if (this.value == ' Your Email')
{this.value = '';}\"><br />";
echo "<p> </p>";
echo "Password: <input type=\"password\" name=\"password\" size=\"15\" class=\"text big\" value=\" Your Password\" onBlur=\"if (this.value == '')
{this.value = ' Your Password';}\"
onfocus=\"if (this.value == ' Your Password')
{this.value = '';}\"><br />";
echo "<p> </p>";
echo "<input type=\"submit\" name=\"btnLogin\" id=\"btnLogin\" style=\"width:154px; height:34px;\" value=\"Login\">";
echo "</form>";
echo '</body>';
echo '</html>';
}
?>
Members.php:
<?php
session_start();
include "dbConfig.php";
if (!$_SESSION["valid_user"])
{
Header("Location: login.php");
}
// ...
echo '<html>';
echo '<head>';
echo '<title>Your Status Account</title>';
echo '</head>';
echo '<body style="background-color:#0189c3">';
echo "<p> </p>";
echo "<p> </p>";
echo "<p> </p>";
echo "<p> </p>";
echo "<p> </p>";
echo '<center><h1><font face="Tahoma" color="#FFFFFF"><font="Tahoma"> <font size="6">';
echo '<body id="login"><div class="login-container"><div id="Loginbox">';
echo "<p>User ID: " . $_SESSION["valid_user"];
echo "<p>Username: " . $_SESSION["valid_user"];
echo "<p>Logged in: " . date("m/d/Y", $_SESSION["valid_time"]);
echo '</font>';
echo "<font color=\"black\"><p>Status: Not Verified</font></p>";
echo '</body>';
echo '</html>';
echo "<p><a href=\"logout.php\">Click here to logout!</a></p>";
?>
MySQL server version -- 5.1.63
No Errors
Everything else has been mentioned and rest I dont know where to get cuz I am a newbie,
PLEASE HELP