future_man

Members
  • Content count

    22
  • Joined

  • Last visited

Community Reputation

124 Neutral

About future_man

  • Rank
    Member
  1. OK I solved my problem like this: $current_time = date_create(date("Y-m-d H:i:s")); $last_time = date_create(date("Y-m-d H:i:s", strtotime(get_last_update_time($user_name)))); $result = date_diff($current_time, $last_time); echo $result->format('%Y-%m-%d %H:%i:%s'); but it echoes my result like so: "00-0-0 03:40:56", with all the days etc.. How do I format this so that it only show hours, lets say like so: "232156". With all the days, months years, formatted to hours?
  2. I looked into this diff function already but how do I use it?
  3. I want to subtract database timestamp from current server time. The formatted time that is returned to me from my database is "2013-09-01 22:05:39" and I use function date("Y-m-d H:i:s"); so that my server time I get in php is in the same format.   How can I get a result in hours? Example: 2013-09-01 22:05:39  minus 2013-09-02 22:05:39 equals 24 hours ???
  4.   Thank you, I did a similar approach! Turns out you really need to just put a break tag at the end and echo it :D how simple is that
  5. Hey, I want to list all of my database entries to a nice html format. For every unique id there is one row displayed out from my database to my php/html. I just don't know how to do that. I tried using while loop and foreach I just don't know how to properly structure them... My query and php code looks like this: $query = mysql_query("SELECT * FROM sport"); while($row = mysql_fetch_array($query)) { $result = $row['sport_ime'].' '.$row['sezona']; }
  6. Lets say I have a form in form.php and when I click submit all inputted data is sent to model.php for database manipulation etc.. and then when everything is done the model.php redirects user back to form.php using function: header('Location:form.php'); How in the blazing hell can form.php recognize I was redirected there from model.php ? I am so lost about this for so long now, I tried $_SERVER['HTTP_REFERER'] and everything and I just get an echo with my current page location. I want to get an echo of the model.php on my form.php  
  7.   Except if you have index.php with all of the includes in your root, am I right?
  8. How do you make a root directory though? Isn't the place you get with the server always the "root"? Or can you access diferent folders on a bought server and place files in the more safer place for example?
  9. What does that mean for the directory structure though? Can I just trough everything in private folders or I must allocate a directory that is available for public use?
  10. I am curious about server access. Lets say you buy a hosting service, can you manually decide which directories will be public and which will be off limits? Do public directories have to include views (templates)? Because in a lot of frameworks I see views in private directories. Can you block access via .htaccess and only allow users to browse certain pages? How do you prevent them from browsing your entire php app files?   I know this is a lot of question but a simple overview about directory structure in apache servers will do, since I am building one.
  11.   Yes you are right, however I am also aware of this form of "cheating" this is why I simply solved the problem with database entry. You see every location updates the users "location" in the database and a simple function to call that "location" is in order for every new choice user makes to travel. If I am to create a new location I will simply include that function on my new location php page controller. Also I intend to hide full URLs via .htaccess but that is simply for nicer UI.
  12. Hey, I was asking a lot of questions lately on this forum and it all boiled down to this one. We all know it is hype to implement front controller or master page index.php that handles all the requests to all the pages and reroutes you etc... All this for cleaner urls, easier code handling...   But what if you have a browser game with a lot of locations and variables, states, conditions etc.. I can't write a million if statements or switch statements on my index page. What if I implement such page structure as described below? Basicly you don't have single point of entry or one front controller but more main controllers that connect to subcontrollers: if location forest if loged in |---------------------------- forest.php |------------------ start.php -------------| | | if location home | |-------------------------- homebase.php | | | | if location else index.php---------| |------------------------- anywhere.php | | if in fight |------------------- combat.php | | if not loged in |------------------- homepage.php Why would all pages have to go through index.php? This would be a big mess! Divide pages based on location, for example my start.php page will decide where to redirect further. So in this case I have two bigger controllers not just one front one. Is this still a good convention? I mean is this still a good front controll design or is it better to leave all the redirects to index.php?
  13.   But what is so wrong about simply having the URL http://www.myserver.com/posts/byUser/24  I get the part you can make shorter URLs and such but why  index.php?url=posts/byUser/24 instead of http://www.myserver.com/posts/byUser/24 ?   Another thing why would I use this if my user has to log in to access the page anyway? I could simply use $_SESSION variables to display correct data on my index page... like so (I am building a simple browser game): if ($_SESSION['combat'] = true) { include 'certain_page.php'; } else if (...) { include 'another_page'; } else if ..... etc...
  14. But I hear that index.php or so called fron controller makes things act more like a coherent system and less like a loose collection of standalone pages. And you also have a bigger control over your page?   You are correct I am building a browser game, a simple one. And redirecting everything to your front page is supposed to be a good idea for better control over which views/templates to load.   I just don't know how to implement this, I mean right now I access new pages via links or forms. And when the link or form sends a request to a database, should that database return the result to the controller and that controller to the fron controller, or what...
  15. I know some people make a single point of entry to their website which is usually index.php - the first site you visit and login from.   But what is this exactly? Is it a controller that decides which webpages to show like in this tutorial http://www.technotas...ont-controller/ ?   Why would you want a controller for a whole page?   How does it work? Does it just redirect every link you click to the index.php and every header in php leads to index.php?   In the provided tutorial, author goes on how we type the url and it redirects us to index.php. But what does this mean in reality, when you must click links and forms to navigate through a website?   Does this mean that every submitted form and every new php page redirects to controller page and then the controller page redirects everything to index.php?