web page loading

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

BandanaChaudhury
New php-forum User
New php-forum User
Posts: 22
Joined: Fri Jun 22, 2012 9:14 am

web page loading

Postby BandanaChaudhury » Mon Oct 15, 2012 10:38 am

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.

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: web page loading

Postby seandisanti » Mon Oct 15, 2012 11:17 am

I'm sorry, what part are you looking help for, redirecting to member.php, or getting their data to display on member page?

BandanaChaudhury
New php-forum User
New php-forum User
Posts: 22
Joined: Fri Jun 22, 2012 9:14 am

Re: web page loading

Postby BandanaChaudhury » Tue Oct 16, 2012 1:58 am

redirecting to member.php

User avatar
simplypixie
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire
Contact:

Re: web page loading

Postby simplypixie » Tue Oct 16, 2012 5:52 am

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
}

BandanaChaudhury
New php-forum User
New php-forum User
Posts: 22
Joined: Fri Jun 22, 2012 9:14 am

Re: web page loading

Postby BandanaChaudhury » Tue Oct 16, 2012 6:59 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.

User avatar
simplypixie
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire
Contact:

Re: web page loading

Postby simplypixie » Tue Oct 16, 2012 7:05 am

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.


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron