Menu DaniWeb
Log In Sign Up
  • Read
  • Contribute
  • Meet
  1. Home
  2. Programming Forum
  3. Web Development Forum
  4. Code Snippet Repository
  5. Reusable Code Snippet

Enable/disable multiple redirects based on cookie...

13 Years Ago vindom 0 Tallied Votes 294 Views Share

Hi!
Im a noob to PHP but had to use it instead of ASP because I couldn't retrieve images from database using ASP + MS Access... Anyways.. I have couple questions:

Number 1: How to retrieve and displaymultiple(!) images(jpg) from mysql DB?

NUmber 2: I have a main page that displays iframe with multiple images (they are hardcoded for now). When pressing on any image it will redirect to a page with that image and text box for a comment..(thats the plan anyway) . And is it possible to disable redirect option if the user is not logged in (based on cookie)?
Thanks

http-protocol php seo web-browser
<div class="img">

 <a target="_blank" href="klematis_big.htm"><img src="1.jpg" alt="Klematis" width="220" height="130" /></a>
 
</div>

<div class="img">

 <a target="_blank" href="klematis2_big.htm"><img src="2.jpg" alt="Klematis" width="220" height="130" /></a>
 </div>
 
<div class="img">

 <a target="_blank" href="klematis3_big.htm"><img src="3.jpg" alt="Klematis" width="220" height="130" /></a>
</div>

<div class="img">

 <a target="_blank" href="klematis4_big.htm"><img src="4.jpg" alt="Klematis" width="220" height="130" /></a>
</div>

<div class="img">

 <a target="_blank" href="klematis4_big.htm"><img src="5.jpg" alt="Klematis" width="220" height="130" /></a>
</div>

<div class="img">

 <a target="_blank" href="klematis4_big.htm"><img src="6.jpg" alt="Klematis" width="220" height="130" /></a>
</div>

<div class="img">

 <a target="_blank" href="klematis4_big.htm"><img src="7.jpg" alt="Klematis" width="220" height="130" /></a>
</div>

<div class="img">

 <a target="_blank" href="klematis4_big.htm"><img src="8.jpg" alt="Klematis" width="220" height="130" /></a>
</div>

<div class="img">

 <a target="_blank" href="klematis4_big.htm"><img src="9.jpg" alt="Klematis" width="220" height="130" /></a>
</div>

<div class="img">

 <a target="_blank" href="klematis4_big.htm"><img src="10.jpg" alt="Klematis" width="220" height="130" /></a>
</div>
About the Author
Member Avatar for vindom
vindom 0 Newbie Poster
Member Avatar for grant.baker
grant.baker 10 Newbie Poster
12 Years Ago

Hi, I haven't done any work with images in a database, so I'm not much help to you there. As for your second problem, if you want to either enable or disable all of the links based on if the user is logged in, then I would make two separate pages, say links.php and no-links.php, and include links.php if the user is logged in and the other if the user is not logged in.

So when the user logs in, I would set a session cookie, say $_SESSION['logged-in']=yes, but it could be anything you want. Then for your include code, you could have:

<?php
    if($_SESSION['logged-in']='yes'){ //check to see if the session variable is set
        include_once('path-to-file/links.php'); //if it is, include the links file
    }
    else {
        include_once('path-to-file/no-links.php'); //else include no-links file
    }
?>

Put the code you have listed in two files - one with links, one without - and put the include script where it was.

Reply to this topic
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.

Sign Up — It's Free!
Related Topics
  • Member Avatar Enable/disable multiple redirects based on cookie... 18
  • Member Avatar absolutely controlling where the user may go on my web pages 3
  • Member Avatar CakePHP URL routing 3
  • Member Avatar got 404 error while running php in netbeans 1
  • Member Avatar inserting line feed in text area 2
  • Member Avatar Redirecting users to another page 10
  • Member Avatar jsp,eclipse and weblogic server 8
  • Member Avatar Incorrect page content passed to WordPress plugin in firefox 1
  • Member Avatar PHP Gaming basics 2
  • Member Avatar Redirect to Login page if session doesn't exist 31
  • Member Avatar creating XML file by using php? 15
  • Member Avatar Microsoft Fights to Block Google's Deal with Yahoo Japan 1
  • Member Avatar Calendar 2
  • Member Avatar My PHP and MySQL log in script, please help 7
  • Member Avatar Calendar Date Pick 3
  • Member Avatar Microsoft IE 8 More Friendly to Developers, IT 2
  • Member Avatar selected indes for coke machine 2
  • Member Avatar Alternatives to $_SERVER['HTTP_REFERER'] 5
  • Member Avatar How to run Windows Apps under Google Chrome OS 3
  • Member Avatar td height Google Chrome 5
Not what you need?

Reach out to all the awesome people in our web development community by starting your own topic. We equally welcome both specific questions as well as open-ended discussions.

Start New Topic
Topics Feed
Reply to this Topic
Edit Preview

Share Post

Insert Code Block

  • Forums
  • Forum Index
  • Hardware/Software
    • Recommended Topics
  • Programming
    • Recommended Topics
  • Digital Media
    • Recommended Topics
  • Community Center
    • Recommended Topics
  • Latest Content
  • Newest Topics
  • Latest Topics
  • Latest Posts
  • Latest Comments
  • Top Tags
  • Topics Feed
  • Social
  • Top Members
  • Meet People
  • Community Functions
  • DaniWeb Premium
  • Newsletter Archive
  • Markdown Syntax
  • Community Rules
  • Developer APIs
  • Connect API
  • Forum API Docs
  • Tools
  • SEO Backlink Checker
  • Legal
  • Terms of Service
  • Privacy Policy
  • FAQ
  • About Us
  • Advertise
  • Contact Us
© 2025 DaniWeb® LLC