Hi there,
First post here, but i’m having a real problem.
I’m trying to display some user data on my web page once a user logs in, such as username country and an avatar.
But for some reason, no matter who logs on i get the same user profiles picture and data pop up.
Could you guys have a qucik look through my code and see where i’m going wrong, or if i’ve made a bit of a hash of it.
I’ve stripped away the html just phowing my php.
ok so code from the index.php
[code]<?php
start_session();
?>
" . "{$row['username']}
" . "{$row['country']}
"; echo "Not {$row['username']}? Logout"; } else { echo ""; echo ""; echo ""; echo "
"; echo "Click here to register"; echo "
"; } ?>[/code]
checklogin.php
[code]<?php
ob_start();
include (“dbconnect.php”);
// Define $myusername and $mypassword
$myusername=$_POST[‘myusername’];
$mypassword=$_POST[‘mypassword’];
$query=“SELECT * FROM members WHERE username=’$myusername’ and pass=’$mypassword’”;
$result=mysqli_query($cxn, $query);
// Mysql_num_row is counting table row
$count=mysqli_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file “login_success.php”
session_register(“myusername”);
session_register(“mypassword”);
header(“location:login_success.php”);
}
else {
echo “Wrong Username or Password”;
}
ob_end_flush();
?>
[/code]
login success.php
[code]<?php
session_start();
if(!session_is_registered(myusername))
{
header(“location:index.php”);
}
?>
[code]<?php
session_start();
session_destroy();
?>
if you can see where i’m going wrong please let me know, it’s annoying me now.
Cheers
Brucie