0

i am making a login page for my website.

here is the code:

<?php
include='dbconnect.php';

$tbl_name="members"; 

$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:memberpage.php");
}
else {
echo "Wrong Username or Password";
}
?>

I DO NOT GET AN ERROR BUT nothing COMES UP.....please help!

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by hielo
0

Your php.ini settings are probably incorrect.

You should use include('dbconnect.php'); rather than include=dbconnect.php;

0

Try:

<?php
session_start();
include('dbconnect.php');

$tbl_name="members"; 

$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) or die(mysql_error());

$count=mysql_num_rows($result);

if($count==1){
//session_register("myusername");
//session_register("mypassword");
$_SESSION['myusername']=$myusername;

header("location:memberpage.php");
exit;
}
else {
echo "Wrong Username or Password";
}
?>
0

On memberpage.php you need:

<?php
session_start();
echo "hi, {$_SESSION['myusername']}!";
?>

Edited by hielo: n/a

This topic has been dead for over six months. 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.