premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
More accurately ob_start ob_get_contents and ob_end_clean
-
Did you try it?
-
[SOLVED] set a session when you use header redirect?
premiso replied to aebstract's topic in PHP Coding Help
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. -
$string = str_replace("\n\n", "</p><p>", $string); $string = "<p>" . $string . "</p>"; echo $string; str_replace
-
[SOLVED] set a session when you use header redirect?
premiso replied to aebstract's topic in PHP Coding Help
<?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" -
SELECT DISTINCT DATE_FORMAT('%Y-%m-%d', `datecol`) FROM `table_name` WHERE `somecol` = 'someval' DATE_FORMAT
-
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.
-
[SOLVED] set a session when you use header redirect?
premiso replied to aebstract's topic in PHP Coding Help
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. -
[SOLVED] set a session when you use header redirect?
premiso replied to aebstract's topic in PHP Coding Help
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. -
[SOLVED] set a session when you use header redirect?
premiso replied to aebstract's topic in PHP Coding Help
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. -
<?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 ) )
-
Class HELP! Basic class just won't work properly
premiso replied to robcrozier's topic in PHP Coding Help
Can you post how you are accessing the methods of the class? -
[SOLVED] processing login and using session to hold data
premiso replied to fbm's topic in PHP Coding Help
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.... -
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.
-
[SOLVED] processing login and using session to hold data
premiso replied to fbm's topic in PHP Coding Help
You do not have session_start on the page that does the processing. -
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.
-
How to hide your XML file: put inside a PHP file??
premiso replied to OM2's topic in PHP Coding Help
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? -
[SOLVED] set a session when you use header redirect?
premiso replied to aebstract's topic in PHP Coding Help
<?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; } -
[SOLVED] set a session when you use header redirect?
premiso replied to aebstract's topic in PHP Coding Help
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 -
[SOLVED] set a session when you use header redirect?
premiso replied to aebstract's topic in PHP Coding Help
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. -
[SOLVED] How can I create a link that will change 'WHERE id = 1' by 1?
premiso replied to Cerys's topic in PHP Coding Help
<a href="?id='$id'&english=on" To add more variables you use & the question mark should only be used for the initial one. -
<?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.
-
mail Not hard at all, given you have a mail server to use.
-
If on a windows system, yes. Using system / exec and the script is locally on the server.