Jump to content

What do I do after successful PHP login?


wowcrofty

Recommended Posts

About a month ago, I posted the code I was using to create a PHP/MySQL login system for my website and I received guidance on what part of it did was incorrect and how I could fix it.  I am now able to use my login page to access my MySQL database and successfully log in the user.  What I would like to know now is how I go about using the currently logged in user to display custom information on pages that changes when someone else logs in.  The application of the log in system is on a Boy Scout website and I would like to display applicable personal information when one of the boys logs in.  How would I go about doing this?  I will include all associated code from both my PHP and HTML documents for context.  I am using Microsoft Expression as my web editor.

 

(register.php)

<?

$username="xxxx";

$password="xxxx";

$database="xxxx";

$host="xxxx";

 

$user=$_POST['user'];

$pass=$_POST['pass'];

$firstname=$_POST ['firstname'];

$lastname=$_POST ['lastname'];

$email=$_POST ['email'];

 

@mysql_connect($host,$username,$password);

@mysql_select_db($database) or die("Unable to select database");

 

$query = "INSERT into users VALUES ('','$user','$pass','$firstname','$lastname','$email')";

mysql_query($query);

 

mysql_close();

?>

 

(user_registration.html)

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled 1</title>

</head>

 

<body>

<form action="register.php" method="post">

Desired User Name    <input type="text" name="user">

<br />

Desired Password     <input type="text" name="pass">

<br />

<br />

First Name                <input type="text" name="firstname" size="30">

<br />

Last Name               

<input type="text" name="lastname"

<br style="width: 187px" />

<br />

Email                       

<input type="text" name="email"

 

<br /> <br />

<br />

<input type="submit" value="Register" name="submit">

 

</form>

</body>

</html>

 

(login.php)

<?

$username="xxxx";

$password="xxxx";

$database="xxxx";

$host="xxxx";

 

$user=$_POST['user'];

$pass=$_POST['pass'];

 

@mysql_connect($host,$username,$password);

@mysql_select_db($database) or die("Unable to select database");

 

$sql="SELECT username, `password` FROM users WHERE username='$user' and `password`='$pass'";

$r=mysql_query($sql);

if(!$r){

$err=mysql_error();

print $err;

exit();

}

if(mysql_affected_rows()==0){

header("Location:user_login.html");

print "Invalid User Name/Password. Please try again";

exit();

}

else{

print "Login Successful!";

exit();

}

?>

 

 

(user_login.html)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

 

<head>

<meta http-equiv="Content-Language" content="en-us" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Troop 322 of DC: Login</title>

<style type="text/css">

.style1 {

text-align: center;

}

.style30 {

vertical-align: middle;

}

.style31 {

font-family: Arial;

}

.style32 {

margin-left: 5px;

}

.style33 {

font-family: "Arial Black";

font-size: medium;

}

</style>

</head>

 

<body style="background-color: #9E9A61">

<div class="style1">

<table style="width: 100%">

<tr>

<td>

<img alt="American Flag" src="American%20Flag.gif" width="161" height="90" /></td>

<td>

<img alt="Crest" src="Honor%20Crest.gif" width="125" height="122" class="style30" /></td>

<td>

<img alt="PA Flag" src="PA%20Flag.gif" width="152" height="96" /></td>

</tr>

<tr>

<td colspan="3">

<img alt="Banner" src="Login%20Banner.jpg" width="650" height="120" /></td>

</tr>

</table>

<br /><span class="style33">Enter the User Name and Password assigned to you

below to access personalized pages and information on the site.  If you

do not have an account, please contact one of our Webmasters and a profile

will be set up for you.<br />

</span><br />

</div>

<form method="post" action="login.php">

<div class="style1">

<span class="style31"><strong>User Name    

<input name="user" type="text" style="width: 150px" /><br />

 Password    </strong></span><strong>

<input name="pass" type="password" style="width: 153px" class="style32" /><br />

</strong>

<br />

<input name="submit" type="submit" value="Log In" /></div>

</form>

 

</body>

 

</html>

 

 

 

 

Link to comment
Share on other sites

you can get all required information for customer or user directly from mysql database by studying DBMS. you can take reference from http://dev.mysql.com/doc/refman/5.1/en/

 

