Jump to content

[SOLVED] Duplicate Links


timmah1

Recommended Posts

Why do these links show up twice?

$data = array(
'seller' => array('	<p><a href="member.php">My Account</a></p>
					<p><a href="main.php?cid=list">List Items</a></p>
					<p><a href="main.php?cid=myitems">My Items</a></p>
					<p><a href="member.php?change=password">Change Password</a></p>
	 				<p><a href="member.php?change=email">Change Email</a></p>
	 				<p><a href="main.php?cid=logout">Logout</a></p>
					<p></p>
	 				<p><a href="member.php?change=account">Close account</a></p>'),

'buyer' => array('	<p><a href="member.php">My Account</a></p>
					<p><a href="member.php?change=password">Change Password</a></p>
					<p><a href="member.php?change=email">Change Email</a></p>
	 				<p><a href="main.php?cid=logout">Logout</a></p>
					<p></p>
	 				<p><a href="member.php?change=account">Close account</a></p>'),
    //buyer => array(<p><a href="member.php?change=password">Buyer</a></p>'),
'<p>Welcome to the members only page '.$_SESSION['s_name'].'!</p>
<p>You are logged in as '.$_SESSION['s_username'].' from the IP address '.$_SERVER['REMOTE_ADDR'].'</p>',
    
  );
  $type = $_SESSION['s_type'];

  foreach($data[$type] as $val) {
    echo $val;
  }

 

This is what shows up

Main Links
close - Navigation
My Account
Change Password
Change Email
Logout
Close account

Welcome to the members only page!
You are logged in as cheezy from the IP address xx.xxx.xx.xxx

close - Login information

My Account
Change Password
Change Email
Logout
Close account

Link to comment
Share on other sites

I'm not sure either, that's why I'm posting it here to see if I coded it wrong.

 

Here is the entire code if that helps

<?php session_start(); 

if($_GET['set'] > 0)
{

if($_SESSION['whattoclose'] == NULL)
{

	$_SESSION['whattoclose'] = $_GET['set'];

} else {

	$_SESSION['whattoclose'] = $_SESSION['whattoclose'] . '|' . $_GET['set'];

}

}

if($_GET['undo'] > 0)
{

if(!empty($_SESSION['whattoclose'])){

	$_SESSION['whattoclose'] = str_replace("|".$_GET['undo'] , "" , $_SESSION['whattoclose']);
	$_SESSION['whattoclose'] = str_replace($_GET['undo'] , "" , $_SESSION['whattoclose']);

}

}

function showTitle($id)
{

$title = array(
	"Navigation",
	"Login information",
	);

$data = $_SESSION['whattoclose'];

$not = explode( "|" , $data );
if(!in_array( $id , $not ))
{

	echo '<a href="member.php?set='.$id.'">close</a> - ';
	echo $title[$id-1];

} else {

	echo '<a href="member.php?undo='.$id.'">open</a> - ';
	echo $title[$id-1];

}		

}

function checkIt($id)
{

$data = array(
'seller' => array('	<p><a href="member.php">My Account</a></p>
					<p><a href="member.php?change=list">List Items</a></p>
					<p><a href="member.php?change=myitems">My Items</a></p>
					<p><a href="member.php?change=password">Change Password</a></p>
	 				<p><a href="member.php?change=email">Change Email</a></p>
	 				<p><a href="main.php?cid=logout">Logout</a></p>
					<p></p>
	 				<p><a href="member.php?change=account">Close account</a></p>'),

'buyer' => array('	<p><a href="member.php">My Account</a></p>
					<p><a href="member.php?change=password">Change Password</a></p>
					<p><a href="member.php?change=email">Change Email</a></p>
	 				<p><a href="main.php?cid=logout">Logout</a></p>
					<p></p>
	 				<p><a href="member.php?change=account">Close account</a></p>'),
    //buyer => array(<p><a href="member.php?change=password">Buyer</a></p>'),
					'<p>Welcome to the members only page '.$_SESSION['s_name'].'!</p>
					<p>You are logged in as '.$_SESSION['s_username'].' from the IP address '.$_SERVER['REMOTE_ADDR'].'</p>',
    
  );
  $type = $_SESSION['s_type'];
  foreach($data[$type] as $val) {
    echo $val;
  }

$str = $_SESSION['whattoclose'];

$not = explode( "|" , $str );
if(!in_array( $id , $not ))
{

	echo '<div class="table">';
	echo $data[$id-1];
	echo '</div>';

}

}

?>

<div class="header">
<? showTitle(1) ?>
</div>
<? checkIt(1) ?>
<br>
<div class="header">
<? showTitle(2) ?>
</div>
<? checkIt(2) ?>

Link to comment
Share on other sites

When I pull this out

function checkIt($id)
{

I get an error on line 99, which is this

echo '</div>';

 

This is the revised code

//function checkIt($id)
//{

$data = array(
'seller' => array('	<p><a href="member.php">My Account</a></p>
					<p><a href="member.php?change=s-guide">Sellers Guide FAQ</a></p>
					<p><a href="member.php?change=list">List Items</a></p>
					<p><a href="member.php?change=myitems">My Items</a></p>
					<p><a href="member.php?change=password">Change Password</a></p>
	 				<p><a href="member.php?change=email">Change Email</a></p>
	 				<p><a href="main.php?cid=logout">Logout</a></p>
					<p></p>
	 				<p><a href="member.php?change=account">Close account</a></p>'),

'buyer' => array('	<p><a href="member.php">My Account</a></p>
					<p><a href="member.php?change=password">Change Password</a></p>
					<p><a href="member.php?change=email">Change Email</a></p>
	 				<p><a href="main.php?cid=logout">Logout</a></p>
					<p></p>
	 				<p><a href="member.php?change=account">Close account</a></p>'),
    //buyer => array(<p><a href="member.php?change=password">Buyer</a></p>'),
					'<p>Welcome to the members only page '.$_SESSION['s_name'].'!</p>
					<p>You are logged in as '.$_SESSION['s_username'].' from the IP address '.$_SERVER['REMOTE_ADDR'].'</p>',
    
  );
  $type = $_SESSION['s_type'];
  foreach($data[$type] as $val) {
    echo $val;
  }

$str = $_SESSION['whattoclose'];

$not = explode( "|" , $str );
if(!in_array( $id , $not ))
{

	echo '<div class="table">';
	echo $data[$id-1];
	echo '</div>';

}

}

?>

<div class="header">
<? showTitle(1) ?>
</div>
<? checkIt(1) ?>
<br>
<div class="header">
<? showTitle(2) ?>
</div>
<? checkIt(2) ?>

Link to comment
Share on other sites

try this. I have removed the function and the div. Get the simple part working then we can add more.

 

<?php session_start(); 

if($_GET['set'] > 0)
{

if($_SESSION['whattoclose'] == NULL)
{

	$_SESSION['whattoclose'] = $_GET['set'];

} else {

	$_SESSION['whattoclose'] = $_SESSION['whattoclose'] . '|' . $_GET['set'];

}

}

if($_GET['undo'] > 0)
{

if(!empty($_SESSION['whattoclose'])){

	$_SESSION['whattoclose'] = str_replace("|".$_GET['undo'] , "" , $_SESSION['whattoclose']);
	$_SESSION['whattoclose'] = str_replace($_GET['undo'] , "" , $_SESSION['whattoclose']);

}

}

function showTitle($id)
{

$title = array(
	"Navigation",
	"Login information",
	);

$data = $_SESSION['whattoclose'];

$not = explode( "|" , $data );
if(!in_array( $id , $not ))
{

	echo '<a href="member.php?set='.$id.'">close</a> - ';
	echo $title[$id-1];

} else {

	echo '<a href="member.php?undo='.$id.'">open</a> - ';
	echo $title[$id-1];

}		

}


$data = array(
'seller' => array('	<p><a href="member.php">My Account</a></p>
					<p><a href="member.php?change=list">List Items</a></p>
					<p><a href="member.php?change=myitems">My Items</a></p>
					<p><a href="member.php?change=password">Change Password</a></p>
	 				<p><a href="member.php?change=email">Change Email</a></p>
	 				<p><a href="main.php?cid=logout">Logout</a></p>
					<p></p>
	 				<p><a href="member.php?change=account">Close account</a></p>'),

'buyer' => array('	<p><a href="member.php">My Account</a></p>
					<p><a href="member.php?change=password">Change Password</a></p>
					<p><a href="member.php?change=email">Change Email</a></p>
	 				<p><a href="main.php?cid=logout">Logout</a></p>
					<p></p>
	 				<p><a href="member.php?change=account">Close account</a></p>'),
    //buyer => array(<p><a href="member.php?change=password">Buyer</a></p>'),
					'<p>Welcome to the members only page '.$_SESSION['s_name'].'!</p>
					<p>You are logged in as '.$_SESSION['s_username'].' from the IP address '.$_SERVER['REMOTE_ADDR'].'</p>',
    
  }
  $type = $_SESSION['s_type'];
  foreach($data[$type] as $val) {
    echo $val;


$str = $_SESSION['whattoclose'];

$not = explode( "|" , $str );
if(!in_array( $id , $not ))
{

	echo '<div class="table">';
	echo $data[$id-1];
	echo '</div>';

}

}

?>

Link to comment
Share on other sites

I tried that and got errors, so I tried to remove



<div class="header">
<? showTitle(1) ?>
</div>
<?  ?>
<br>
<div class="header">
<? showTitle(2) ?>
</div>
<? checkIt(2) ?>

And everything works!

 

I guess I don't need to have them have the ability to open and close the information, just thought it would be different.

 

Thanks for all of your help adam, it's really appreciated

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.