Jump to content

let only 1 register user see a link


chanfuterboy

Recommended Posts

hi,

 

I try but I am doing something wrong. I want the user ' lady1 ' in table of username, be able to see a link that i called crew2.php. the rest users will not see the link, help me figur out it, in my code below

 

if(mysql_num_rows($sql) > 0){

// Loop through the results
while($row = mysql_fetch_array($sql)){
	$username = $row['username'];
	$password = $row['password'];
	$email = $row['email'];

if ($username == lady1)
	 {
	print "click, click > <a href='crew2.php'>here</a> <";
	}
else
	{

	}
	$all_stuff =  "<b>Admin name</b>:<b><font face='Tahoma' size='3'> $username</font></b> <hr size=1>

	               <br>Adm Pass: $password
	               <br>Adm email: $email";
	if($i % $tblWidth ){
		echo "<td align='center' valign='top' bgcolor='#F2F2F2'>$all_stuff</td>";
	}else{
		//else then print column number 2 etc for the next loop.
		echo "<tr></tr>";
		echo "<td align='center' cellpadding='10' valign='top' bgcolor='#F2F2F2'>$all_stuff</td>";
	}
	//add only 1 for the loop ($i).
	$i++;

 

 

Link to comment
Share on other sites

Give something like this a try, I broke your code down so it's easier to read. I took out a bunch of the echos and prints and just used HTML code instead.

<?php
if(mysql_num_rows($sql) > 0){
   
   // Loop through the results
   while($row = mysql_fetch_array($sql)){
      $username = $row['username'];
      $password = $row['password'];
      $email = $row['email'];
      
   if ($username == lady1)
       { ?>

      click, click > <a href='crew2.php'>here</a> <

  <?php    }
else
      {
         
      } ?>

     <b>Admin name</b>:<b><font face='Tahoma' size='3'> $username</font></b> <hr size=1>

                     <br>Adm Pass: $password
                     <br>Adm email: $email
<?php
      if($i % $tblWidth ){
    ?>
         <td align='center' valign='top' bgcolor='#F2F2F2'><?php echo $all_stuff; ?></td>
<?php
      }else{
         //else then print column number 2 etc for the next loop.
?>
         </tr><tr>
         <td align='center' cellpadding='10' valign='top' bgcolor='#F2F2F2'><?php echo $all_stuff; ?></td>
<?php
      }
      //add only 1 for the loop ($i).
      $i++; ?>

 

I don't know how you have your table set up, I'm assuming that you have omitted some of that code.

Link to comment
Share on other sites

#1 you're trying to compare 'lady1' as a string NOT a constant to the $username variable which means you should encase that string with quotes..

 

#2 when a user logs in you should store their username and other often used information in a session...

 

so if you do store them in a session

 

if ($_SESSION['username'] == 'lady1') {

}

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.