I need a rundown on how to code the PHP AFTER a successful log in.  I don't need a tutorial on MySQL because the code I included works fine, but I don't know what to do with it once the user is authenticated.  Can you help me with that?

Link to comment
Share on other sites

if(mysql_affected_rows()==0){
header("Location:user_login.html");
print "Invalid User Name/Password. Please try again";
exit();
}
else{
print "Login Successful!";
exit();
}

 

to

 

if(mysql_affected_rows()==0){
header("Location:user_login.html");
print "Invalid User Name/Password. Please try again";
exit();
}
else{
header("Location:sucess.html");
print "Login Successful!";
exit();
}

 

make page called sucess.html

 

check for cookie method [easiest but risky]

or

cookie and session [best]

 

in sucess.html to make sure ppl who aint logged in can't just go to sucess.html and have access

Link to comment
Share on other sites

Sweet, I will do that.  I do have a couple more questions, however.  What do I place on the top of each member page to check whether a user is logged in or not.  If they are, it will display the page.  If not, it will take them to the login page.  Also, how do I change the content of a page based on the user that is logged in.  I am very new to PHP and I really appreciate all the assistance I am receiving.  You guys are awesome!

Link to comment
Share on other sites

well its hard to say which one you pick just cookie method or cookie and session.

 

i'll use cookie and session method.

 

add

 

// Start the session
session_start();

 

to every page that needs to check if user logged in or not  (VERY TOP OF PAGE!) lol to remove any stupid errors later.

 

umm thats the session cookie method thats about it..

 

now when you login do like

 

$_SESSION['isloggedin'] = true;

 

you can even store the username of the logged in person!

 

$_SESSION['user'] = $user;

 

and at your other pages.. just do like

 

if($_SESSION['isloggedin']) {
echo "HELLO $user!";
}

simple isn't it?

 

it creates a saved cookie on your computer with a SESSION ID token that token is sent to every page you visit and php checks if that token exists in the saved sessions folder if it matches up it gives back the array of isloggedin being true and user being your username.

 

so its still not that secure someone can just steal your cookie and the token and put that token in their cookie on their computer and be logged in your account! thats why you need to add ip checking..

 

session + cookie method is more complicated you see but

 

just cookie stores user and isloggedin on your own computer each page you visit not on php.. like instead ppl can just have token but if you store everything in cookies ppl can even get your password!.

 

very risky both ways but just using cookie method is the riskiest of all risks

so add ip checking too but then again people can even hack that  by spoofing their ip! haha you still not protected everything can be hacked.. nothing is protected 100% if a hacker is really determined thats why they got FBI etc.

 

Last week for just kicks i hacked a MMORPG the hack was simple I spoofed my ip of the player who was connected on game server and i sent a packet with his SOURCE IP to DEST server and what happened? he dropped his items in game it was quite funny i returned the items but that was just to prove that.

 

Internet signals are just energy no router cares where they come from they just accept them or reject them.. they are just electricity LOL WOAH i got carried away hits Save!

Link to comment
Share on other sites

My login.php now looks like:

 

<?php
session_start();

$username="xxx";
$password="xxx";
$database="xxx";
$host="xxx";

$user=$_POST['user'];
$pass=$_POST['pass'];

@mysql_connect($host,$username,$password);
@mysql_select_db($database) or die("Unable to select database");

$sql="SELECT username, `password` FROM users WHERE username='$user' and `password`='$pass'";
$r=mysql_query($sql);
if(!$r){
$err=mysql_error();
print $err;
exit();
}
if(mysql_affected_rows()==0){
header("Location:user_login.htm");
print "Invalid User Name/Password. Please try again";
exit();
}
else{
header("Location:memberhome.htm")
$_SESSION['isloggedin'] = true;
$_SESSION['user'] = $user;
exit();
}
?>

And, the page that it refers to after successful login (memberhome.html):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">

<?
session_start();
?>


