I am doing member login program,
i write the form code in one file(let login.php), and give its link to another file(let check.php) where it can check for validity.
if the user exist, then it will load a member page(let member.php).
I don't know how to do that.
Please help me.
web page loading
Moderators: egami, macek, gesf
-
- php-forum Fan User
- Posts: 973
- Joined: Mon Oct 01, 2012 12:32 pm
I'm sorry, what part are you looking help for, redirecting to member.php, or getting their data to display on member page?
-
- New php-forum User
- Posts: 22
- Joined: Fri Jun 22, 2012 9:14 am
redirecting to member.php
- simplypixie
- php-forum Active User
- Posts: 300
- Joined: Sun Dec 11, 2011 12:51 am
- Location: Shrewsbury, Shropshire
- Contact:
Code: Select all
if ($user_authenticated) //use whatever you are using to check user is authenticated, this is just an example
{
header("location: member.php");
} else {
// Do something else here
}
-
- New php-forum User
- Posts: 22
- Joined: Fri Jun 22, 2012 9:14 am
<?php
include("common.php");
session_start();
$username = $_POST['username'];
$password = md5($_POST['password']);
if($username&&$password)
{
$connect = mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("travelpoint") or die(mysql_error());
$query = mysql_query("SELECT * FROM register WHERE username='$username'");
$numrows = mysql_num_rows($query);
if($numrows!=0)
{
//code to login
while($row = mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
}
//check to see if they match
if($username==$dbusername&&$password==$dbpassword)
{
header("location: member.php");
1 //echo"You're in! <a href='member.php'>Click</a> here to enter the memeber page!";
$_SESSION['username']=$username;
}
else
die("Incorrect Password!");
}
else
{
echo "That user doesn't exist!";
echo "You have to register first, click the link below";
echo "<a href='../../Travelpoint.com/register.php'><img src='../../images/Register.gif'></a>";
}
}
else
die("Please enter username and password");
?>
If i write it in the place of 1 then it is showing a error msg like
"Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\Travelpoint.com\common.php:199)"
What to modify, i am not getting it.
include("common.php");
session_start();
$username = $_POST['username'];
$password = md5($_POST['password']);
if($username&&$password)
{
$connect = mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("travelpoint") or die(mysql_error());
$query = mysql_query("SELECT * FROM register WHERE username='$username'");
$numrows = mysql_num_rows($query);
if($numrows!=0)
{
//code to login
while($row = mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password'];
}
//check to see if they match
if($username==$dbusername&&$password==$dbpassword)
{
header("location: member.php");
1 //echo"You're in! <a href='member.php'>Click</a> here to enter the memeber page!";
$_SESSION['username']=$username;
}
else
die("Incorrect Password!");
}
else
{
echo "That user doesn't exist!";
echo "You have to register first, click the link below";
echo "<a href='../../Travelpoint.com/register.php'><img src='../../images/Register.gif'></a>";
}
}
else
die("Please enter username and password");
?>
If i write it in the place of 1 then it is showing a error msg like
"Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\Travelpoint.com\common.php:199)"
What to modify, i am not getting it.
- simplypixie
- php-forum Active User
- Posts: 300
- Joined: Sun Dec 11, 2011 12:51 am
- Location: Shrewsbury, Shropshire
- Contact:
You must ensure a header redirects happen before you output any html on a page so if you have anything above your php it will not work. If you want to use the echo statement with a link then just do that instead.