Jump to content

freelance84

Members
  • Posts

    975
  • Joined

  • Last visited

Everything posted by freelance84

  1. Good evening all, I'm just going through my site checking for any security issues I may have missed... Is it possible for someone to "fake" a $_SESSION variable? There are several MySQL queries which are using the $_SESSION variables as part of the query... Therefore, if someone managed to "fake" a $_SESSION they could make some of the queries unsafe as I haven't run any of the $_SESSION variables through the mysql_real_escape_string. I know the mysql_real_escape_string is designed to make safe any user input into MySQL, so this may apply if they "fake" the $_SESSION?
  2. Has anybody ever heard of this? I came to my computer one morning having not changed a thing all night. I try to log in with the correct login details, but it appears not to login correctly. NB, the home page it should be loading has some checks which look like the following: <?php session_start(); if (isset($_SESSION['username'])) { $u_ID = $_SESSION['ID']; $u_name = $_SESSION['username']; $u_type = $_SESSION['type']; $u_email = $_SESSION['email']; $u_forename = $_SESSION['forename']; $u_surname = $_SESSION['surname']; if($u_type == 5) { content of the php page } else echo "Sorry something has gone wrong with your user type. Please <a href=index.php>click here</a> to log in again."; } else {header("location:index.php");}; After some tests I found that what was happening was a problem in line three: the "isset($_SESSION['username']". I know that the $_SESSION['username'] was there as the authenticate page sets it, and if it doesn't it throws an error message back to the index.php. But for some reason it kept seeing the session username as not being there and going to the last line which went back to the index.php. However, the index.php also checks the SESSION variables and then goes to the appropriate page. However it was loading. What's weirder is that when I pressed back in the browser (FF) after the attempt to sign in, it loaded OK and I could continue browsing through the rest of my site with no probs. When I clear the FF History (everything), I can then sign in with no problems too. But then the problem isn't as strict as that, it is very intermittent. EG, I have cleared the browser about 15mins ago and logged in and out several times with no problems. I have even restarted FF a few times. When this problem went away at lunch time i choose to ignore it, but now, 2hrs later it happened again. Does anyone have any ideas? Could it be a server thing? Or a virus or something? (I do have ie6, ff 3.6.6, chrome and opera10.60 loaded onto my computer to check my site as I am building it. Could this be causing the issue?) PS, The site does not use and cookies except the SESSIONS. It also does not use and Javascript.
  3. It works! Thanks for all your help! A file in sub-folder test named "test" on public_html contains a file named "test1.php". "test1.php" requires "functions.php" from a sub-folder named "testing" on public_html. The following worked: require_once ('../testing/functions.php'); I'm pretty sure this didn't work before, but it does now. I think there must be some more tangles in the actual index.php I was originally testing. Either way I now understand a lot more on the subject. Thanks once again!
  4. Please pardon my not getting this, its really annoying me too. Ok, I echo'd getcwd and it returned: /home2/[my_username]/public_html There is a folder in public_html named adw, therefore a php file echoing getcwd() should look like: /home2/[my_username]/public_html/adw The index.php within adw whose location should be: /home2/[my_username]/public_html/adw/index.php ...requires a file whose location is: /home2/[my_username]/public_html/functions.php What should I be putting in the require_once()? Should it be: require_once (/home2/[my_username]/public_html/functions.php); ??
  5. Ok, i added the lines to the bottom of the main index (the sites main home/login page) and it returned an array. Number 18 in the array read: [18] => /root I'm not much the wiser: What does this mean exactly?
  6. If it needs at least one"RE:" you could add one on to the string after all of them have been removed $new_string = "RE: ".str_replace("RE:", "", $string); Dunno if that will work straight off, it may need breaking into two parts
  7. index.php is within folder "adw" in the public_html. On load it must require_once a file named "functions.php" directly in the public_html. I've tried using the following: require_once '/functions.php'; but it returns Any ideas?
  8. The code to try and require is: require_once '/security/login.php'; I've checked the spelling of the directories and that's fine. The .php file trying to get the login is in the root directory, and the login.php is in "security" which is also in the root. I solved this via trial and error, and found removing the '/' from in front of the security worked. Would someone be able to tell me what the correct way is to go forward and backward (directory wise) from within the public_html? I can't find it anywhere in my book or on google as i'm assuming this is assumed knowledge, only I don't know it
  9. The code to try and require is: require_once '/security/login.php'; I've checked the spelling of the directories and that's fine. The .php file trying to get the login is in the root directory, and the login.php is in "security" which is also in the root.
  10. Well, this is rather embarrassing, I've just realised a couple of the require_once() lines were still trying to get from the same directory as the index it was reading. Where they should be jumping back one step. I'm gonna change this and it should work. Apologies.
  11. OK, I've now done a simple test. 1 Within the adw directory i renamed the index.php to something else 2. Then put a new file in named index.html 3. closed the browser and tried to login again. It worked, the exact same header loaded the index.html. I replace the index.php and deleted the index.html, and the once again it could not load. Any ideas? (i know the .php file works just fine)
  12. If you look at the following page, http://customcanvasuk.com/. All the links on it will send you to another directory on that website e.g: http://customcanvasuk.com/contact-us/ That URL will remain in the address bar as I am assuming that within the contact-us/ directory there is another index file. However I am trying to achieve the same thing but without as much success. The index.php in the public_html is a login page. The user enters their details hits login and the details are sent to the login.php. If all is correct the login.php uses header() to redirect them to another page. This was working fine when I had all the files in the public_html, but now it doesn't. if ($row[3] == '1') { header("location:http://www.site.net/adw/"); exit(); } The above results a message from ff saying: And the address bar reads: Anybody know why? I want the address bar to read:
  13. Ok, thanks for your help. I might just be doing that then as I'm nearly done with my first site
  14. Ok, so if I turned Indexes off via the .htaccess, if Apache failed or something else the user would not be able to see anything but a blank page? What if the Apache or something else failed during the login? Would this display the login.php to user in plain text?
  15. I'm not sure if this is the correct place for this one, if not i'm sure it will be corrected. With regards to the PHP-security tutorial: Section 5 talks about External file access and how everything but the index.php should be removed from the document root... I'm pretty confused and been trying to get my head around this for about 2hrs now, with google searches not really resulting in much. Firstly, don't all the pages need to be in the public_html or one of its sub-directories? Also, if something does go wrong and the user does see the directory tree, would they be able to right click and save to file any folder/file they wish? Or are they just simply able to view the different file names? Please go easy with me one this one, it's all completely new and i'm just struggling to break in. Thanks, John
  16. phpchamps, removing the use of the button tag solved it all. It also solved some other odd issues on other pages where I was using the button tag instead of the input. Thanks for the other bits of advice too!
  17. Blimey, every day something new. Thanks for the help, i'll see if it works
  18. echo <<<_END <form action="nrt-home.php" method="post"> <select name="class_name"> _END; //the current classes into the drop down list for($i = 0 ; $i < $current_number; ++$i) { echo "<option>$current_class_name[$i]</option>"; } echo <<<_END </select> <input type="hidden" name="j_number" value="$j"/> <button class="button-add" type="submit" name="race">Class races</button> <button class="button-edit" type="submit" name="edit">Edit class details</button> <button class="button-delete" type="submit" name="delete">Delete class</button> <br/> </form> _END; The above is a simple form; a drop down menu and three buttons. The form send info back to the same page it is on: nrt-home.php. Depending on which button is pressed a different action is performed when the page reloads: //getting the class name and numb races if passed from form if(isset($_POST['class_name'])) { $class_name = $_POST['class_name']; $get_numb_races = mysql_query("SELECT number_races FROM members_classes WHERE ID = '$u_ID' AND class_name = '$class_name'"); $number_races = mysql_fetch_row($get_numb_races); } //navigating to different page according to form if(isset($_POST['race'])) { header("location:nrt-home-view-racesToDo.php?class_name=$class_name"); } if(isset($_POST['edit'])) { $_SESSION['show/hide']='hide'; header("location:nrt-home-edit-editDelete.php?class_name=$class_name&number_races=$number_races[0]"); } //deleting a class if(isset($_POST['yes_delete']) && isset($_POST['class_name'])) { $class_to_delete = get_post('class_name'); $query_delete = "DELETE FROM members_classes WHERE ID = '$u_ID' AND class_name = '$class_to_delete'"; $result_delete = mysql_query($query_delete); if (!$result_delete) die ("Database access failed: " . mysql_error()); } There is a problem with ie6. With ff and chrome everything is fine. In ie6, it doesn't matter which button the user presses, edit delete or class races, they all go to the edit page. I really don't understand what is going on here as this is just php right? And as i said, everything works fine in ff and chrome. Any ideas? I'm stumped
  19. Hmm, nice one, cheers. Can't belive thats all it needed!
  20. Fairly new to CSS so if there is a glaring mistake here I appologise. A centered header contains a logo on the left and some text on the right: The HTML: <div id="header"> <a href="index.php"><img style="padding-left:5px;padding-top:3px;" src="png/logo.png" alt="logo" /></a> <span id="header-inner">$u_name -<br/>Account -<br/><a href="logout.php">Log Out</a> -</span> </div> The CSS #header { width: 700px; margin-right:auto; margin-left:auto; background-image: url(png/top-gradient.png); background-repeat: repeat-x; } #header-inner{ float: right; width: 100px; font-size: small; font-weight: bold; color: #EEEEEE; text-align: right; padding-right: 15px; padding-top: 4px; } The result in FF and Chrome is a header with my logo inside on the left and the span inside the header on the right. When I checked if it working in ie6, the span and contents keeps going under the line in which the image is on. Any ideas? Is there some css I should be applying to the img tag enabling them to sit on the same line as other stuff? Any help here would be very much appreciated. PS: When I take out the image, the span tag will quite happily sit in the header
  21. Thanks everyone, as you might of guessed this is for a data entry site i'm creating. Soldier Jane, that site is really helpful thanks! Well, I think i'm going to be going with, delete - red add - greenish edit - light blueish See how it goes. Also, the results to a big message on facebook were: Delete red Edit blue Green green Thanks again
  22. Mine are: 1. Red 2. Orange or blue 3. Green Anyone else who reads this, please, don't be shy, tell me what you think. To start with I was thinking along the lines of edit being green.
  23. Wasn't sure where to post this one, but here goes.. Colour Associtaion. What colour comes to mind first when you think of the word: 1. Delete 2. Edit 3. Add
  24. Hey, I had a similar question a month back. I had a look thorugh my posts but can't find the thread. Basically the answer was to have fewer tables, something about the program not having to back out of one table and then into another means the program can run faster. Obviously it isn't possible to combine some tables as the data stored is totally different. Hope that helps
  25. OK, I've now solved this by giving adding the year to the end of the name: 'abc - 09' and then using some php to remove the ' - 09' after it has been retrieved. Would love to know if it is even possible to do it the way I started out by trying
×
×
  • 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.