<head>
      <LINK href="main.css" type="text/css" rel="stylesheet" />
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
.style1 {
text-align: center;
}
.style2 {
text-align: center;
font-family: "Arial Black";
font-size: x-large;
}
.style3 {
font-size: large;
}
.style5 {
color: #008000;
}
.style6 {
color: #FFFFFF;
}
.style9 {
color: #0000FF;
font-family: "Arial Black";
background-color: #FFFFFF;
}
.style10 {
font-family: Arial;
}
.style11 {
border: 2px solid #FFFFFF;
}
.style12 {
border: 1px solid #000000;
}
.style13 {
border: 1px solid #000000;
text-align: center;
}
.style14 {
border-color: #000000;
border-width: 0;
}
.style15 {
border: 1px solid #FFFFFF;
background-color: #008000;
text-align:center;
}
.style16 {
font-family: Arial;
color: #008000;
}
.style17 {
font-family: "Arial Black";
}
.style18 {
font-size: large;
color: #008000;
border: 1px solid #FFFFFF;
background-color: #000000;
text-align: center;
}
.style19 {
font-weight: normal;
}
.style20 {
font-family: "Arial Black";
border-style: none;
padding: 0;
}
.style21 {
font-weight: normal;
font-family: "Arial Black";
}
.style23 {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
color: #FFFFFF;
}
.style24 {
border: 1px solid #000000;
background-color: #0000FF;
}
.style25 {
color: #000000;
}
.style26 {
border: 1px solid #000000;
font-family: Arial;
color: #008000;
}
.style27 {
font-family: "Times New Roman";
font-size: small;
}
.style28 {
text-align: left;
font-size: small;
}
.style29 {
font-size: small;
}
.style30 {
vertical-align: middle;
}
.style31 {
text-align: center;
font-family: Haettenschweiler;
font-size: large;
}
.style33 {
color: #FF0000;
}
.style36 {
color: #0000FF;
}
.style37 {
color: #FFFFFF;
font-size: x-large;
}
.style38 {
font-size: x-large;
}
.style40 {
font-family: "Times New Roman", Times, serif;
}
.style41 {
font-size: large;
color: #FF0000;
font-weight: bold;
}
.style43 {
text-align: center;
font-size: medium;
}
.style48 {
font-family: Arial;
font-size: small;
}
.style51 {
font-family: Arial, Helvetica, sans-serif;
font-size: medium;
background-color: #FFFFFF;
}
.style52 {
font-family: Arial, Helvetica, sans-serif;
background-color: #0000FF;
}
.style54 {
border: 1px solid #0000FF;
font-family: Arial, Helvetica, sans-serif;
font-size: medium;
background-color: #FFFFFF;
}
.style55 {
font-family: Arial, Helvetica, sans-serif;
font-size: medium;
background-color: #000000;
}
.style56 {
border-width: 0px;
}
.style61 {
font-family: Haettenschweiler;
color: #0000FF;
font-size: large;
}
.style62 {
font-family: Haettenschweiler;
color: #006600;
font-size: large;
}
.style64 {
background-color: #FFFF00;
}
.style65 {
background-color: #FFFFFF;
}
.style66 {
font-family: "Arial Black";
background-color: #00FFFF;
}
.style69 {
border-color: #FFFFFF;
border-width: 1px;
font-family: Arial;
color: #FFFFFF;
}
.style73 {
border-color: #008000;
border-width: 0;
}
.style81 {
border-width: 0;
}
.style82 {
text-align: left;
}
.style83 {
border: 1px solid #333333;
}
</style>

<script type="text/javascript" src="tooltip.js">
</script>
<link rel="stylesheet" href="tooltip.css" type="text/css" /> 

<title>Boy Scout Troop 322 of Dickson City, PA</title>
</head>

