Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. More accurately ob_start ob_get_contents and ob_end_clean
  2. Did you try it?
  3. It was a messup on my part. The last page you were on was: /test.php?page=3 The current page is: /test.php?page=3 The new last page is /test.php?page=1 Page 1 | Page 2 | Page 3 That is going from Page 1 to Page 3. It works as expected, I just mixed up the words. Give it a try and see, create a simple test.php and paste that code in it, and it should work like expected.
  4. $string = str_replace("\n\n", "</p><p>", $string); $string = "<p>" . $string . "</p>"; echo $string; str_replace
  5. <?php session_start(); header("Cache-control: private"); $lastpage = isset($_SESSION['last_page'])?$_SESSION['last_page']:''; $_SESSION['last_page'] = $_SESSION['this_page']; if (isset($_GET['page'])){ $_SESSION['this_page'] = "{$_SERVER['PHP_SELF']}?page={$_GET['page']}"; } else { $_SESSION['this_page'] = $_SERVER['PHP_SELF']; } echo "The last page you were on was: {$lastpage} <br /> The current page is: {$_SESSION['this_page']} <Br /> The new last page is {$_SESSION['last_page']}<br />"; echo "<a href=test.php?page=1>Page 1</a> | <a href=test.php?page=2>Page 2</a> | <a href=test.php?page=3>Page 3</a>"; die(); ?> I do not know what you are doing as you only show part of the code. Given the above code, everything works fine on my end, and as expected. Output: The last page you were on was: /test.php?page=3 The current page is: /test.php?page=3 The new last page is /test.php?page=2 Page 1 | Page 2 | Page 3 This was going from the "Page 3" link to the "Page 2"
  6. SELECT DISTINCT DATE_FORMAT('%Y-%m-%d', `datecol`) FROM `table_name` WHERE `somecol` = 'someval' DATE_FORMAT
  7. foreach ($_GET as $key => $val) { echo "You are working with {$key} which is {$val}.<br />"; } You can use that to figure out what values are passed in/get the uri. As far as value etc I would name them different. A more descriptive name makes debugging a bit easier.
  8. You can check $_SERVER['HTTP_REFERER']. But that is dependent on a user. If they choose to shut that off, it will not send it etc. Very un-reliable. If you really want to. At the top of each page, you can have 2 session variable settings. 'this_page' and 'last_page' if last_page is not set then set it to this_page. Then on page load, if last_page is set, you can store that somewhere for the page you are on in a variable then you set last_page to be this_page and this_page to be the page you are on. Then in a regular variable you hold $lastpage which will contain the real last page for use on that page only. A little crazy on the logic, but it would/should work.
  9. Not possible, as far as I know. Since PHP does not except overriding of functions. The other option, each page you set the "last_page" session before you call the header function. Either way you have to do some leg work.
  10. He means where are you calling: "header_" not just "header" You have posted where you defined it. It has to be called. <?php session_start(); // note session_start here as well. if(!isset($_SESSION["id"])) { header_("Location: index.php?page=login"); // note it is now header_ instead of header exit; } Functions have to be called to actually run. You cannot just define them and expect them to run on their own.
  11. <?php $string = '<a href="http://www.abc.com/rand/file.r01"> <a href="http://www.abc.com/rand/file.r02"> <a href="http://www.abc.com/rand/file.r03">'; preg_match_all('~www.abc.com/(.+?)"~is', $string, $matches); echo "<pre>" . print_r($matches, 1) . "</pre>"; die(); ?> Rough example. But should work. Outputs: Array ( [0] => Array ( [0] => www.abc.com/rand/file.r01" [1] => www.abc.com/rand/file.r02" [2] => www.abc.com/rand/file.r03" ) [1] => Array ( [0] => rand/file.r01 [1] => rand/file.r02 [2] => rand/file.r03 ) )
  12. Can you post how you are accessing the methods of the class?
  13. if(mysql_num_rows() < 1){ echo "<p>The username or password you have entered is incorrect!</p>"; echo "<META HTTP-EQUIV=Refresh CONTENT='4; URL=index.php'> "; exit(); } else{ $data = mysql_fetch_assoc($r); $_SESSION["username"] = $username; $_SESSION['clientid'] = $data['clientid']; // given that the col name from mysql is that // more data set here echo "<div align='center'><h5>Logging In</h5></div>"; echo "<META HTTP-EQUIV=Refresh CONTENT='2; URL=client_home.php'> "; } ?> Just like that....
  14. The only thing I can see is that it is prone to SQL injection, and your password is textual and not hashed or encrypted. If magic_quotes is on that may protect you to a point, but you should really turn it off and use mysql_real_escape_string on data before testing them against a database. Also make sure that you always call $_SESSION['loggedin'] and not just $loggedin (given that register_globals is on which it should not be). Other than that check your password if it is very weak (something like 'password') I would suggest beefing it up.
  15. You do not have session_start on the page that does the processing.
  16. echo 'array( Name => "'.$list_explode2['0'].'", Email => "'.$list_explode2['1'].'"),' . "\n"; You need to use double quotes around characters like that for them to display right, the ' takes them literally. The " actually displays the character.
  17. The only way that would work is if you set your page up for an if statement then pass data via GET or POST to it to display it. But anyone who can guess that can view it. But since XML needs to be read, you have to echo it out to the page, or else it is really useless. What are you trying to accomplish exactly?
  18. <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); session_start(); // Note session_start added here header("Cache-control: private"); if(isset($_SESSION["id"])) { header("Location: index.php?page=myaccount"); exit; } $error = ""; echo "{$_SESSION['last_page']}"; <?php session_start(); // note session_start here as well. if(!isset($_SESSION["id"])) { header("Location: index.php?page=login"); exit; }
  19. Ok so it is set on the index page. how about the page that is being called? Is this a separate page or does it use the index page as a gateway? session_start has to be at the top of any page you want to use sessions on. EDIT: And yes, please do as Thorpe suggested
  20. Are you checking if it is set first? Is that header_ being called before you try and call that session variable? If not, then this would not work. You also have to have session_start at the top of the page where you set/try and retrieve this variable at.
  21. <a href="?id='$id'&english=on" To add more variables you use & the question mark should only be used for the initial one.
  22. There really is not a difference. Whichever one you want to use should be fine. (Personally I would stick with the one you found). As mine is adapted for different functionality.
  23. <?php function scmp($a, $b, $key="title") { return strcmp($a[$key], $b[$key]); } $fruits[0]["title"] = "ZShould be last"; $fruits[1]["title"] = "AA Should be first"; $fruits[2]["title"] = "AB Should be second"; usort($fruits, "scmp"); while (list($key, $value) = each($fruits)) { echo "\$fruits[$key]: " . $value["title"] . "<br />"; } die(); ?> Never mind the name of the array ($fruits). That should get you what you want.
  24. mail Not hard at all, given you have a mail server to use.
  25. premiso

    MS-DOS

    If on a windows system, yes. Using system / exec and the script is locally on the server.
×
×
  • 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.