Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. Have you tried doing some research? You should know, the links in your signature have a nofollow attribute, so making threads related to your site for search engine ranking isn't going to work.
  2. The header and footer use <header> and <footer> tags.
  3. Sometimes what people want to target is the first paragraph, not the first child. It's common for a heading to be the first child of a section element. There's a :first-of-type selector that solves this problem, but it's supported by Internet Explorer 9 and above while :first-child is supported by Internet Explorer 7 and above. If you can afford to lose viewers who have IE 8 or 7 then it's safe to use the :first-of-type selector.
  4. The template only decides what the form looks like, not how it works. You need some PHP code to send the mail. Either PHP, or some other server-side language. W3Schools has a section about sending mail with PHP here: http://www.w3schools.com/php/php_ref_mail.asp You should already underatand PHP forms, superglobals and other features.
  5. If you're targeting the first paragraph in an article or section element you would use article p:first-child:first-letter or section p:first-child:first-letter However, if the paragraph is not the first element (for example, if it's preceded by an <h2>) it will not be targeted by that selector.
  6. A section is a semantic element. It's a generic block element that doesn't actually do anything. By default in most browsers it's just a block with no background, border, margin or padding. The MDN describes it well: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section
  7. The selector would be p:first-child:first-letter
  8. You can detect the window's width using the innerWidth property. This page has a cross-browser solution as well: http://www.w3schools.com/jsref/prop_win_innerheight.asp So what you would do is: if( window width is 600 or less) { Change video source to small video } else { Chang video source to large video }
  9. I would not recommend loading two videos and then only showing one of them. Use Javascript to modify the properties of the video once the page has loaded. This stackoverflow thread explains how to change the video source: http://stackoverflow.com/questions/5235145/changing-source-on-html5-video-tag
  10. Each language has its purpose. HTML give the page a structure, CSS give it appearance and Javascript is for behavior. HTML alone can't do anything to process form elements. With Javascript it's very simple to do what you're asking.
  11. The html and body elements need to have a height. html, body { height: 100%; } From that point on, all ancestors of the element you want to set the height of also need to have 100% height.
  12. Ingolme

    Where to Find

    Paragraphs are HTML, not CSS.
  13. Have you learned any Javascript? Reading through the W3Schools Javascript tutorial should give you enough knowledge to do this.
  14. Many browsers prevent AJAX requests from HTML files on the local filesystem for security reasons. Firefox normally works, so you can use Firefox for testing on the filesystem. Otherwise you will need to set up a server on your computer to run it.
  15. "request" is not an HTTP method. GET appends data to the URL and has a size limit, POST does not put the data in the URL and can send about as much data as the server will allow. As far as the database is concerned, it doesn't really matter how the data got there. GET requests are usually used for reading data without changing anything on the server while POST is used to give data to the server, so for a database-driven application the most common approach is to use POST to put the data in and GET to pull the data out.
  16. All you really need to do to prevent anything from breaking the textarea is to encode it using htmlspecialchars() http://php.net/html_special_chars <?php $content = '<html> tags and </textarea> that could potentially break things'; ?> <textarea><?php echo htmlspecialchars($content); ?></textarea>
  17. That's outside the capabilities of HTML. Features like that are programmed in Javascript using AJAX.
  18. Ingolme

    OO PHP

    This code is not going to work at all. Where did you find it? First of all, the PHP block should start with "<?php", not "<?". That line might be working now but won't work on all server configurations Second, you cannot extend a class from itself, that doesn't make any sense. I don't believe you can actually call $this[$key]. you should actually be calling $this->$key, or perhaps $this->data[$key]. That line is likely to cause an error. Square brackets [ ] are not an object-oriented thing, they're a basig programming ocnstruct. Square brackets indicate an element in an array, see the chapter on arrays: http://www.w3schools.com/php/php_arrays.asp The reason __set() has two parameters and __get() only has one is that when you want to set a property you need to say the name of the property you want to set and what value you want it to have. When you want to get the value of a property, you just need to say the name of the property you want to get the value of. I don't think your problem is with object-oriented programming, you seem to lack some understanding of basic programming in general.
  19. Both of those examples should work. If they're not working then perhaps you're not actually printing $data to the page. I'd have to see your page to figure out why it's not working. The bgcolor attribute is not standard, you should be using CSS to give a background color. You also have forgotten the # symbol next to the hexadecimal code, at the very least it should be bgcolor="#FFFFCC"
  20. The simplest password protection scheme is just an if() statement. It's effective, but not flexible. <?php $username = 'Person'; $password = 'Password'; if(isset($_POST) && $_POST['username'] == $username && $_POST['password'] == $password) { ?> Protected content goes here <?php } else { ?> <form method="POST"> <fieldset> <legend>Please log in to view content</legend> <label>Username: <input type="text" name="username"></label> <label>Password: <input type="password" name="password"></label> <input type="submit" value="Log In"> </fieldset> </form> <?php } ?> If you use Javascript for password protection I will personally break into your site. Javascript is 100% ineffective at password protection and what's worse, if you have one of your own passwords as the login, the person breaking in now also knows your password and if you use that password on other sites you're going to get hacked.
  21. This leaves you open to SQL injection (people can hack your database), be sure your strings are sanitized. For database connection you should look into prepared statements. This will completely remove your syntax problem and additionally ensure nobody can hack you. The thing prepared statements don't do, though, is give placeholders for table and field names. For these you'll have to manually sanitize and add the strings. To sanitize table names I recommend removing any backticks from the input string before adding it to the query and wrapping the table name in backticks // This value could come from anywhere, but for the sake of security, it might be better to just hardcode it right into the SQL string $table = 'my_table'; // Sanitize table name $table = str_replace('`', '', $table); // Create the SQL $sql = "INSERT INTO `$table` (baseID, tableName, fieldNames) VALUES (?, ?, ?, ?)" // Instantiate a PDO object $pdo = new PDO( ... ); // Prepare the query $query = $pdo->prepare($sql); // Execute the query with the data $data = array( 8, // baseID 'headerfields', // tableName 'abc,def', // fieldNames ); $success = $query->execute($data); Could you explain why you want to store data about a table in another table? This whole thing is probably not necessary.
  22. This array structure is not ideal for that situation. You're going to have to first construct a temporary data structure to point to the data you want to delete. $existing = [The array you currently have] /* Step 1. Create a new data structure */ $temp = array(); foreach($existing as $index => $data) { // A key to group times from the same date $key = $data['date']; // A timestamp to measure which dates are more recent $timestamp = strtotime($data['date'] . ' ' $data['time']); // If there aren't any times for this date yet, store this one if(!isset($temp[$key])) { $temp[$key] = array( 'index' => $index, 'timestamp' => $timestamp ); // If the largest stored time for this date is earlier than the time of the current element then store the current element } else if($temp[$key]['timestamp'] < $timestamp) { $temp[$key]['index'] = $index; $temp[$key]['timestamp'] = $timestamp; } } /* Step 2. Delete items based on the new data structure */ foreach($temp as $value) { $index = $value['index']; unset($existing[$index]); } /* Step 3. Remove gaps left by unset() */ $existing = array_values($existing); This kind of task, though, seems ideal for a database to do rather than putting the work on PHP. Databases are highly optimized for searching and manipulating data like this.
  23. You need a better way to structure your data. Something like this, for example: { name : "MainArray", data : [ { name : "SubArray1", data : [ ... ] }, { name : "SubArray2", data : [ ... ] }, { name : "SubArray3", data : [ ... ] } ] }
×
×
  • Create New...