Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by ajoo

  1. Hi ! Can someone take a look at this simple code which worked perfectly till I upgraded to php 5.5.11. Here in my code popo should be either late or great depending upon the variable value ( in this case Great ). It seems to be echoing out both !?? Please can someone point the error ? I seem to be missing it. Thanks ! <?php session_start(); $_SESSION['popo']="POPO"; ?> <html> <head> <title> DYN PAGE </title> <style> .wrapper{ width: 1000px; height: 600px; border: 1px solid #e1e1e1; margin: 10px auto 0 auto; } .header{ width: 1000px; height: 65px; font-size: 17px; font-width: bold; color: #fff; text-align: center; background: #717171; } .lowerheader{ width: 1000px; height: 60px; color: #fff; text-align: center; background: #919191; 'display: table; 'overflow: hidden; } </style> </head> <body> <div class = 'wrapper'> <div class = 'header'> <? if(isset($_SESSION['popo']) && $_SESSION['popo'] == "POPO"): ?> <h2><br> POPO IS GREAT </br></h2> <? else : ?> <h2><br> POPO IS LATE </br></h2> <? endif ; ?> </div> <div class = 'lowerheader'> <p> What ever it takes </P> </div> </div> </body> </html>
  2. ajoo

    wrong if else branching

    Thanks loads. That was the problem. Will avoid using the short cut. How can I avoid the intermingling of of html and php , say in this very example. Thanks !
  3. Hi all ! I am really stuck on creating a secure login and site navigation system. Can someone say how secure sessions be created and how to use sessions / cookies / session - cookies together. for navigating a website, like moving from page to page and any special precautions to take while doing a critical task ( say one which involves accessing a database for reading or writing). Generally either sessions or cookies are used for this but I was wondering if it would be a good idea to use both in case that makes the system more secure. Thanks
  4. hey wow !! That seems like a lot of information to ingest. Thanks loads fellas I'll read this and more on sessions and logins and be back with some more meaningful questions. Thanks all !
  5. Hi all, In the login systems on the web, I have found that some use sessions and some others use cookies to validate a login. Normally for login systems with sessions, a hashed login string is created using say the password and HTTP_USER_AGENT is stored in a $_SESSION['logincheck'] variable. $login_check = hash('sha512', $password . $user_browser); and Before access is provided to the secure login page this SESSION variable is checked against a hashed string created again from values of password retrieved from the database again. $_SESSION['logincheck']== $login_check and if the two are same then the user is allowed to access his secure area. A similar approach is also provided in some cases where cookies are used. The values stored in cookies are checked against hashed values created with values of variables from the database and if they match access to the user page is granted. What I wish to ask and know is that would it be a good idea or a bad idea to implement both of these in a login system? What would be the advantages or disadvantages in both cases. I thought that using both would be a good idea but i am not sure. I have also not come across any system where both of these have been used simultaneously. Thanks all !
  6. Thanks Jacques, I will create a new thread now as you suggest but i can swear that almost all examples that I saw on the net use sha512. MD5 and the lot that you rejected for hashing passwords. Thanks for the example on bcrypt. I'll look into it.
  7. Hi Jacques1 and Avi. Thank you both for the reply. I would like to make some clarifications. No I am not storing the password in a cookie nor am i storing th plain text password anywhere. I am storing a hashed and salted version of the password in the tables. However I use another hashed and salted string that i am creating from the password, user browser, and a salt ( 128 characters long) as shown below and store it in a session variable to check, for e.g. when a user moves to another page or if the page is refreshed,and ensure if the user is valid and belongs to this session. $login_str = hash('sha512', $submitted_password . $user_browser. $salt); // hashed string created from submitted password $_SESSION['logincheck'] = $login_str // stored in session. To check on another or refreshed page $login_check = hash('sha512', $stored_password . $user_browser. $salt); // hashed string created from stored password if($login_check == $_SESSION['$logincheck']); // confirm if the user is the right one. Yes I use sha512 because I read that that was safe and has been used in some of the secure login systems that I read about on the web. So if that's a mistake, kindly elaborate so that i can take another look at the other encryption routines. Then as i have mentioned I also thought I would use cookies simultaneously with sessions do be doubly sure of the users login. So i used a similar technique to hash another salted string and store that in a cookie on the user's machine for handshaking while browsing between pages or on page refreshes, I check for both these values and if they match, I know its the right user in the session. For this purpose, I pull out the password from the db and recreate a new string to check against the submitted password just as i have done for the sessions above. Now that, like i mentioned, may or may not be a good idea and I am not sure. Hence I am asking the gurus.
  8. Hi all, I am getting this Notice and I am unable to figure out why. Notice: Array to string conversion in D:\xampp\htdocs\xampp\MagicOn\functions\gen_functions.php on line 1084 Index.php calls the session start routine sec_session_start() which generates the error mentioned above. Line 1084 ( I have put the line number in the function against the line ) is indicated in the function sec_session_start() as the one which is calling session_start(). <?php //error_reporting(E_ALL & ~E_NOTICE); define('INCLUDE_CHECK',true); require 'loader.php'; sec_session_start(); $now = time(); . . . function sec_session_start() { $session_name = 'sec_session_id'; // Set a custom session name $secure = false; // Set to true if using https. $httponly = true; // This stops javascript being able to access the session id. ini_set('session.use_only_cookies', 1); // Forces sessions to only use cookies. $cookieParams = session_get_cookie_params(); // Gets current cookies params. session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly); // 0, /, ''. session_name($session_name); // Sets the session name to the one set above. 1084 session_start(); // Start the php session session_regenerate_id(TRUE); // regenerated the session, delete the old one. } ?> Grateful for any help. Thanks.
  9. ajoo

    Session start causing a Notice.

    Hi thanks for the reply. Yes that's correct, the drive letter path and all and btw I managed to get rid of the error by just shutting down the machine once and starting it again. Yea just that. Without making a single change to the code. That error message seemed to have got stuck. So finally after many attempts at trying this n that I decided to shut down the browser and also the machine. It worked. Now the code is working and there are no messages. So the question is does anyone have any idea or has shared a similar experience whereby shutting the machine gets things going ? Any idea why this happens ? Thanks !
  10. Hi, I am using transactions on a piece of code whose structure is somewhat like this if ( condition ) { mysqli_autocommit($fcon, false); if ( condition ) { $query " "; if ( condition ) { $query " "; if ( condition ) { $make = makeTable(); // where this is a function which creates a table and uses a query like INSERT into ... to create an entry in a table if ( $make == true) { $query " "; if ( condition ) { $query " "; } else else and so on ending all else. The problem is that the function call to makeTable prevents the roll back beyond that point. Please can someone tell me if and how it would be possible to roll back all the way to the defined starting point at the very beginning of the code block. Thanks all for any help, comments, suggestions.
  11. Thanks Barand, that worked great. It was also getting the null record which i managed to eliminate by adding to the end of the query "AND dues IS NOT NULL"; Now i'll check out the earlier reply from you ( some things work better in code) and get back with the results. You have been awesome help and guide. Thanks loads.
  12. Hi Barand, Thanks for this. I have to check it out yet cos you've used the earlier table. I have studied the code and got the drift though. Still I'll try it out and revert. Meanwhile I have another twist on the previous Query that you solved below: SELECT cv.day_id, cv.dues, cv.last_visit, cv.points FROM clubvisit cv WHERE last_visit > ( SELECT MAX(last_visit) FROM clubvisit --+ WHERE points <> | ( | find the SELECT points as lastpoints --+ | latest date FROM clubvisit | find points | that had a JOIN | value from | point value ( | the record that | not equal to SELECT MAX(last_visit) as last_visit --+ get | matches the | points value FROM clubvisit | latest | latest date in | found in the ) --+ date | the subquery by | latest record as latest USING (last_visit) --+ JOIN on the date --+ ) ) This works great. However what if the MAX(last_visit) had to check for and ensure that the dues on this day was not NULL. If the dues was NULL in the last row ( highest date)then this row had not to be considered in the rest of the query. So i tried to get the latest date as follows:- JOIN ( SELECT MAX(last_visit) as last_visit FROM (SELECT* FROM clubvisit as cv WHERE dues IS NOT NULL) ) as latest USING (last_visit); But this gave an error " #1248 - Every derived table must have its own alias" . even though "SELECT* FROM clubvisit as cv WHERE dues IS NOT NULL" gave me the subset i wanted. So i don;t know how to eliminate this error though I tried. I even tried to use this statement as the first statement in the query and then work with the alias but that gave an error too. So how do i get there now ? Just for clarity if the Table is as below : (1 , 900 , '2012-12-01' , 6), (2 , 700 , '2012-12-04' , 7), (3 , 600 , '2012-12-07' , 5), (4 , 600 , '2012-12-09' , 6), (5 , 600 , '2012-12-10' , 6), (6 , 600 , '2012-12-14' , 6), (7 , NULL, '2012-12-14' , NULL); Then the last_value has to be that of date 14-12-2012 or day_id = 7 and the desired table should be calculated with corresponding point value of 6. The output should be as before :- +--------+------+------------+--------+ | day_id | dues | last_visit | points | +--------+------+------------+--------+ | 4 | 600 | 2012-12-09 | 6 | | 5 | 600 | 2012-12-10 | 6 | | 6 | 600 | 2012-12-14 | 6 | +--------+------+------------+--------+ Thanks !
  13. MacGyver is right but Thanks none the less, gives me something else to check and read about.
  14. Hi barand, Thanks for this but i forgot to change the dues values when i changed the table order earlier. So it kind of changed the entire sense of what was needed. So I am just going to put the table back here corrected and which is as follows: Day_ID -- Dues --- Last_Visit --- Points. 1 --------- 900 -------- 1/12 -------- 9 2 --------- 600 -------- 4/12 -------- 6 3 --------- 400 -------- 7/12 -------- 4 4 --------- 500 -------- 9/12 -------- 5 5 --------- 600 -------- 10/12 ------- 6 6 --------- 600 -------- 11/12 ------- 6 7 --------- 600 -------- 13/12 ------- 6 8 --------- 500 -------- 15/12 ------- 5 9 --------- 500 -------- 19/12 ------- 5 Ok so here's the modified table and I have changed the dates to be unique ( I understood that here we should have a date and time format for multiple entries on the same day) just to keep it simple. So now I am looking for the latest value of dues (500) . Then we move back on dates and the next is also 500, so we want that and then we come to dues value of 600 on Day_ID 7. Here the dues have changed. But now I want to know for how many earlier days were the dues 600. So we move back and find that till Day_ID = 5 or till on 10/12 the dues were same and equal to the value 600. That's it. Those are all the values I want. So my output should be : 5 --------- 600 -------- 10/12 ------- 6 6 --------- 600 -------- 11/12 ------- 6 7 --------- 600 -------- 13/12 ------- 6 8 --------- 500 -------- 15/12 ------- 5 9 --------- 500 -------- 19/12 ------- 5 I have checked and rechecked the table. Its correct. Please guide how this may be achieve achieved. Thanks loads !
  15. Hi barand, thanks for the response and yes this data is different from the earlier. I think there is a small mistake in the data in TABLE A ( the one in the previous post) so here's the new table again - TABLE B Day_ID -- Dues --- Last_Visit --- Points. 1 --------- 900 -------- 1/12 -------- 6 2 --------- 700 -------- 4/12 -------- 7 3 --------- 400 -------- 7/12 -------- 4 4 --------- 600 -------- 9/12 -------- 6 5 --------- 600 -------- 10/12 ------- 6 6 --------- 500 -------- 10/12 ------- 5 7 --------- 600 -------- 14/12 ------- 6 8 --------- 500 -------- 14/12 ------- 5 ok so now I think its correct. Yes multiple dates are allowed. However I think that the dates got goofed in the sense that they should have followed order ( Ascending I mean.). Ok but your keen observation has led me to another few questions. 1. I would like to ask that in a system where a person;'s visits to the club are entered serially, is it possible for the table to store them in an un-ordered manner as in TABLE A. 2. Even if the system enters inputs these dates in order, is there any manner that the table may get jumbled on dates (again as in TABLE A). 3. How can the same output be achieved for both the tables. I think if you just do that for me for the earlier TABLE A, I'll try and do the simpler TABLE B one myself. Thanks very much.
  16. Hi Barand ( guru), I am here once again with another query that i wish to form from the same table clubvisits. The table of entries is as below. Day_ID -- Dues --- Last_Visit --- Points. 1 --------- 900 -------- 1/12 -------- 6 2 --------- 700 -------- 4/12 -------- 7 3 --------- 400 -------- 7/12 -------- 4 4 --------- 600 -------- 9/12 -------- 6 5 --------- 600 -------- 10/12 ------- 6 6 --------- 600 -------- 14/12 ------- 6 7 --------- 500 -------- 10/12 ------- 5 8 --------- 500 -------- 14/12 ------- 5 The last time you created a query which checked for last entry value of Dues and the found all the entries for which the dues were same. This time I wish to change that slightly so that it finds the latest dues value (500) and checks for all records with the same dues value as well as all the value of the next dues values. i.e. I want to make a query whose result would be 4 --------- 600 -------- 9/12 -------- 6 5 --------- 600 -------- 10/12 ------- 6 6 --------- 600 -------- 14/12 ------- 6 7 --------- 500 -------- 10/12 ------- 5 8 --------- 500 -------- 14/12 ------- 5. I am able to get 6 --------- 600 -------- 14/12 ------- 6 7 --------- 500 -------- 10/12 ------- 5 8 --------- 500 -------- 14/12 ------- 5. if i change " Where last visit > " to " Where last visit >= " but I am not able to get the rest of the entries for which the dues value = 600. Help sought. Thanks again !
  17. yes that's exactly correct. yes I don't want someone to go to secound.php from anywhere else except the hyperlink so i guess sessions is the best way to ensure it. Maybe You can suggest something else. Thanks
  18. yea hi ! ok so this one file is not an included file. It's a PHP file, say second.php which is invoked by a hyperlink on the main webpage index.php. Now i don't want to give a direct access to it so i asked if something similar like defining a constant and then checking for it in the second.php , once the hyperlink was pressed in index.php, could be used to prevent direct access to this file second.php. I am actually thinking of using sessions to prevent direct accesss to this one - (a hyperlink invoked file). Thanks.
  19. Hey thanks ! yes I am now trying and using the define to define a constant. However what about a file that I have to access using a href defined hyperlink? What's the way to prevent direct access to that file other than what you suggested of putting the files into a folder other than the root. Please suggest something. Thanks !
  20. hey Thanks ! but guess what I tried and got it too. SELECT count(last_visit) FROM clubvisit cv WHERE last_visit > ( SELECT MAX(last_visit) FROM clubvisit WHERE points <> ( SELECT points as lastpoints FROM clubvisit JOIN ( SELECT MAX(last_visit) as last_visit FROM clubvisit ) as latest USING (last_visit) ) ); So i was also trying it even after posting the query. Thanks loads cos I am learning too with your help.
  21. Hi Barand, I have achieved what i wanted with your help but I just want to confirm if there is a more elegant way to achieve it. So this query that you created initially to solve this issue returns the latest three rows with the points value 6. However if i did not wish to have have these rows listed and instead just wanted to know the count of rows that were returned, can the query be modified to achieve that? That's what I have been trying and thought I had managed but I had not. So i used the result in mysqli_affected_rows and indirectly counted the rows to be three. However I was wondering and trying to achieve the same with count in the query. I am sure it can be done and request you to show me how to do it. Thanks again !
  22. Hi Barand, The previous query that you were so kind to help me with, I have altered a little as follows : $sql = "SELECT COUNT(last_visit) as numcount FROM clubvisit WHERE points <> ( SELECT points as lastpoints FROM clubvisit JOIN ( SELECT MAX(last_visit) as last_visit FROM clubvisit ) as latest USING (last_visit) );" It works as desired in myphpAdmin. However now i am using this as $result = mysqli_query($link,$sql) and I am not sure how I may retrieve the value of numcount from this one. kindly guide. Thanks !
  23. Thanks Guru !! I did manage to find the explanation using the myphpAdmin by taking parts as you have also segregated. So I ran the SQL's and got the results of the portions. I have a few questions on this but i'll first try and read a bit more and hammer them out myself and if I cannot, then i'll come and ask them again. Thanks a lot.

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.