<body style="background-color: #9E9A61" link="green" vlink="green">
<table style="width: 100%" cellpadding="5" cellspacing="9">
<tbody>
<tr>
	<td style="width: 176px" class="style31"><span class="style33">THE FIRE 
	THAT NEVER DIES...</span><br />
	<span class="style36"><br />
	...WITH THE</span><span class="style33"> </span><span class="style37">
	SPIRIT</span><span class="style33"> </span><span class="style36"><br />
	THAT LIVES FOREVER</span>
	</td>
	<td>
	<table style="width: 100%" cellspacing="4" align="center" class="style73">
		<tbody>
		<tr>
			<td class="style1" style="width: 241px">
			<img alt="American Flag" src="American%20Flag.gif" width="161" height="90" />
			<br />
			</td>
			<td class="style1" style="width: 241px">
			<center>
			<img alt="Crest" src="Honor%20Crest.gif" width="125" height="122" class="style30" /><br />
			<br />
			</center>
			</td>
			<td class="style1" style="width: 241px">
			<img alt="PA Flag" src="PA%20Flag.gif" width="152" height="96" />
			<br />
		</td>
		</tr>
		<tr>
			<td class="style2" colspan="3" style="height: 72px">
			<table style="width: 101%; height: 119px;" class="style73" cellspacing="0">
				<tr>
					<td>
					<img alt="Home Banner" src="Home%20Banner.jpg" width="650" height="120" /></td>
				</tr>
			</table>
		</td>
	</tr>
	</tbody>
	</table>

	</td>

	<td class="style1">
	<span style="line-height:115%;
mso-ascii-theme-font:minor-latin;mso-fareast-font-family:
Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi;
mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA" class="style61">
	<br />
	</span>
	<span style="line-height:115%;
mso-ascii-theme-font:minor-latin;mso-fareast-font-family:
Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi;
mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA" class="style62">
	"INSIDE EVERY BOY LIES A DORMANT HERO.  IT IS OUR JOB TO ROUSE HIM 
	TO CONSCIOUSNESS."</span><span style="line-height:115%;
font-family:"Calibri","sans-serif";mso-ascii-theme-font:minor-latin;mso-fareast-font-family:
Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi;
mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA" class="style3"><br style="mso-special-character:line-break" />
	</span>
	<span style="font-size:11.0pt;line-height:115%;
font-family:"Calibri","sans-serif";mso-ascii-theme-font:minor-latin;mso-fareast-font-family:
Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi;
mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA">
	<![if !supportLineBreakNewLine]>
	<br style="mso-special-character:line-break" />
	<![endif]></span> 
