Jump to content

50r

Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by 50r

  1. what i was trying to ask was, i am working on a system that will manage tenants so tenant on their registration, need to pick a subscription cycle which can be monthly,quarterly semi-annuall, and annualy. what i did not know is that there were such simple functions like mktime and the date(t) format. But my intent in this question was the ability to add up a three or six or monthly cycle regardles of the numbers in the month but just bind it all in just a simple variable monthy, quarterly and soo on. thanks to you guy good bless. .
  2. Thanks for the quick replay i also found this one which also works perfectly fine. function get_days_in_month($month, $year) { return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year %400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31); }
  3. I am working on a tenance script that will need to know how many days are in the current month and also to check if the current february is not in a leap year. this is the code that i was trying to use but is there any better way to handle this? $month = strftime('%m'); $year = strftime('%Y'); if ($month == 1 || $month == 3 || $month == 5 || $month == 7 || $month == 8 || $month == 10 || $month == 12) { $days = 31; } elseif ($month == 4 || $month == 6 || $month == 9 || $month == 11) { $days = 30; } elseif ($month == 2) { if(($year % 4 == 0) && ($year % 100 != 0) || ($year %400 == 0)) { $days = 28; } else { $days = 29; } } echo $days;
  4. I dont understand the question. are you asking why the " still show up in the echoed string from the database even though it was escaped on insert? if thats the question then the answer is escaped values are handled differently depending on a dbms that you are using. but if you escape a string, you are telling the dtatabase not to use the " for sql execution rather egnore them and save the string as a normal string. thats why when you sometimes echo an escaped string from a database, it will display with the " on. the escape function dont strip the " but does inform the database as i have explained above. thanks.
  5. http://crackstation.net/hashing-security.htm the last time i checked that site it was down but it has a very good tutorial on how to hash and sal a password. i use there sample code but it will be better if you read from him first on how he explains that code. public static function create_hash($password) { // format: algorithm:iterations:salt:hash $salt = base64_encode(mcrypt_create_iv(PBKDF2_SALT_BYTES, MCRYPT_DEV_URANDOM)); return PBKDF2_HASH_ALGORITHM . ":" . PBKDF2_ITERATIONS . ":" . $salt . ":" . base64_encode(self::pbkdf2( PBKDF2_HASH_ALGORITHM, $password, $salt, PBKDF2_ITERATIONS, PBKDF2_HASH_BYTES, true )); } private static function pbkdf2($algorithm, $password, $salt, $count, $key_length, $raw_output = false) { $algorithm = strtolower($algorithm); if (!in_array($algorithm, hash_algos(), true)) die('PBKDF2 ERROR: Invalid hash algorithm.'); if ($count <= 0 || $key_length <= 0) die('PBKDF2 ERROR: Invalid parameters.'); $hash_length = strlen(hash($algorithm, "", true)); $block_count = ceil($key_length / $hash_length); $output = ""; for ($i = 1; $i <= $block_count; $i++) { // $i encoded as 4 bytes, big endian. $last = $salt . pack("N", $i); // first iteration $last = $xorsum = hash_hmac($algorithm, $last, $password, true); // perform the other $count - 1 iterations for ($j = 1; $j < $count; $j++) { $xorsum ^= ( $last = hash_hmac($algorithm, $last, $password, true)); } $output .= $xorsum; } if ($raw_output) return substr($output, 0, $key_length); else return bin2hex(substr($output, 0, $key_length)); } public static function validate_password($password, $good_hash) { $params = explode(":", $good_hash); if (count($params) < HASH_SECTIONS) return false; $pbkdf2 = base64_decode($params[HASH_PBKDF2_INDEX]); return self::slow_equals( $pbkdf2, self::pbkdf2( $params[HASH_ALGORITHM_INDEX], $password, $params[HASH_SALT_INDEX], (int) $params[HASH_ITERATION_INDEX], strlen($pbkdf2), true ) ); } private static function slow_equals($a, $B) { $diff = strlen($a) ^ strlen($B); for ($i = 0; $i < strlen($a) && $i < strlen($B); $i++) { $diff |= ord($a[$i]) ^ ord($b[$i]); } return $diff === 0; }
  6. There are two problem actually why no one has replyed to this post. 1 your question is quite not clear, 2 the code that you post is not well indented which makes it hard to read. Try by explaining what the problem is. do you want to retrieve data from a database? after you insert it or what?
  7. hello guys this seems simple but not in my case as per now. i have a table of categories with cat_id -------------------cat_parent_id----------- cat_name 7 ------------------------- 0 ---------------------- cat1 9 --------------------------- 0----------------------- cat2 11 -----------------------------7------------------------ cat3 now am using these categories as a menu on the front page. i have made a query that calls only cats that have a 0 for parent thats fine. in this case cat1 and cat2 are the main menu. i want to have an icon on a category that has a child which is cat3 that will show a user that if they point a cursor there, they will see hiden childrens. the proble is am on a home page that has no query in the url that i can use as a reference in my sql query. what kind of query can i do to put an icon on cats that have a child? before even a use clicks on it.
  8. Hey freaks i want to be sure on this, do are constants binded to global and local scopes like valuables? i see one code of my friend using constants in a class method but i dont see where he declairs them global. but they are defined from an included config file.
  9. i understand thanks guys maybe i am just being un petient.
  10. Hello freaks this has got me trying to figure out how to get the number of row using the select conunt() but i cant figure it out. here is the code $sql = mysql_query("SELECT COUNT(*) FROM tbl_menu WHERE module = $id"); if(!$sql){echo "there is an error".mysql_error();} I just want to catch the number of row as a result.
  11. this is not only going to depend on your php code, but it will also involve the structure of your database. make sure you understand what a word relational in database means.
  12. what are you trying to do? do you have a class inside a class? do you know anything about class referencing? extends?
  13. Thanks it was such a stupid biggner mistake. hope it helped @ arunpatal
  14. Hello freaks, many of the sites that i get dont seem worth spending money and time as they explain it cleary that their courses are durated for some 5day some 30 day i call that money waste and time waste. does any one of you good freaks know of any instution that offers an online instructor led advernced php course?
  15. did you set the $_SESSION['MM_address'] on the login page or where ever you set your sessions?
  16. 50r

    Functions

    function test(){ $test = "test"; $foo ="me"; $boo ="we"; return array($test,$foo,$boo); } $array = test(); then go ahead and use the valuable from the array.
  17. post your code lets build it from your idea. do you want the serial number to be checked on submit or bihind the seen?
  18. <?php require("config.php"); $topping = "<div id='Layer1' style='position:absolute;text-align:center; left:0px;top:0px;width:100%;height:33px;z-index:0;' title=''> </div>"; $topping .= "</br></br>"; if($header_toping = "yes"){ echo $topping; }else{ echo ""; } ?> then here put your html
  19. some where on google i saw this example but can someone try to break down for me cause i am failing to get it work. <script> function showDetails(id) { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("details").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","test.php?q="+id,true); xmlhttp.send(); } </script> <select name="users" onchange="showDetails(this.value)"> <option value="">Select:</option> <option value="1">1</option> <option value="2">2</option> </select> <div id='details'></div>
  20. let me hope you want to have a module or call it a plugin in your script that desplay the shopping cart and has a checkout batton. it updates everytime a user picks somthing and after selecting all that they want then they can either go to the page that you have now or they checkout. is that what you want?
  21. hello freaks i have a database table of tbl_menus (working on content management part of my script). menus are ordered according to the position in the table field position. on the site we have 4 spots for menus called modules but all menus are stored in one table tbl_menus we also have a field module in the table. now on the form in new menu.php the position will be based on the number of row based on the module field. the position select options are populated according to the number of row based on the module field. that mean while am creating a new menu, to populate the right number of row for someone to pick a position, i have to first run an sql count query base on a selection of the module. Javascript would be the base solution but how do i go about it?
  22. the same way you stored the session user name is the same way you are going to store all other session data that you want to use. you can query your database with the select query and the store the results in a session for each and every data that you want to use after that call that sessio9n where ever you want to use it.
  23. all you need to do is to restrict the photo upload page to only registered users. do you know how to create a php session?
  24. yeah the post data is already in the $_POST array and the database data is in the $row array but the question is how do i campare them and how do i exclude array items that are the same.
×
×
  • 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.