PDA

View Full Version : Variable Navigation


Mac
01-25-2008, 06:18 PM
I have little piece of navigation on a few page as follows:

Help | Sign out

Potentially add more down the road.

I want to find some PHP that will allow me to just display "Help" when your on the login page. If you haven't signed in there in no need to have the "Sign out" option. Once your signed in you have the two options.

Does that make sense?

-Mac

rangana
01-25-2008, 06:47 PM
Ok, just a few questions, have you placed your Help and Signout in a <td> or in a <div>???..
It would be a lot easier if it's in a table, for example, If the sign-in button is clicked then on the PHP, it would go like,
if (isset($_POST['signin']){ then echo here help and signout}
If it's in a <td> it would be a lot simplier. Do post back.

Jake302
01-25-2008, 07:10 PM
Are you using cookies for your login?

rawad
01-29-2008, 01:56 PM
Hello guys, i'm kind of new to php so i have a small problem, and would appreciate it if someone helps,
i'm using global variables in a php script and when i run the code it keeps on giving me unexpected T_variable, this is the code:

<?php
global $person_id;
global $f_name;
global $m_name;
global $l_name;
global $ssn;
global $dist;
global $str;
global $bld;
global $phone_num;
global $gua_id;
global $username;
global $password;
$person_id = $_POST['visitor'];

$query="SELECT * FROM person WHERE person_id=$person_id";
if(!($connect=mysql_connect("localhost","root","root")))
{
die("could not open database");
}
if(!(mysql_select_db("senior_project",$connect)))
{
die("Could not open database");
}
if(!($result=mysql_query($query,$connect)))
{
Print("could not execute query");
die(mysql_error());
}
$row=mysql_fetch_array($result)


$f_name = $row['first_name'];
$m_name = $row['midle_name'];
$l_name = $row['last_name'];
$ssn = $row['ssn'];
$dist = $row['district'];
$str = $row['street'];
$bld = $row['building'];
$phone_num = $row['phone_num'];
$gua_id = $row['guardian_id'];
?>

the variable person_id is going on fine, but the rest of the variable that come after the database connection are the ones that generate the error, please some help.
Thank you.

Mac
01-29-2008, 03:26 PM
This is my code:

<div class="headerNav"><a href="#">Help</a> | <a href="#">Sign Out</a> </div>

Im open to any suggestions.

-Mac

¥åßßå
01-29-2008, 05:29 PM
Hi rawad,
it's normally considered impolite to hijack another posters thread ;)

you missed a semi-colon

$row=mysql_fetch_array($result);

¥

rangana
01-29-2008, 07:13 PM
@mac, Hi there
<div class="headerNav"><a href="#">Help</a> | <a href="#">Sign Out</a> </div>
From the quoted above, you could add this in your PHP code:
echo '<div class="headerNav"><a href="#">Help</a>';
if (isset($_cookie['cookiename'])) //Where cookiename is the name of your cookie
echo '| <a href="#">Sign Out</a>';
echo '</div>';
See if this helps.

@rawad,
Try creating a new thread, but anyway, ¥åßßå answered it for you!.