</td>
</tr>
<tr valign="top">
	<td style="width: 176px" class="style1">
	<table style="width: 100%" class="style14">
		<tbody>
		<tr valign="middle">
			<td>
			<img alt="Eagle Logo" src="Eagle%20Logo.gif" width="143" height="109" /><br />

		</td>
		</tr>
		<tr>
			<td>
			<table style="width: 100%" cellpadding="4" class="style24">
				<tbody>
				<tr>
					<td>
					<img alt="Home Link" src="nav_buttons/Home%20Selected%20Button.png" width="150" height="30" />
				</td>
				</tr>
				<tr>
					<td>
					<a href="news.htm">
					<img alt="News Link" src="nav_buttons/News%20Normal%20Button.png" width="150" height="30" class="style56" /></a> 
				</td>
				</tr>
				<tr>
					<td>
					<a href="gallery.htm">
					<img alt="Gallery Link" src="nav_buttons/Gallery%20Nornal%20Button.png" width="150" height="30" class="style56" /></a> 
				</td>
				</tr>
				<tr>
					<td>
					<a href="achievements.htm">
					<img alt="Roster Link" src="nav_buttons/Roster%20Normal%20Button.png" width="150" height="30" class="style56" /></a></td>
				</tr>
				<tr>
					<td>
					<a href="events.htm">
					<img alt="Event Link" src="nav_buttons/Event%20Normal%20Button.png" width="150" height="30" class="style56" /></a></td>
				</tr>
				<tr>
					<td class="style1">
					<a href="about.htm">
					<img alt="History Link" src="nav_buttons/History%20Normal%20Button.png" width="150" height="30" class="style56" /></a></td>
				</tr>
				<tr>
					<td>
					<a href="contact.htm">
					</a>
					 <a href="FAQ.htm"><img alt="FAQ Link" src="nav_buttons/FAQ%20Normal%20Button.png" width="150" height="30" class="style56" /></a></td>
				</tr>
				<tr>
					<td>
					<a href="contact.htm">
					<img alt="Contact Link" src="nav_buttons/Contact%20Normal%20Button.png" width="150" height="30" class="style56" /></a></td>
			</tr>
			</tbody>
			</table>
			<br />
			<table style="width: 100%" class="style24">
				<tbody>
				<tr>
					<td>
					<a href="camping.htm">
					<img alt="Camp Info Link" src="nav_buttons/Camping%20Normal%20Button.png" width="150" height="30" class="style56" /></a> 
				</td>
				</tr>
				<tr>
					<td>
					<a href="links.htm">
					<img alt="Links Link" src="nav_buttons/Links%20Normal%20Buttton.png" width="150" height="30" class="style56" /></a> 
				</td>
			</tr>
			</tbody>
			</table>
			<br />
			<table style="width: 100%" cellpadding="3" class="style24">
				<tbody>
				<tr>
					<td class="style23">Best of the Best 
				</td>
				</tr>
				<tr>
					<td>
					<a href="eaglescouts.htm">
					<img alt="Eagle Scouts Link" src="nav_buttons/Eagle%20Scouts%20Normal%20Button.png" width="150" height="30" class="style56" /></a> 
				</td>
				</tr>
				<tr>
					<td>
					<a href="orderofthearrow.htm">
					<img alt="OA Link" src="nav_buttons/OA%20Normal%20Button.png" width="150" height="30" class="style56" /></a> 
				</td>
			</tr>
			</tbody>
			</table>


		</td>
	</tr>
	</tbody>
	</table>

	</td>

	<td class="style1"><span class="style40"><span class="style41">
	<span class="style25">
	<br />
	</span>
	<table style="width: 100%">
		<tr>
			<td><span class="style40"> 
			<? 
			if($_SESSION['isloggedin']) {
			echo "WELCOME $user!;";
			}
			?>
			</span> </td>
		</tr>
	</table>
	<br />
	</span>
	</span>
	</span>
	<table style="width: 100%">
		<tbody>
		<tr>
			<td class="style17"><span class="style25"><br />
			<span class="style38">W</span>ELCOME TO THE MEMBER&#39;S AREA!  
			Here you can track your progress towards your next rank, find 
			out the activities you must still complete to earn Merit Badges, 
			and gain access to member only content.  </span><br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<table style="width: 100%" class="style11" cellspacing="4" cellpadding="3">
				<tbody>
				<tr>
					<td class="style9"><strong>MISSION STATEMENT OF THE BOY SCOUTS OF AMERICA</strong>
				</td>
				</tr>
				<tr>
					<td class="style16">The mission of the Boy Scouts of America is to 
					prepare young people to make ethical and moral choices 
					over their lifetimes by instilling  in them the 
					values of the <strong>Scout Oath</strong> and <strong>Law.</strong>
				</td>
				</tr>
				<tr>
					<td>
					<table style="width: 100%" class="style14">
						<tbody>
						<tr valign="middle">
							<td style="width: 373px" class="style12">
							<span class="style10"><span class="style5">
							<strong>Scout Oath<br />
  </strong>
							<br />
							On my honor I will do my best<br />
							To do my duty to God and my country<br />
							and to obey the Scout Law;<br />
							To help other people at all times;<br />
							To keep myself physically strong,<br />
							mentally awake, and morally straight.</span></span><span class="style5"><br />
							<br />
							<span class="style10">
							<strong>
							<a href="scoutoath.htm" target="_blank">
									<img alt="speaker" src="Speaker%20Icon.png" width="32" height="29" class="style56" /></a></strong></span></span>
							</td>
							<td class="style13" style="width: 222px">
							<span class="style10"> <span class="style5"><strong>Scout 
							Law</strong><br />
							<br />
							A Scout is:</span></span><table style="width: 100%">
								<tbody>
								<tr valign="middle">
									<td class="style16"><a target="_blank" href="lawpointtrustworthy.htm" onmouseout="popUp(event,'trust')" onmouseover="popUp(event,'trust')" onclick="return true" style="text-decoration:none">Trustworthy</a></td><td class="style16"><a target="_blank" href="lawpointobedient.htm" onmouseout="popUp(event,'obedient')" onmouseover="popUp(event,'obedient')" onclick="return true" style="text-decoration:none">Obedient</a>
								</td>
								</tr>
								<tr>
									<td class="style16"><a target="_blank" href="lawpointloyal.htm" onmouseout="popUp(event,'loyal')" onmouseover="popUp(event,'loyal')" onclick="return true" style="text-decoration:none">Loyal</a>
									</td>
									<td class="style16"><a target="_blank" href="lawpointcheerful.htm" onmouseout="popUp(event,'cheerful')" onmouseover="popUp(event,'cheerful')" onclick="return true" style="text-decoration:none">Cheerful</a>
								</td>
								</tr>
								<tr>
									<td class="style16"><a target="_blank" href="lawpointhelpful.htm" onmouseout="popUp(event,'helpful')" onmouseover="popUp(event,'helpful')" onclick="return true" style="text-decoration:none">Helpful</a>
									</td>
									<td class="style16"><a target="_blank" href="lawpointthrifty.htm" onmouseout="popUp(event,'thrifty')" onmouseover="popUp(event,'thrifty')" onclick="return true" style="text-decoration:none">Thrifty</a></td>
								</tr>
								<tr>
									<td class="style16"><a target="_blank" href="lawpointfriendly.htm" onmouseout="popUp(event,'friendly')" onmouseover="popUp(event,'friendly')" onclick="return true" style="text-decoration:none">Friendly</a>

									</td>

									<td class="style16"><a target="_blank" href="lawpointbrave.htm" onmouseout="popUp(event,'brave')" onmouseover="popUp(event,'brave')" onclick="return true" style="text-decoration:none">Brave</a>
								</td>
								</tr>
								<tr>
									<td class="style16"><a target="_blank" href="lawpointcourteous.htm" onmouseout="popUp(event,'corteous')" onmouseover="popUp(event,'corteous')" onclick="return true" style="text-decoration:none">Courteous</a>

									</td>

									<td class="style16"><a target="_blank" href="lawpointclean.htm" onmouseout="popUp(event,'clean')" onmouseover="popUp(event,'clean')" onclick="return true" style="text-decoration:none">Clean</a>
								</td>
								</tr>
								<tr>
									<td class="style16"><a target="_blank" href="lawpointkind.htm" onmouseout="popUp(event,'kind')" onmouseover="popUp(event,'kind')" onclick="return true" style="text-decoration:none">Kind</a>

									</td>

									<td class="style16"><a target="_blank" href="lawpointreverent.htm" onmouseout="popUp(event,'reverent')" onmouseover="popUp(event,'reverent')" onclick="return true" style="text-decoration:none">Reverent</a>
								</td>
							</tr>
							</tbody>
							</table>
							<span class="style5">
							<br />
							<span class="style48">(Hoover over a law for the 
							definition as it relates to Scouting.  
							Click for more information.)</span></span><br />

						</td>
						</tr>
						</tbody>
						</table>

				</td>
			</tr>
			</tbody>
			</table>

		</td>
	</tr>
	</tbody>
	</table>
	<br />
	<img alt="Boy Scout Logo" src="Boy%20Scout%20Logo.png" width="105" height="103" /><br />
	<br />
	<table style="width: 100%" class="style11" cellspacing="4" cellpadding="3">
		<tbody>
		<tr>
							<td class="style9">VISION STATEMENT OF THE BOY 
							SCOUTS OF AMERICA
							</td>
		</tr>
		<tr>
							<td class="style26">
							<p>The Boy Scouts of America is the nation's 
							foremost youth program of character development 
							and values-based leadership training. <br />
							<br />
							In the future, Scouting will continue to</p>
							<table style="width: 100%">
								<tbody>
								<tr>
									<td>
									<ul>
										<li>Offer young people responsible 
										fun and adventure</li>
										<li>Instill in young people lifetime 
										values and develop in them ethical 
										character as expressed in the Scout  
										Oath and Law</li>
										<li>Train your people in 
										citizenship, service, and leadership</li>
										<li>Serve America's communities and 
										families with its quality values-based program</li>
									</ul>

								</td>
							</tr>
							</tbody>
							</table>


							</td>
	</tr>
	</tbody>
	</table>
	<br />
	<img alt="Boy Scout Logo" src="Boy%20Scout%20Logo.png" width="105" height="103" /><br />
	<br />
	<table style="width: 100%" class="style15" cellpadding="6">
		<tbody>
		<tr>
			<td style="width: 769px; height: 67px;" class="style18"><span class="style20">THE NEWS SCOUT</span><span class="style21"><strong class="style19"><br />
			</strong></span><span class="style20">What's Happening Within the Troop?</span>
		</td>
		</tr>
		<tr>
			<td style="width: 769px" class="style69"><strong>February 8, 2010</strong><br />
			<br />
			<span class="style10">The Klondike Derby at Goose Pond is on 
			Saturday, February 13, 2010 this year.  As is typical, we 
			will meet at the Primitive Methodist Church and carpool to Goose 
			Pond.  More information will be posted as it becomes 
			available.</span></td>
		</tr>
		<tr>
			<td style="width: 769px" class="style69"><strong>January 5, 2010<br />
			<br />
			</strong>The Winter Campout at Goose Pond is rapidly 
			approaching!  Please take a minute to review the list of items 
			that should and should not be brought on the <em>Camping</em> 
			page and we eagerly look forward to seeing everyone there.</td>
		</tr>
	</tbody>
	</table>
	<br />

	<img alt="Boy Scout Logo" src="Boy%20Scout%20Logo.png" width="105" height="103" /><br />
	<br />
	<br />
	<center><table style="width: 85%" class="style11">
		<tbody>
		<tr>
			<td class="style52"><span class="style37"><strong>Q</strong></span><span class="style6"><strong>UESTIONS, 
			COMMENTS, OR SUGGESTIONS ABOUT THE SITE?</strong></span>
		</td>
		</tr>
		<tr>
			<td class="style54"><br />
			<strong>SIGN/VIEW OUR GUESTBOOK<br />
			<br />
			</strong>Click here <em>(Coming Soon - Promise)</em><br />
			<br />

		</td>
		</tr>
		<tr>
			<td class="style51"><strong>OR</strong>
		</td>
		</tr>
		<tr>
			<td class="style54"><br />
			<strong>EMAIL THE WEBMASTERS</strong><br />
			<br />
			Click
			<a target="_blank" href="contact_webmaster.htm">here</a><br />
			<br />

		</td>
		</tr>
		<tr>
			<td class="style55">
			<strong><span class="style6">THANK YOU IN ADVANCE FOR YOUR FEEDBACK!</span></strong>
		</td>
	</tr>
	</tbody>
	</table></center>
	<br />
	<br />
	<a href="http://www.reliablecounter.com" target="_blank"><img src="http://www.reliablecounter.com/sample.php?page=www.troop322dc.com&digit=style/shadows/34/&reloads=1" alt="Free Web Counters" border="0"></a><br><br />


	</td>


	<td class="style1">
	<br />
	<br />
	<br />
	<table style="width: 100%" class="style11">
		<tbody>
		<tr>
			<td class="style66">
			<table style="width: 100%" class="style65">
				<tbody>
				<tr>
					<td class="style29">COUNTDOWN TO</td>
				</tr>
			</tbody>
			</table>
			<br />
			SUMMER CAMP 2010<br />
			<span class="style29">AT GOOSE POND <br />
			<br />
			</span>
			<table style="width: 100%" class="style64">
				<tbody>
				<tr>
					<td><font face="arial" size="x-small"><script type="text/javascript" language="javascript">
