Jump to content

saurabhx

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Everything posted by saurabhx

  1. When a logged in user performs some action (like accessing one of the admin page or something), store the current time is a session variable or somewhere (eg: last_access_time). Then when the logged in user performs another action, check if it has been 20 minutes since the last recorded time stamp. If it has been more than 20 mins, logout the user. Or if it is not 20 mins yet, allow the action and update last_access_time with the current time. By the way, your above code will not check for time out and also, the function session_is_registered is deprecated as of PHP 5.3.0. So use the $_SESSION super global instead.
  2. May be you can use ajax to pass the value from your javascript code to php and process it..
  3. You are just referring to a normal for with a background image
  4. That should be easy. In the tag.php page, check if $_GET['action']==delete. If action is delete, then show a question Like 'Are you sure you want to delete?' or something and provide two buttons (or links) - Yes and No. If 'Yes' is clicked, submit again to the page tag.php?ID=2&action=delete-confirmed Then in the beginning of the page, check if $_GET['action']==delete-confirmed. If it is, then run the code to actually delete the record.
  5. echo "<a href='viewprofile.php?username=", $info['username'], "'><img src......"; For improved performance, use , (comma) instead of the dot operator. Just saying..
  6. You are probably not looping through the entire recordset, instead just using the 1st row only. Use something like this while($row = mysql_fetch_array($result)) { echo $row['ID']; }
  7. The function is not looping through all the array elements because after the first array element is processed, your function is 'returning' return array( 'name' => $name, 'filename' => $jpg, 'ext' => $ext ); Instead of writing return in each iteration, just assign the results in another array and return that array after the entire parameter array is looped through. Like this:- foreach($jpgs as $jpg) { $ext = strrchr($jpg, '.'); if($ext !== false) { $name = substr($jpg, 0, -strlen($ext)); echo $name."<br />"; echo $jpg."<br />"; echo $ext."<br /><br />"; $value[] = array( 'name' => $name, 'filename' => $jpg, 'ext' => $ext ); } } return $value;
  8. Why don't you just use an array instead of $row_1, $row_2.... An array is much more flexible and php offers a great deal of ways to manipulate functions. With arrays, you can write $row[$i] = 1;
  9. With AJAX you are changing only a small portion of the page, but to force a download you will need to modify the HTTP headers, which are the first things that are sent to the browser. So if you can change the http header of the current page through ajax, you can force download. I *think* it is not possible. Would love to hear if there is a way.
  10. When the link to save the page is clicked, make the following code execute:- header('Content-Type: text/html'); header('Content-Disposition: attachment; filename=file.txt'); echo "Hello"; // Output the page contents you want the user to download here Note: header() will not work if you have already output html content in the page. So in your case, probably is is best to write the above code in a separate file and link to that file. Even if the code is in a separate file, the user will not be taken to that new file, instead he will stay in the current page and a download prompt will be shown
  11. You can set a count in a session variable when the page is first loaded and then increment it each time it reloads. Then you can check the count and decide to check for the file or show the timeout message, right?
  12. There is nothing wrong or insecure about sending data through GET, as long as you are not sending sensitive data like password or anything. To secure your code from sql injection attacks, you have to sanitize the user input variables before using them in query. For mysql, you can use php's addslashes() or mysql_real_escape_string to escape special characters. By the way, it is better to use $_POST['Name'] instead of $_POST[Name].
  13. kney's reply is syntactically correct, but a more appropriate way will be this:- $titles = array('Home', 'About Us', 'Registration', 'Sitemap', 'Contact Us', 'Useful Links', 'Feedback'); if (in_array($this->getTitle(), $titles)) { $this->publicSite() = true; } else { $this->publicSite() = false; }
  14. Here I have corrected ur file and attached it [attachment deleted by admin]
  15. Just absolute position your divBG2:- .divBG2 { background:url(image3.png) no-repeat fixed bottom right; width:100%; min-height:100%; height:auto !important; height:100%; position:absolute; }
  16. Not clean, but this works:- <?php $number = '123.5...'; sscanf($number, '%d.%d%s', $a, $b, $s); $len = strlen($s)-1; while ($len >= 0) { if ($s[$len] == '.') { $s[$len] = '0'; $s[$len+1] = ''; } $len--; } echo trim($a.'.'.$b.$s); // Will output 123.50 ?>
×
×
  • 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.