Jump to content
#StayAtHome ×


  • Content Count

  • Joined

  • Last visited

Everything posted by ajoo

  1. hmmm, you see this is the last and the only one page of it's sort that requires this conditional menu appearance / disappearance, as of now, that I need to fix before I put up the application. So the question of longer really doesn't arise. I am at the last. Could you please elaborate? If you are saying that I should do as I have been doing for the pages to display the menu so far, then that cannot work for this, because the menus are set for the user on login and remain the same for the length of the session. This print page is the only rogue page in that sense. Then how do I do it ? Thanks loads !
  2. Hi requinix, Thanks for the reply ! Would it be a problem if I instead check for the Page URL like i did earlier because your suggestion, must definitely be better, is a bit long drawn out it at this stage of the project. If the above solution, of checking the url and displaying the menu, has no security implications I would rather use that for this page and maybe come back to it later and make the changes you recommend. That solution works fine but i don't know if there is a serious downside to it. Please let me know. Thank you !
  3. HI requinix, I do not think that this, as you suggested, would work in my case requinix because my program structure and page flow is like this. include "header.php"; include"navbar.html" // --- The menus are decided and displayed here. . . . if(isset($_GET['page']){ $page = $_GET['page']; swicth($page) { // all pages go here // ... case "home": ... break; case "gallery": ... break; case "childprints" include("fra_prints.php"); break; ... } } The menu is displayed before the page is included. So setting the variable in the relevant case comes after the menu is already displayed. What do you think ? Is that correct or am i reading you wrong ? Thanks !
  4. The way to check for the landing page URL and display the print menu accordingly. Thanks.
  5. Hi Requinix, I really do wish that sometimes you would solve the problem without handing me out another one to work on !!😊 This $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] seems to be the way to go about it. Is this what you had in mind ? It does as required. Thanks
  6. Ya all right, I'll try and be clearer. When a user logsin say as an admin, his menu is set for all pages. As of now he has this menu : HOME GAMES GALLERY with submenus. There is one page print page that is invoked not via menu but via a submit button on a form as below User1 --- data1 --- data2 --- data3 ---- VIEW User2 --- data4 --- data5 --- data6 ---- VIEW . . UserN --- dataX --- dataY --- dataZ ---- VIEW Now when the Admin presses the VIEW submit button , he lands an a page which can be printed and so now I want the menu on this page to be HOME GAMES GALLERY PRINT. I feel that here when the button is submitted i have to use JS or JQ to set the session variable to print so that the following code can invoke the PRINT menu <li> <a href='index.php?page=page1'>Home</a> </li> <li> <a href='index.php?page=page2'>Games</a> </li> <li> <a href='index.php?page=page3'>Gallery</a> </li> <?php if(isset($_SESSION['print']) && $_SESSION['print'] == "print"): ?> <li> <a href='flogin.php?page=childprints'>Print</a> <?php endif; ?> Is that correct? I hope I have been able to make it clear. Also is there an all PHP way to do this ? Thanks !
  7. HI requinix, Thanks for the reply My menus are set on user login and depend upon the user login. Like separately for the admin and other users. The are set using a navbar and then the pages are included in the page area below it. In order for the additional menu to display on a required page and not on any other I had thought i would use a session variable. However this would have to be set and evoked on a button submit which includes the printable page. Wouldn't I still have to use jQuery to set the value of the session variable on a button submit for the menu to be displayed on the landing page? I know this is a different strategy from the one in the question above although it would still useJQ or JS. Is there a better all PHP way to do this ? Thank you.
  8. HI requinix, Thanks for the reply. That's how i had left that page a long time ago with a $_SESSION['print'] for enabling and disabling the menu, but that did not seem to work when i came back to finishing the print page now. I'll look into my earlier logic and see if I can debug it and implement it using PHP. Just for the sake of discussion, isn't using JQuery a good way to go about this ? Thanks !
  9. Hi all, I have the following menu : <li> <a href='index.php?page=page1'>Home</a> </li> <li> <a href='index.php?page=page2'>Games</a> </li> <li> <a href='index.php?page=page3'>Gallery</a> </li> <li> <a href='index.php?page=page4'>Print</a></li> Of these, I want the Print menu to be disabled and invisible for all pages except when it is invoked via a button called View on the Gallery page. The landing page / URL in that case would be index.php?page=page4 and I want the Print menu to be disabled (the link )and made invisible when the user navigates away from the Print page. I know I have to use something like the following for disabling the link but all variations i tried on it seem to fail. $(window).on('hashchange', function(e){ $('a #page4').bind('click', function(e){ e.preventDefault(); }); . . . }); Kindly help to resolve this. Thanks !
  10. ajoo

    insane code

    Thank you Guru Barand ! I'll look it up and revert. Thanks.
  11. ajoo

    insane code

    Hi all ! I have the following code that works perfectly well. However I know that this is not the best way to code php and HTML together. I really want to clean up this code and make it as clean as possible. I have no clue how to proceed. <?php echo "<table border=0 cellpadding=0 cellspacing=0 width=600pt style='border-collapse:collapse;table-layout:fixed;width:600pt'>"; if($selected === 'Zu'|| $selected === 'unZu') { $c = 0; $rowcnt = 0; for($rows=0; $rows<2; $rows++) { if($rows ===0) $p = $rows*$sl1; if($rows ===1) $p = $rows*$sl2; echo "<tr>"; for($j=0; $j<$colCount1; $j++) { if(($j+1+$rows*$colCount1)== $miss[$c]) { $c++; echo "<td class=sum_number style='background-color:pink;' > ".($j+1)."</td>"; }else { echo "<td class=sum_number >".($j+1)."</td>"; } } echo "</tr>"; for($i=0;$i<$sumlen[$rows];$i++) { echo "<tr>"; for($a=1; $a<=$colCount1; $a++) { echo "<td class=sum_1st_column_3 >"; if($pr[$rowcnt][$a]>0) echo " ".$pr[$rowcnt][$a]; else echo $pr[$rowcnt][$a]; echo "</td>"; } echo "</tr>"; $rowcnt += 1; } echo "<tr>"; for($j=0; $j<$colCount1; $j++) { echo "<td class=result > </td>"; } echo "</tr>"; echo "<tr>"; for($j=0; $j<$colCount1; $j++) { echo "<td class=space_between_rows ></td>"; } echo "</tr>"; } echo "</table>"; ?> Thanks all !
  12. hi Ginerjim, Thanks for your interest in this. Sorry for the delay in reply since I saw it just now. OK so these are as follows: The cn__no represents a center is a session variable defined on user login. dd_Stream is the value of the dropdown box that is sent as a post variable when it is selected. once selected, it is also assigned to the Session variable $_SESSION['dd_Stream']. If next time around, if rank dropdown is chosen and submitted, the last value of dd_Stream will be held in the session variable and will be used as such, the rank value is now sent as a post variable. Together these two variable are needed and are fed to a query to generate the results to be displayed. The first time around, on the home page, there are default values for these two variables that are used to invoke the query and display the results. Yes the code now works just fine. I hope that clears it. In case you want any further clarification, i'll be glad to provide. Thanks loads !
  13. Hi Benanamen !! Thanks again for the reply. Right so I call the drop downs a form because their selection causes a submit and both are actually enclosed in <form> tags. So yes they are the forms. Of-course I can choose only one at a time and so only one would be submitted. I put the code for all of you to see. I have managed to sort it out though. It's working great now. I did club the posts together under $_SERVER['method_request'] like you suggested. Yes the logic needed a little twisting though because it needs values from previous session as well. Thanks a ton for pursuing this with me. Regards to all !
  14. Hi all, Grateful for all the responses. I have managed to solve the issue as far as I could test. Find attached the code below that I had to jiggle with to get the correct order for the logic to work. The complexity arose because of the session values that need to come in a certain order for the logic to work. <?php if(isset($_POST['cn_no'])) { if(($cn_no = fcheckNumber($_POST['cn_no'])) !== false){ $_SESSION['f_error'] = "Center No = ".$cn_no; } else $_SESSION['f_error'] = "Center Error"; } else $cn_no = $_SESSION['cn_no']; ////////////// Stream DropDown /////////////// if(isset($_POST['ddStream'])) { if(($dd_Stream = fcheckStream($_POST['ddStream']))===false) { $dd_Stream = false; $_SESSION['f_error'] = "invalid Stream1"; } elseif($dd_Stream ==='All') { $_SESSION['ddStream'] = $dd_Stream; $pp = "(userstatus.Stream = ? || userstatus.Stream = ?)"; $strTypes = 'issi'; $mm = 'Regular'; $nn = 'Beginners'; $values = array($cn_no,$mm,$nn); } else // $dd_Stream === 'Regular' || $dd_Stream === 'Beginners' { $_SESSION['ddStream'] = $dd_Stream; $pp = "userstatus.Stream = ?"; $strTypes = 'isi'; $mm = $dd_Stream; $values = array($cn_no,$mm); // echo $pp; } } elseif(isset($_SESSION['ddStream'])) { if(($_SESSION['ddStream'])==='All') { $pp = "(userstatus.Stream = ? || userstatus.Stream = ?)"; $strTypes = 'issi'; $mm = 'Regular'; $nn = 'Beginners'; $values = array($cn_no,$mm,$nn); } elseif($_SESSION['ddStream'] === 'Regular' || $_SESSION['ddStream'] === 'Beginners') { // echo"A1"; $dd_Stream = $_SESSION['ddStream']; $pp = "userstatus.Stream = ?"; $strTypes = 'isi'; $mm = $dd_Stream; $values = array($cn_no,$mm); } else { $dd_Stream = false; $_SESSION['f_error'] = "Invalid Stream2"; } } else { $pp = "(userstatus.Stream = ? || userstatus.Stream = ?)"; $strTypes = 'issi'; $mm = 'Regular'; $nn = 'Beginners'; $values = array($cn_no,$mm,$nn); } if(isset($_POST['ddrank'])) { if($_POST['ddrank']==='All') $dd_rank = 'All'; else $dd_rank = fcheckNumber($_POST['ddrank']); if($dd_rank===false){$dd_rank=false; $f_error = "rank Error";} if($dd_rank && $dd_rank==='All') { $_SESSION['ddrank']=$dd_rank; $qq = 'userstatus.rank <= ?'; $ll = 14; array_push($values,$ll); } else { $_SESSION['ddrank']=$dd_rank; $qq = "userstatus.rank = ?"; $ll = $dd_rank; array_push($values,$ll); } } elseif(isset($_SESSION['ddrank'])) { if(($_SESSION['ddrank'])==='All') { $qq = 'userstatus.rank <= ?'; $ll = 14; array_push($values,$ll); } else { $dd_rank = $_SESSION['ddrank']; $qq = "userstatus.rank = ?"; $ll = $dd_rank; array_push($values,$ll); } } else { $qq = 'userstatus.rank <= ?'; $ll = 14; array_push($values,$ll); } . . . ?> By the way I do have CSRF token checking in place in case someone should point that out. I removed that since with a common post block it would be much simpler. Thank you all very much. Much obliged. @ Benanamen: The overall task is to take values of two drop downs. One is sent via post and the other is from a session, the previous value, and using these 2, execute a query and display the results. For ex. in my program, it allows a choice of a stream ( like a subject) and the grade or rank of the user and based on these 2 it creates a query and displays the results. The block structure you gave was absolutely correct. The sessions and their placement in the overall code was the problem. Thanks again !
  15. Hi all ! Thanks for all the responses. I think that which was suggested by you all is correct and the problem lies in a bit of complication in my code and the manner in which $_POST and $_SESSION have been used in the if else blocks to get the current and session values. I will fix that, hopefully soon, and then check / test the code again and revert if the problem still remains. Thanks loads !
  16. Hi ! @Benanaman The problem that I wish to solve is to get the submits to find the correct block and avoid interception by the wrong block. @ Kicken. Correct. I made that mistake here. It's perfect in the actual code though. Thanks.
  17. Hi to all my respected fellow coders and gurus who have taken time to respond, My code echos an error because there are two exactly same blocks as below in it "included" from different pages. one is the from the home page which has the login / logoff slider bar, header. This itself is quite wrong unless I am highly mistaken. Main Page : if ($_SERVER['REQUEST_METHOD'] === "POST"){ if(isset($_POST['submit']) && $_POST['submit'] ="login"){ ... } if(isset($_POST['submit']) && $_POST['submit'] ="logoff"){ ... } } and menu the 2nd comes from the page "included" in the display area. Display Page: if ($_SERVER['REQUEST_METHOD'] === "POST"){ if(isset($_POST['submit']) && $_POST['submit'] ="activate"){ ... } } As i could see from the error and by invoking var_dumps on the results, the $_POST[''submit'], submit from the "included" code in the page display area is intercepted by the code in the first block that deals with login and logoff. Because it does not find the type "activate" of the button associated with type = "submit" in that block , it throws an error. If the code could just fell through the first code block and reached the 2nd block (fictional of course since it cannot happen like that) the error would not occur. But of-course that is wrong in the first place. I am still missing out something from the discussion above, as i probably am, i am really sorry and request you to please explain just once again. Thanks all !
  18. Hi Benanamen, Thanks for the reply. Ya that does seem easy. Yet the problem remains in my case. I'll try my best to explain it. The main page handles the login and logoff. So there is a block of code if ($_SERVER['REQUEST_METHOD'] === "POST") { ... } which handles these two cases. If the user logs in he accesses the restricted page which is included in the main page. This page also has a few buttons and also it's own block if ($_SERVER['REQUEST_METHOD'] === "POST") {...} to handle the submits of this included page. Now because there are two similar blocks in scope, the first block intercepts the request which is meant for the 2nd block and gives an unknown index error. Hence I thought that maybe I needed to use the "AND" to filter it down to the second block. This, thus is the dilemma !! I hope you can tell me a way out. Thanks loads !
  19. Hi requinix, 😃 Thanks for the reply though I am none the wiser ! 🤔 Most of the time I click a button, a form is also being submitted. So what do i do in that case ? Another thing that you mentioned is that the login and logoff form pointing to a dedicated page. In my case, it's handled on the same page. The logoff simply brings the user back to the login page and login includes the restricted page into the main page. Any issues with that especially concerning security. So now there are these 2 questions !!😥 😃 Thank you !
  20. Hi, I have been detecting POST submits as below if(isset($_POST['someindex']) && $_POST['someindex']==="somevalue"){ .. } which I know should be replaced by if($_SERVER['REQUEST_METHOD']=== "POST"){ ... } So I changed it in entirety in my project and on testing found that there are conflicts. Now my main file has a slider with a login and logoff button. and then when the user is logged in it includes the user page, which in turn keeps including other pages . So if there are many buttons on those pages, it can result in a conflict as I found out. I wish to confirm that to avoid the conflicts is the following the right way to go about it. I would like to say that while the index may be the same, the values for each are unique. if($_SERVER['REQUEST_METHOD']=== "POST" && if(isset($_POST['someindex']) && $_POST['someindex']==="somevalue")){ ... } Thanks all !
  21. Hi all ! Ok so now it has started to work again. I have tested my code like 6 times and it works everytime. I made zilch change to my code. Can anyone shed light on this strange phenomenon !! Thanks all !
  22. I just tested http://josiahbertoli.com This is supposed to be a demo of the reCaptcha. Interestingly this is failing too !!!??? On form submittioin, it says "failure" !! Now I wonder if this is supposed to do just that but i seriously doubt it. Could this be like related ? I mean both seem to be failing. Hope this is some help to anyone wanting to help me out !!😃 Thanks loads !
  23. Hi all ! The google reCaptcha was working great till recently. Now it has started to give the following error. and this happens to be line 68 Please help ! Thanks all !
  24. Hi Requinix, It worked & the error is gone ! Thanks loads.
  25. Hi requinix, I'll try it out and revert. Thanks loads.
  • 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.