Jump to content

oni-kun

Members
  • Posts

    1,984
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by oni-kun

  1. PHP Help is "Do you need help with some code you wrote?" and miscellaneous questions thread would fit nicely here But it's really not a 'need', Maybe write a suggestion in the appropriate forum and see what comes of it!
  2. I like the idea, I mean the simplicity of asking something without all the overhead is nice. But it's just simply not such a good practise. Users may get confused if a lot is posted, and it may defer somewhat amount of valued traffic (such as SE indexing), IRC just seems most familiar for it, a lot of good posters hang around there. I guess this thread could be a suitable mini-Q&A thread for awhile, it's not bad in any way if one has a lot of random questions they're wondering about, It's more productive than a prolonged thread in PHP Help that only attracts a few people who've only read the title (that won't know there are other questions within)
  3. I don't think there's a clear result
  4. Your RSS feed is not full of "updates", rather a superfluous amount of very random PHP information that shouldn't really be related to your up front site. The search box overlaps content sometimes, and doesn't look so appealing. Why does a user need to know their IP? And page ranks are deprecated.
  5. Yes, the colours are really doing my head in. And in your random link tutorial: A) That is not very 'random' for this purpose.Why not use a weighted mt_rand or.. Should I be so daunted to say, array_rand! B) A multidimensional array instead of two arrays for each name is preferred and more efficient. C) ---v What on earth does displaying a random address have to do with a "Bad word filter" ? EDIT: If you're so happy about your traffic, Then work on putting out quality content, then it should be justified.
  6. Maybe short tags should be placed into the swear (in programming language?) filter on SMF. [ot]So many "shy" emoticons you use[/ot]
  7. You would use Regular expressions (RegEx), with the function preg_replace. Here is a somewhat simple example I wrote, it should work fine: <?php $text="www.phpfreaks.com is a great site, Look at www.phpfreaks.com/index.php?&foo=bar#baz"; $text = preg_replace( "/(?:^|\b)((((http|https|ftp):\/\/)|(www\.))([\w\.]+)([,:%#&\/?=\w+\.-]+))(?:\b|$)/is", "<a href=\"$1\" target=\"_blank\">$1</a>", $text); print $text; ?>
  8. Heh, Maybe there should be a sticky on how to handle slashes from Magic Quotes, They're almost as bad as headers sent errors. A lot of people tend to not understand their modus operati.
  9. Your code uses isset and a comparison operator at the same time, which cannot be (Unless testing for TRUE or FALSE) if (isset($_SESSION['userid']) == 'Admin') { Should be: if (isset($_SESSION['userid']) AND $_SESSION['userid'] == 'Admin') { You can read more about operators here: http://php.net/manual/en/language.operators.comparison.php Cookies are not needed, Sessions are kept on the server (Only a cookie with the session ID is set to the user) and can be changed to what you wish. Again, the basics are really of use.
  10. Your new edit on the code is correct, in the point being it will only show if userid is set to "Admin".
  11. Where do I see "killing" in the manual? Destroying the session will remove the data from memory (To some extent), Killing the session or deleting the client's cookie/and or your server's /tmp entry of the data is another subject, that should not in any practise need to be used on a logout such as you mentioned.
  12. I meant on the input, such as you queries. Notice you are using mysql_real_escape_string prior to replacing, This will not fix the problem with your single quote in col3 and is most likely breaking the SQL statement.
  13. Your brace ( } ) is not enclosed within the PHP tags so it will be useless, but otherwise yes, that will work. Be aware anything below the brace (Not in an ELSE statement as your example) will be visible to any user, you should really read up on the basics before you tackle anything harder.
  14. We do have an IRC channel which was designed for this.
  15. The definitions of killing and destroying fortunately relate to your question.
  16. The quote is most likely encoded as an HTML entity and is not caught by the str_replace call. Use var_dump on the output of the file or query and make sure the quote is indeed what you think it is, it is always useful to debug and check inputs before assuming a function does not work.
  17. Read up on sessions here: http://www.php.net/manual/en/book.session.php http://www.tizag.com/phpT/phpsessions.php I assume you know how to handle the $_POST data from the forms, Match it and if the password is correct use the following line (very simple example): if ($_POST['user'] == "Mark" && $_POST['password'] == "123") { $_SESSION['userid'] = "Mark"; } Of course with session_start at the beginning of each file. On the index the $_SESSION superglobal will have the user ID set (in userid), thus the index can tell if the user is logged in or not.
  18. Generate a session for the user, then it's as simple as ABC. <?php session_start(); //Required on pages using sessions if (isset($_SESSION['userid'])) { print "You are logged in, here is the form"; ?> <form ...> </form...> <?php } else { print "Please log in before using this form"; } ?> You should read up on the basics, as this should be fairly simple to do.
  19. So is your question answered?
  20. As long as you authenticate the user to.
  21. Not by any predefined behaviour, PHP is much different in default infrastructure and goal than ROR.
  22. oni-kun

    Hey!

    Hi. Welcome to the forums
  23. oni-kun

    Username

    It's not our fault you did not read the terms you accepted, you should have before you posted your first post.
  24. Why not see if the queries are actually running? Also you should learn basic code formatting... Also The error in the first query is very obvious if you checked for it with the first step of debugging. EDIT: Sorry, browser lagged for 10 minutes to post
×
×
  • 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.