Jump to content

Simple PHP controlled button


werushka

Recommended Posts

I want to place a button that function as the following between this div

 

<div class="linkbutton">

<?php

global $user;

if ($user->uid) {

  node/add/duyuru} (I want it to go to this page)

else {

  /user/login (if the criteria is not met above go this page instead)

}

?>   

</div>

 

and if the current page is "node/add/duyuru" this div class should be hidden.

 

I understand the logic but I have almost no idea how to write it.

 

I would really appreciate any help

Link to comment
https://forums.phpfreaks.com/topic/98042-simple-php-controlled-button/
Share on other sites

So like?

 

<?php
$where = $_GET['button'];
switch ($where):
case "something":
	header("Location: node/add/duyuru");
	exit();
default:
	header("Location: /user/login");
	exit();
?>
<div class="linkbutton">
<?php
global $user;
if ($user->uid)
{
echo "<a href=\"{$_SERVER['PHP_SELF']}?button=$user\">Click Me</a>";
else
{
echo "<a href=\"{$_SERVER['PHP_SELF']}?button=default\">Click Me</a>";
}
?>   
</div>

 

Is that close to what you're trying to accomplish?

I am kind of confused by your code...

 

Basically I want to created a Link button on my navbar, with the div tag (which I can customize the look.

 

My requirements are as follows, if the user is logged in then the button will lead the user to "node/add/duyuru"(this is a link)

 

but if the user is not logged in and anyone clicks on the "link button" i created then it redirects the user to "/user/login" link so that can login to use the function of that link button...

 

In the mean time it would be really nice so if the user viewing this page only "node/add/duyuru" then the button is not displayed at all...

 

Thanks for your reply

This part is understandable

<div class="linkbutton">

<?php

global $user;

if ($user->uid)

{

echo "<a href=\"{$_SERVER['PHP_SELF']}?button=$user\">Click Me</a>";

else

{

echo "<a href=\"{$_SERVER['PHP_SELF']}?button=default\">Click Me</a>";

}

?> 

</div>

 

But the part above I just want a rollover image, where can i define the "Button"

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.