TargetDate = "07/04/2010 12:00 AM";
BackColor = "light blue";
ForeColor = "black";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
FinishMessage = "PREPARE FOR A WEEK OF FUN AND LEARNING!";
</script>
<script type="text/javascript" language="javascript" src="timer_countdown.js"></script></font></td>
				</tr>
			</tbody>
			</table>
			</td>
		</tr>
	</tbody>
	</table>
	<br />
	<br />	
<table style="width: 100%">
	<tr>
		<td><map name="FPMap0" id="FPMap0">
		<area href="recruitment.htm" shape="rect" coords="7, 203, 185, 236" />
		</map>
		<img alt="Recuritment Graphic" src="Recuritment%20Graphic.png" width="189" height="241" usemap="#FPMap0" class="style81" /></td>
	</tr>
</table>

	<br />

	<br />
	<table style="width: 100%">
		<tr>
			<td>
	<div style="text-align: right; width: 170;"><form action="http://free-website-polls.com/poll.php" method="POST">
		<table width="170" cellpadding="2" cellspacing="0" border="0" style="background-color: #008800; " class="style83">
<tr><td align="center" colspan="2" style="color: #ffffff; font-family: Arial; font-weight: bold;">A major part of Scouting involves becoming in tune with nature.  Do you think more activities such as camping out in the woods should be added to our schedule?<br><br></td></tr>
<tr><td><input type="radio" name="answer[]" id="answer2968" value="2968"></td>
<td width="100%" class="style82"><label for="answer2968" style="color: #ffffff; font-family: Arial;">Yes.</label></td></tr>
<tr><td><input type="radio" name="answer[]" id="answer2966" value="2966"></td>
<td width="100%" class="style82"><label for="answer2966" style="color: #ffffff; font-family: Arial;">No.</label></td></tr>
<tr><td><input type="radio" name="answer[]" id="answer220507" value="220507"></td>
<td width="100%" class="style82"><label for="answer220507" style="color: #ffffff; font-family: Arial;">What are we talking about?</label></td></tr>
<tr><td colspan="2" align="center">
<br><input type="submit" value="Vote" style="border: 1px #333333 solid;"><br><br>
<a href="http://free-website-polls.com/poll.php?show_poll=78800" target="_blank" style="color: #ffffff; font-weight: bold;">View Results</a>
<input type="hidden" name="poll_id" value="78800"></td></tr>
</table></form></div>			</tr>
	</table>
	<br />
