Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by Irate

  1. Hm, right, I guess I used single quotes because I didn't remember that vars aren't used as their values within single quotes. The . operator would've worked for it, too, but thanks anyway.About SQL injections, is it really necessary to escape the preset input value I gave the user? And I guess you're right anyway, I prefer to ask once again to be secure. I'll also be sure to check prepared statements thoroughly, got it. I think I'm still used to JavaScript where such search would have returned an indexOf-like result, but it could also that I didn't know what I did ;~; I want to be sure that the query returns true every time executed, even when it is 0 because 0 answers correct is also possible (yet rare, I still want to be prepared for it). As for the switch statement, I basically want it to echo out a new input button that contains the total amount to submit it to somewhere (I have that submission action handled). But I guess an array would work for that, too. I'll take some time to deeply review this when I'm on my PC, my mobile is not all too ideal for this. Thanks anyway for answering, appreciate it.
  2. So, after my last topic on this subject, I figured out how to validate my quiz with arrays, using only POST methods, and I have made some attempts to do so with MySQL. I have a table named quiz in a database named 'DA' where each row has one primary key 'pid' as integer, simply numbered down from 1 to 35. Next I have the second column named 'answer' which contains the value attribute from my input buttons (the correct one out of 2-6 answer options). How would I attempt to validate the quiz with the result I get from MySQL? Code fragments I have so far... <?php // quiz.php // do something like headers here etc. <form action="score.php" method="POST"> <input type="radio" name="1" value="a1">Question 1<br> <input type="radio" name="1" value="b1">Question 2<br> // and so on ?>Now score.php... <?php // score.php $total = 0; $validate = new mysqli('localhost', 'admin', 'password', 'DA'); if(!$validate){ die('A database connection problem occured.'); } foreach($_POST as $answer){ $query_quiz = ('SELECT answer FROM quiz IF($answer = answer)'); if($validate->query($query_quiz)!=-1 AND $validate->$query_quiz>0){ $total++; } } switch($total){ case 0: // now do the case check for the score and display some misc. messages exit; break; case 1: // and so on, until 35 exit; break; } ?>I cannot do a functionality check right now since I am on my mobile, but I would like to get some feedback on the code and where I could improve the code. Remember, I'm still new to PHP Anyway, thanks in advance!
  3. window.onbeforeunload = function(){ if(!required_fields){ // do something to check if all fields are filled var conf = confirm("You still have some required fields to fill out. Cancel?"); if(!confirm) return false; else { // add a function that sends something to your database } } }; Try something like that.
  4. Could you provide a screenshot how it looks like at the moment?
  5. How about looking for messages and breaking while there are no messages? A while(true) loop is a hefty workload...
  6. Alternatively, do what I did and buy yourself long and detailed books on this subject.
  7. I edited httpd.conf, I am sure about it. So I cannot have Skype online while I am trying to boot Apache? :l
  8. Bump, I guess. Still getting the same error.
  9. A quick Google research gave me this: http://dev.mysql.com/doc/refman/5.1/en/sql-syntax.html Alternatively, check if you have any IT stores near your location who sell books on that matter, it works wonders.
  10. Well, if it's not your homework, sure. Do you want the carousel to turn automatically after a time or only when someone hovers over it?
  11. Well, this forum isn't here to help you to do your homework :s Anyway, do you have any idea at all how you could solve this?
  12. Hmmm... I changed Listen 80 to Listen but when I try to start Apache from my XAMPP Control Panel, this is the warning I receive before even starting... 17:42:25 [main] Initializing Control Panel 17:42:25 [main] Windows Version: Windows 7 Home Premium SP1 64-bit 17:42:25 [main] XAMPP Version: 1.8.1 17:42:25 [main] Control Panel Version: 3.1.0 3.1.0 [ Compiled: September 20th 2012 ] 17:42:25 [main] Running with Administrator rights - good! 17:42:25 [main] XAMPP Installation Directory: "c:\php\xampp\" 17:42:26 [main] Checking for prerequisites 17:42:26 [main] All prerequisites found 17:42:26 [main] Initializing Modules 17:42:26 [Apache] Problem detected! 17:42:26 [Apache] Port 80 in use by "system"! 17:42:26 [Apache] Apache WILL NOT start without the configured ports free! 17:42:26 [Apache] You need to uninstall/disable/reconfigure the blocking application 17:42:26 [Apache] or reconfigure Apache to listen on a different port 17:42:26 [Apache] Problem detected! 17:42:26 [Apache] Port 443 in use by "c:\program files (x86)\skype\phone\skype.exe"! 17:42:26 [Apache] Apache WILL NOT start without the configured ports free! 17:42:26 [Apache] You need to uninstall/disable/reconfigure the blocking application 17:42:26 [Apache] or reconfigure Apache to listen on a different port 17:42:26 [main] Starting Check-Timer 17:42:26 [main] Control Panel Ready 17:42:29 [Apache] Attempting to start Apache app... 17:42:30 [Apache] Status change detected: running 17:42:31 [Apache] Status change detected: stopped 17:42:31 [Apache] Error: Apache shutdown unexpectedly. 17:42:31 [Apache] This may be due to a blocked port, missing dependencies, 17:42:31 [Apache] improper privileges, a crash, or a shutdown by another method. 17:42:31 [Apache] Check the "/xampp/apache/logs/error.log" file 17:42:31 [Apache] and the Windows Event Viewer for more clues
  13. Fair enough. I can set the port Apache is listening to to 8080 without conflicting the 80 port of 'system', right?
  14. So, basically, I have configured IIS via Command Prompt and everything's working fine, now I have downloaded WAMPP and Apache throws me - rightfully - an error that it cannot be started because 'server' is already listening to Port 80. How do I change the port IIS is listening to via Command Line? I want to experiment with both IIS and Apache, so I'm asking. Thanks in advance. P.S.: A method to change the port Apache is listening to is also welcome.
  15. How about adding !important to it? :/ To be honest, err, change the whole CSS you are using to fit the needs of it, that would be my suggestion.
  16. Try applying 'position: fixed;' to all other elements which you don't want to be moved. Also you could try setting the z-index of the div to 999 when hovering over it.
  17. You need a properly working SMTP Server registered to a valid domain name to send those. Even if you have that, your host domain must match a valid and registered domain on the internet and even by that time, some email hosts still disallow PHP to send emails to them.
  18. You can use Ajax to submit it without having to reload the browser page. But generally you would need PHP to make proper use of the form.
  19. Either use a frame/iframe tag or do URLRewrite. An example for an iframe and a frame tag (my school uses the frame tag on their home page, by the way): <!DOCTYPE html> <head> <title> Site Title </title> </head> <body> <iframe src="index.php" name="Index"></iframe> <!-- or use this <frame name="Main Site" src="index.php?rewrite=main%20site"></frameset> --> </body> </html> You can in fact do this with embed and object tags, too. I wouldn't use the URLRewrite option unless you are not familiar with HTML (which is unlikely because HTML is much easier than URL Rewriting), though.
  20. I'll give SQLite a try if you say it's easier to set up. I have set-up books about PHP and SQL (I have IIS set up correctly already) but I can't find the rograms because the books are German and my PC language is English >.<
  21. Do you have any code made yourself yet? Post it if you have, please...
  22. Seeing as I want to include 35 Questions with each 2 to 4 radio buttons and 4 essay questions, I think SQL would my weapon of choice once I get around to properly administering my own database, then I think I will be ready to move onto an external server host and will post a new topic about this. Thank you for your input.
  23. Depending on your server host, you should be able to do so over your Control Panel...
  24. Good to know... Thank you for your help and sorry if I'm still too noobish @_@
  25. I assume the database would still work within an iframe tag, right? If so, I'll reply to this topic once I have the database doe.
  • 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.