Jump to content

scootstah

Staff Alumni
  • Posts

    3,858
  • Joined

  • Last visited

  • Days Won

    29

Everything posted by scootstah

  1. Well, $sound variable is the value of the submit button. So for the first button it would be "Escuchar0", the second would be "Escuchar1", and so on. Okay, you can remove the else block then. This way, you are only running the embed HTML if a button was submitted, and you still display all the buttons after it was submitted.
  2. Well, I don't have the audio files, so I obviously can't test that. But, I echo'd out the value of $file and it was correct. However, the page should be blank once submitted, based on that code. Nothing visual is output after the submit button is pressed. View the page source, and confirm that the HTML is correct, and that the path to the audio file is correct.
  3. Sorry, I made a typo. <?php if (!empty($_POST)) { if (isset($_POST['escuchar2'])) { $nombre = 'DIRECTORY'; $sound = $_POST['escuchar2']; $file = "./grab/$nombre/$sound.wav"; echo '<embed src="' . $file . '" hidden="true" autostart="true"></embed>'; } } else { $total = 5; for ($i = 0; $i < $total; $i++) { echo '<form method="post"> <input type="submit" name="escuchar2" value="Escuchar '. $i .'"> </form>'; } } I tested it this time, and it does what is expected. In the future, it would be good to turn on error reporting. The fact that you didn't see this error, and saw a blank screen, is indication to me that you don't have error reporting on. A quick way to enable it (on a per-script or per-application basis) would be to put this at the top of your script: error_reporting(-1); ini_set('display_errors', 1); You can also turn those on in your php.ini to make it site-wide (more about that here).
  4. No, those are not the same. if (!empty($_POST)) is checking if the $_POST superglobal is not-empty, which means there is a POST request. If you add a key in there, then you are only checking for that specific key. My point in all this is that you don't necessarily need to create a dynamic key from the session, you can simply accept any POST request, and then make sure the data is what you expected. In case you don't want to do that, I already showed you how to format the dynamic key. In case you missed it, here it is again: $key = 'key' . $_SESSION['enquete_vragon']; if (isset($_POST[$key])) {}
  5. Some of the benefits of OOP are: - encapsulation - polymorphism - code reuse - abstraction - modularity For very small projects, OOP may not seem to have any benefit. In fact, it might be worse - by over complicating the problem. In my opinion, this is an excellent book on OOP, and how it applies to PHP.
  6. Did you even read my post?
  7. A for loop is better in this situation, because it uses less code and this is exactly what it is used for. for ($i = 0; $i < $total; $i++) { echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '"> <input type="submit" name="escuchar2" value="Escuchar '. $i .'"> </form>'; } Secondly, you need to move the if(isset($_POST... block out of the loop, so it is only executed once. Also, you shouldn't use $_SERVER['PHP_SELF'] in this way because it opens up an XSS vulnerability. If you want the form to submit to itself, simply leave the action attribute blank or remove it completely. Here is some updated code which should work: <?php if (!empty($_POST)) { if (isset($_POST['escuchar2'])) { $nombre = 'DIRECTORY'; $sound = $_POST['escuchar2']; $file = "./grab/$nombre/$sound.wav"; echo '<embed src="' . $file . '" hidden="true" autostart="true"></embed>'; } } else { $total = 5; for ($i = 0; $i < $total, $i++) { echo '<form method="post"> <input type="submit" name="escuchar2" value="Escuchar '. $i .'"> </form>'; } }
  8. Something like this? $key = 'key' . $_SESSION['enquete_vragon']; if (isset($_POST[$key])) {} Note that you don't need to check if the specific submit button was set. You can simply check for a POST request, and then process it accordingly. You can do that with if (!empty($_POST)){}
  9. Okay, so then you will need to make a custom page in WordPress where you can process the form. Or, just a static file in the WordPress root or something.
  10. What? No. How did you come up with that from my post? I said to leave out the action attribute from the form, so that it will submit to itself.
  11. Well, it depends how you implement the plugin, but you could omit the action attribute and have the form send to itself and process it on the same page.
  12. I assume you are working as part of a team of developers. Have you gotten their input on the situation? Perhaps, since you're the new guy, you just don't carry enough weight to get through to your boss. But, if the whole team of developers are pushing him, he might succumb.
  13. You're just messing up the quotes. You don't need to concatenate new lines like that in PHP. $sql = mysql_query("SELECT id, fname, mi, lname FROM $dbt ORDER BY date DESC LIMIT $offset, $rec_limit"); EDIT: Also, you need to put quotes around array indexes. $_POST[arc] should be $_POST['arc']. And, you should be sanitizing all user input before using it in a query, to prevent SQL injection. Normally you would use mysql_real_escape_string, but I'm not sure if that would work for the table name. You might just have to strip special characters (like quotes or slashes) from the input completely. One last thing - you should probably put backticks around the table name, in case it has a space in the name. FROM `$dbt`
  14. I am a he. The picture belongs to my girlfriend, lol.
  15. Does that come as a surprise?
  16. Yes, it's our first. And yes, very excited! The due date is approximately March 25th.
  17. Personally, I would put scripts that you don't want accessed directly either above the docroot, or in a directory protected by .htaccess. For the .htaccess, all you need is: order deny,allow deny from all In either case, scripts can still be used by other scripts (include() or require()), but cannot be accessed directly by URL.
  18. Use a framework (they aren't all bloated) or an ORM, like Doctrine or Propel.
  19. Since you are using some sort of database wrapper, I can't see the query. So, the first thing you need to do is figure out what the actual query being run is and make sure everything is okay with that. How deep can the submenus go? If they can only go 1 level deep, you should probably use a JOIN to select them instead of running queries in a loop. If it can be more than 1 level deep you'll probably want to store it in a hierarchical format. See these two articles for that: http://www.sitepoint.com/hierarchical-data-database/ http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/
  20. Have any rows been returned?
  21. I don't see any code that indicates you are sending Twitter anything.
  22. What does $_FILES['userfile']['error'] yield?
  23. This topic has been moved to CSS Help. http://forums.phpfreaks.com/index.php?topic=363176.0
×
×
  • 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.