<br /><br />
	<br />

</td>
</tr>
</tbody>
</table>

<p class="style43"> <img alt="100 Year Banner" src="100%20Year%20Banner.jpg" width="380" height="77" /><br />
<br />
Home | <a href="news.htm">News</a> | <a href="gallery.htm">
Gallery</a> | <a href="events.htm">Events</a> | <a href="about.htm">About</a> |
<a href="contact.htm">Contact</a> | <a href="camping.htm">Camping Information</a> 
| <a href="links.htm">Links</a> | <a href="eaglescouts.htm">Eagle Scouts</a> |
<a href="orderofthearrow.htm">Order of the Arrow</a></p>
<p class="style1"> </p>
<p class="style1"><span class="style29">Copyright </span><span class="style27">© 
2010 Graphical Insights</span></p>
<p class="style28">Last updated Saturday, April 3, 2010 7:59 PM</p>

</body>

</html>

 

Do I have the syntax right in both?  Also, how do I change what is displayed on the memberhome and subsequent pages based on who is logged in.  Can I do it with the GET method in PHP and how would I go about doing it?

 

 

 

Link to comment
Share on other sites

when you check the user's password against the one in the database, you should pull the entire row from the database and then populate some session variables to use

 

 


<?php
session start();
include("MySQL_Connection.php");

