Jump to content

tourbike

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tourbike's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hello and thank you very much for the advice especially #PFMaBiSmAd @wildteen88 that was a type error on my part so sorry about that anyway it worked like a treat but i think i do need to work on the error pages now, so thanks again laters
  2. Thanks I changed the code above and slotted it into the page I wanted to protect but when i tried to access the page it didnt work (bearing in mind that I am working on my localhost xampp windows version ) this is the code that i use to create the $_SESSION once the user logs in: if #Mysql query is correct then returns a value { // Register $myusername, $mypassword and redirect to file "control.php" session_start(); $_SESSION['username']; $_SESSION['pass']; header("location:control.php"); } else { echo "Wrong Username or Password"; } this works for making the correct passwords etc but its the next step that I am struggling with. the following code I use on control.php to block unauthorised access to the file. <? session_start(); if(!isset($_SESSION['sm_username'])){ header("location:login.php"); } exit(); ?> where am I going wrong???
  3. So to protect the other web pages in my app I would add the code: <? session_start(); if($_SESSION['username']){ header("location:login.php"); } ?> and add this to all the pages that I want to protect. !???! this is roughly right, as I cannot seem to get it to work on my localhost machine. cheers
  4. thank you very much for your help
  5. hello, I am trying to protect in internal web app pages being accessed without proper username and passwords. I thought I could use $_SESSION instead of using session_register then use this golbal $_SESSION to protect. Is this right or is there an easier way. cheers in advance
  6. Hi I am trying to learn php before my university begins in the fall but I am stuck on cookies. What I want to happen is that when a user comes to a page, a cookie is given to that user and moves the user to another page. On this other page it will check if a cookie has been set and move user to x location, however if no cookie has been set then the redirect send the user back to the page that hands out the cookies. So I created to different pages: 1. cookie.php (this hands out the cookie) code as follows: <?php // Set a cookie // Cookie name: name // Cookie value: cookie // Cookie expire: in 1 hours setcookie ('name', 'cookie', time() + (60*60*1)); // Now check that cookie is loaded error_reporting (E_ALL ^ E_WARNING ^ E_NOTICE); // Check if cookie has been set or not if ($_GET[$_COOKIE['name']] != 'cookie') { // Set cookie setcookie ('name', 'cookie', time() + 60); // Reload page header ("Location: checkcook.php"); } else { // Check if cookie exists if (!empty($_COOKIE['name'])) { echo "Cookies are NOT enabled on your browser"; } } ?> page two that checks the cookie and if no cookie exists then 2. cookiecheck.php <? // check cookie is correct value if(!isset($_COOKIE['cookie'])) { header("location:correct_location.php"); } else { // if failed then go back to page header ("Location:cookie.php"); } ?> I hope someone can just help where I am going wrong with my thinking thanks tourbike
  7. I have just built my first html message that is sent when people sign into my newsletter. But I want to know if it is possible to include a header that when the people open the html message it asks the client who receives the email to notify the sender. I have seen this before on an email once or twice and i am wondering if this is possible with php Thanks for any comments
  8. Hi currently I have a one user php script running on my site basically one user can only use the database at any one time how can I change this to a multi-user environment so that anyone can log in and only use the areas of the database that they are only privaliged too thanks for any replies
  9. hi I am just learning php and I am stuck on a problem basically I have two php programs running on different websites but i want to include one into the other I can move the programs into the same root directory using the include( dirname(__FILE__) . "/file.php"); but i want to change this to include( "http://www.example.com/file.php"); where www.example.com is a remote or separate site as i only want to include the file.php how can i make this possible with just line of code ???? I have looked at the manual but seem to be lost thanks for any feedback
×
×
  • 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.