Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. That will be find if the OP was not going use IIS. @hardya look at the following guide in the PHP documentation for how to configure PHP with IIS http://php.net/manual/en/install.windows.iis7.php
  2. if the message tags does not contain http:// links then replace urls in $post_text before replacing the message tags. Also you should not use e pattern modifier for you replacement string. This could allow a hacker to run malicious code. It is is better to use preg_replace_callback. Your regex converted below // for each match this function is called. It will wrap the url in HTML anchor tags function url_to_link($matches) { $url = $matches[0]; $link = "<a href=\"$url\" title=\"$url\" target=\"_blank\">"; $link .= strlen($url) >=250 ? substr($url, 0, 250) . '...' : $url; $link .= '</a>'; // return the HTML for the link return $link; } $post_text = preg_replace_callback("/(https?:\/\/[^\s]+)/", 'url_to_link', $post_text);
  3. You can use the built in DateTime class to generate the dates between the start and end dates Look at the DatePeriod examples here http://php.net/manual/en/dateperiod.construct.php To encode the dates into JSON add each date to an array and then use json_encode
  4. You wont need PHP for this. All you need is HTML and a splash of CSS. Google "css button tutorial" or "css buttons" you should get tons of helpful results.
  5. To do this you need apply the css selector for styling the fields text and border color red when the login fails Why not have a go yourself?
  6. As I said cookies are used to identify the user. How this works is you when call session_start. It will check to see if an existing session is valid. It will do this by looking to see if a cookie named PHPSESSID exists. It will then retrieve the session id from that cookie and check to make sure the session has not timed out. If the cookie does not exist or the existing session has expired it will create a new session and a new PHPSESSID cookie will be issued with a new unique session id. It is this id contained within the PHPSESSID cookie that will identify the user. Having multiple users from the same network accessing the same site will not result in the same session being used. Each user will have their own unique session. PHP takes no notice of the users IP address.
  7. Do you mean to say you want the username and password fields to be colored red when the login fails?
  8. No. Sessions are tied to the user by cookies. Each user is assigned a unique session identifier.
  9. Ok. Took a further look at the code. Delete the following blocks of code. They are not needed at all 1) $query_User = "SELECT * FROM users"; $User = mysql_query($query_User) or die(mysql_error()); function GetUser($naam, $password) { global $User; while($row = mysql_fetch_array($User)) { if($row["username"] == $naam) { if($row["password"] == $password) { return true; } } } return false; } 2) <?php if ($_SERVER['REQUEST_METHOD'] == 'POST' ) { $username = trim(htmlentities(mysql_real_escape_string($_POST['username']))); $password = trim(htmlentities(mysql_real_escape_string($_POST['password']))); if (!empty($username) && !empty($password)) { if(GetUser($username, $password)){ $_SESSION['username'] = $username; } } } ?> . Next find this line header("Location: ". $MM_redirectLoginFailed ); And change it to echo "Invalid/Username or password. Please try again."; or if you want to display a message and also redirect the user at the same time change it to this instead header("Refresh: 5; url=$MM_redirectLoginFailed"); // redirect user after 5 seconds echo "Invalid/Username or password. Please try again."; exit;
  10. I just told you what to do.
  11. Try adding else { echo 'Username/Password invalid'; } After if(GetUser($username, $password)){ $_SESSION['username'] = $username; } #DreamweaverSpaghettiCode
  12. Umm... de ja veu http://forums.phpfreaks.com/topic/292323-need-help-with-writing-a-php-code-or-data-form/ See reply #2 in that thread for the answer.
  13. Is the code you posted the actual code you are testing? You'd only get that result if $end is being multiplied by 1000 and not $diff.
  14. What!!! Seriously you do not now how to do basic text file editing?
  15. Try changing MS to Microsoft
  16. Yes. Lines starting with // are ignored. These are called comments
  17. By using event listeners Could be more specific and tell us when you want that function to be called?
  18. You could just install the basic AMP (apache, php and mysql) stack on your computer then? Look into the following free software packages WAMP (windows) MAMP (mac) XAMPP (windows, mac and linux)
  19. No matter how you are going to display the data the last sentence to pyshco's posts still stands. You can use mysql_insert_id to get the id of record that was inserted. Then all you do is run a query to return the data that belongs to that id. I would also encourage you to stop using the mysql_* functions they are deprecated (meaning no longer supported). You should update your code to either mysqli or pdo database functions
  20. What is the output of printf('<pre>%s</pre>', print_r(($phpArray, 1));
  21. Paid hosting will be much better than any free hosting package could offer. A couple of dollars a month is not exactly going to break the bank is it. What has phpmyadmin got to do with it? phpMyAdmin is a php script for managing your mysql databases through a web interface. I think you maybe confused with mysql maybe? Also what I find funny is you're using a premium script but you dont want to pay for hosting.
  22. Not a wordpress user but does the following work? function childtheme_cat_limited_blog( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'events_categories', 'mycategory1' ); $query->set( 'category_name', 'mycategory2' ); } } add_action( 'pre_get_posts', 'childtheme_cat_limited_blog' );
  23. Initialize $gr_total outside of the while loop $gr_total = 0; while ($row = odbc_fetch_array($result)) Also please wrap your code in tags or click the <> button in the editor. (I have edited your posts for you)
  24. Functions have their own variable scope. You need to pass $connection to your mysqli_prep function as an argument. You should ideally use prepared statements rather than escaping the values manually.
  25. Yes using an the update query like you showed if you're converting plain text passwords to md5 or sha1 (which you should not be doing). You will need to do something like this if you're going to use password_hash // connect to db $mysqli = new mysqli('localhost', 'username', 'password', 'database'); // get the user id and password from users table $result = $mysqli->query('SELECT id, password FROM users'); // prepared statement for updating the password $stmt = $mysqli->prepare('UPDATE user SET password = ? WHERE id = ?'); // bind the values to the statement $stmt->bind_params('is', $id, $password); // loop through the user id and passwords in the resultset while(list($id, $password) = $result->fetch_row()) { // convert the existing plain text password to a hash using password_hash() $password = password_hash($password, PASSWORD_BCRYPT); // update the password in the database $stmt->execute(); } md5 or sha1 or any other encryption algorithm can not be decrypted easily. All an hacker is doing is generating millions of md5/sha1 hashes (a secound) and seeing if the generated hash matches any of your password hashes in your database. Once a match occurs the hacker looks back and sees what sequence of characters where used to generated that hash. This is how a hacker then gets to know your password. The idea of adding salt to a password is to make it stronger and make it a lot harder for a hacker to find a matching hash. However this is still not enough as eventually a match will still be found no matter what salt you use. The purpose of password_hash is to add latency each time a hash is generated slowing the hacker down for every generated hash. Check out ircmaxwells post for more information as he'll explain it better than me
×
×
  • 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.