$Query = 'SELECT * FROM Members WHERE Username="' . $_POST['Username'] . '"';
$Result = mysqli_query($Connection, $Query);
$Row = mysqli_fetch_array($Result);

if ( /*passwords match*/ )
{
$_SESSION['Authorization'] = 1;
$_SESSION['FirstName'] = $Row['FirstName'];
$_SESSION['AccountLevel'] = $Row['AccountLevel'];
}

?>

 

then check at the top of each page to see that $_SESSION['Authorization'] is set to 1, which you probably already do.

 

then since you already have account level and first name saved into session variables upon login, you can do something like:

 

echo 'Welcome, ' . $_SESSION['AccountLevel'] . ': ' . $_SESSION['FirstName'] . '.';

 

which would print something like "Welcome, Administrator Bob"

 

i hope that makes sense.  i didn't bother reading each post so this might not even be what you're asking lol

 

Link to comment
Share on other sites

Ok, an understanding of header() function is needed here.

 

The following is backwards:

 

<?php
if(mysql_affected_rows()==0){
header("Location:user_login.htm");
print "Invalid User Name/Password. Please try again";
exit();
}
else{
header("Location:memberhome.htm")
$_SESSION['isloggedin'] = true;
$_SESSION['user'] = $user;
exit();
}

 

print "Invalid User Name/Password. Please try again";

^Will never execute as expected; neither will your $_SESSION variables 'isloggedin' and 'user', as your header() will fire and redirect before any code thereafter has a chance to execute.  You need to set your session vars BEFORE you redirect the script/user to ensure they get set.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.