Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

need help on calling html page from php

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

need help on calling html page from php

Postby arobert74 » Fri Jun 06, 2014 1:11 pm

Hi

I have a page where I currently link to another page, so using href tag inside my html body.
I want to add some code where user could only click on the link to go that second page ONLY when they are logged in.
I have my SESSION code in my page and it works. So am able to check when user is logged in or not.

I was thinking to use an if else to show the referenced link when user is logged in, and show a non referenced link when user is not logged in. So like this, the user could access the page (thru the link) only when they are logged in.

So something like:

<?php
if (isset($_SESSION['userid'])) {
???
} else {
echo 'Create Listing';
}
?>

But not sure what to put in my true part (where ??? is)
In html, it would be <a href="Listing2.php">Create Listing</a>, but here not sure how to link to a file from php.

Thanks for any help.

Arnal
arobert74
New php-forum User
New php-forum User
 
Posts: 6
Joined: Sun Apr 27, 2014 3:17 pm

Re: need help on calling html page from php

Postby arobert74 » Fri Jun 06, 2014 1:32 pm

I found it ! :-)
Here is what I did:

<?php
if (isset($_SESSION['userid'])) {
echo "<a href=\"Listing2.php\">Create Listing</a>";
} else {
echo 'Create Listing';
}
?>
arobert74
New php-forum User
New php-forum User
 
Posts: 6
Joined: Sun Apr 27, 2014 3:17 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google Feedfetcher and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.