Ingolme

Moderator
  • Content count

    12,872
  • Joined

  • Last visited

  • Days Won

    305

Ingolme last won the day on April 19

Ingolme had the most liked content!

Community Reputation

771 Excellent

3 Followers

About Ingolme

  • Rank
    Foxy Mod

Previous Fields

  • Languages
    Javascript, PHP, MySQL

Contact Methods

  • Website URL
    http://www.thecodingfox.com/
  • ICQ
    0

Profile Information

  • Gender
    Not Telling
  • Interests
    Web development, drawing, videogames, foxes.

Recent Profile Visitors

157,854 profile views
  1. You will need to change your code. As of PHP 5.5, the server will show warning messages if you're using the mysql library and in PHP 7 the mysql library will no longer be supported. If you're interested in keeping your code working on newer platforms you will have to update it to use a newer library.
  2. Which element are you setting the height for? Setting the height of .first will affect the height of the background image. You can also set the padding of .first (not margin) to give more space for the background within the element.
  3. The form attribute only applies to form control elements. It doesn't exist on elements like <div> or <p>. What kind of element are you referring to when you say "non-form element"? This is regarding the form attribute from the MDN page for the <input> element: When the element is a descendant of a <form> element the form attribute is not needed. If the element is not inside a <form> then the form attribute will indicate which form the element belongs to so that when the form is submitted the element's value is added to the data that is sent. I'm not certain how fieldset elements behave, I would guess that the fieldset's children would belong to the same form that the fieldset belongs to, but it can be easily confirmed with an experiment. Experiments can be done with the form attribute by submitting the form and seeing which values get sent to the server. My guess before doing experiments is that a child of one form that has a form attribute from a different form will be added as a value when either of the two forms are submitted.
  4. The mysql library is deprecated for security reasons, use PDO or MySQLi. To stop injection, escaping is no longer the correct solution, the proper solution is to use prepared statements. W3Schools has a tutorial page about prepared statements.
  5. You can use scandir() to list files in a directory and generate the HTML for the images. The line breaks exist, but HTML doesn't render line breaks unless you specifically put a <br> element. You can use nl2br() to show line breaks in the text provided by users. You can't choose the size of a file, but you can give a size limit in the file uploader. There are plenty of PHP file upload tutorials, you should look at some of them. The W3Schools tutorial has sections explaining how to limit the file size and file type. You can use str_replace() to change substrings into something else, such as in the following example: <?php $string = str_replace(':)', '<img src="smiley.gif">', $string); ?>
  6. I don't know what you want it to do. Should you users see the literal string "<h3>" in their e-mails or not?
  7. It strictly depends on what you want to see. From what I've read in your previous posts, you actually want angle brackets ("<" and ">") to appear in your e-mail. You need to sanitize the $_POST variable when you put it into the template. There are two different environments you're working with: Environments that use plain text (Database, PHP backend) Environments that use HTML (Browsers and e-mail clients) For environments that use plain text, no sanitization is needed. When you put the variables into an environment that uses HTML then you have to sanitize it.
  8. That's true. The $_POST variable and the database table will have exactly the same content that you typed into the textarea. What you have to watch out for is that if you put the content of the $_POST variable into an environment that reads HTML (a browser or e-mail client) it will parse the HTML.
  9. Your current solution is far more efficient than constructing an array and using in_array() on each iteration, but there's an alternative to in_array() which is much less costly: Using the keys of an associative array. <?php $exclude = array( 'item1' => 1, 'item3' => 1, 'item4' => 1 ); $dir = '/myFolder'; $filesDir = new FilesystemIterator($dir, FilesystemIterator::SKIP_DOTS); $fileName = ''; foreach ($filesDir as $file) { $fileName = $file->getBasename(); if(!isset($exclude[$fileName])) { echo $fileName.'<br>'; } }
  10. If you want to see "<h3>Q&A</h3>" instead of "Q&A" then you should pass it through htmlspecialchars() before putting it into the template any anywhere else were you will be using it. $html_message = str_replace('%something%', htmlspecialchars($something), $html_message);
  11. Have you tried the same code in another environment to see if it's just an issue with the browser itself? Generally the mouse wheel doesn't scroll something unless it's focused, so you have to click on the region before scrolling it.
  12. If you actually want the HTML to be rendered, then no sanitization is needed at all. If you want to literally see all the tags then you would use htmlspecialchars() right before putting the data into the HTML template. There's no need to sanitize it for storage even when you want to prevent HTML injection. You sanitize it only right before using it.
  13. You should stop using the mysql library, it's been deprecated for over a decade for security reasons. Every manual page for mysql_ functions has a large warning on them: http://php.net/mysql_query You should not put variables right in your SQL string, that leaves your code open to being hacked. Use prepared statements, W3Schools had a tutorial page about them: https://www.w3schools.com/php/php_mysql_prepared_statements.asp
  14. Float puts an element to the left or right of all the content that follows it if that content fits in the remaining space. In this W3Schools example, the menu is 25% width and the content is 75% width. If you tried to add something else, it wouldn't fit because it exceeds 100% of the available width. If you want to add a third column you have to adjust the widths. A floated element will only appear next to content that follows it and below content that precedes it unless the preceding content is also floated. I haven't seen your specific code, so I don't know for your particular case why it's not behaving as you intended.
  15. Store the completed state of the form in the session, then check whether the session value is set before showing the panel. You can do this in Javascript with localStorage, sessionStorage or cookies. You can do it in PHP using sessions or cookies.