homepage Welcome to WebmasterWorld Guest from 54.204.215.209
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP login-form
Redirects to the same PHP form even when logged in
geeklike




msg:3919658
 8:32 am on May 25, 2009 (gmt 0)

Hi,

My problem is this; I have a gallery that you aren't supposed to see unless you're logged into the site, which kinda works. It's just the fact that the PHP form I have that you have to log in through that doesn't work - it just redirects to the same login-form over and over again. Help, please?

This is my PHP;

session_start();
include('inc/db_connect.inc');

$us_mail = $_POST['us_mail'];
$us_pass = $_POST['us_pass'];

$query ="SELECT * FROM users WHERE us_mail = '$us_mail' and us_pass= '$us_pass'";
$result = mysql_query($query, $dbc) ;
$row = mysql_fetch_assoc($result);
$number_of_users = mysql_num_rows($result);

if($number_of_users == 0) {
$out .= "You are not authorised to view this page. Please log in."
. "<form action='gallery2.php' method='post'>"
. "<div class='box'><input type='text' name='us_mail' class='login' maxlength='60' value='Email' /><br /></div>"
. "<div class='box'><input type='text' name='us_pass' class='login' maxlength='32' value='Password' /><br /></div>"
. "<input class='btn' type='submit' value='Login' />"
. "</form>";
} elseif($number_of_users != 0) {
$out .= "<p class='loggin'>You are logged in as" . $row['us_mail'] . "<br/>"
. "<a href='logout.php'>Log out?</a></p>";

$gallery_query="SELECT * FROM gallery ORDER BY gal_id ASC";
$gallery_result=mysql_query($gallery_query);
$gallery_data = mysql_fetch_assoc($gallery_result);
mysql_data_seek($gallery_result,0);

$image = $gallery_data['gal_img'];
$size = getimagesize($image);
$height = $size[1];
$width = $size[0];

if ($height > 150) {
$width = ($width * 150 / $height);
$height = 150;
}

while ($width > 150) {
$height = ($height * 150 / $width);
$width = 150;
}

$newrow = true;
$out .="<table>";

for ($i = 0; $gallery_data = mysql_fetch_assoc($gallery_result); ++$i) {
if($newrow) {
$out .= '<tr>';
$newrow = false;
}

$out .= "<td class='img'>"
. "<a href='" . $gallery_data['gal_img'] . "'>"
. "<img src='" . $gallery_data['gal_img'] . "' width='" . $width . "px' height='" . $height . "px' alt='" . $gallery_data['gal_name'] . "'/>"
. "</a>"
. "</td>";

if($i % 3 == 0) {
$out .= "</tr>";
$newrow = true;
}

$out .= "</tr>"
. "</table>";
}
}

 

abidshahzad4u




msg:3919861
 6:41 pm on May 25, 2009 (gmt 0)

Please make modification at

if($number_of_users == 0) {
//Your code for re login }
else {
//Your code for gallery
}

geeklike




msg:3919926
 9:01 pm on May 25, 2009 (gmt 0)

It still goes directly to the login function after logging in

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved