Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. The issue is not related to PDO. The reason your code is not working is that your logic is wrong. This is the structure your code has: $username = $_POST['username']; $password = $_POST['password']; if($username && $password) { } elseif ($username && $password) { } elseif ($username && $password) { } else{ } You're making the exact same comparison three times in a row. If the comparison is true, only the first one will run, if the comparison is false then only the else block will run. The solution to your problem is to do one single query and pull out values from all three fields: Administrator, License, and Scorer. After these values have been pulled out, read these values and make a decision based on them. You are using prepared statements wrong, you should not put variables into the SQL string, put placeholders and then assign values to the placeholders, as shown in the tutorial page: https://www.w3schools.com/php/php_mysql_prepared_statements.asp If you do not fix that, your page is wide open to being hacked, people will be able to log in without knowing the username or password. You are also making the mistake of storing passwords in plain text in your database. This is a bad idea because if anybody manages to reveal the contents of your database, every single user will have had their password revealed which will be used to hack into their accounts on any number of sites. In PHP, you should use password_hash() and password_verify() when managing passwords. If those are not available, you will need another form of cryptographic hashing, such as PHP's crypt() function.
  2. You need a script tag for the scrollspy plugin in addition to the jQuery one.
  3. You would not use an animated GIF, you would have to use a static image with all of the animation frames on it, then manually slice pieces of the image based on the amount of time that has passed. Your game needs a loop that runs every fixed amount of time. You can do this using requestAnimationFrame(). MDN has a guide on how to use requestAnimationFrame here: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations. In the loop, the game needs to read inputs, calculate values and then display something on the canvas. For reading inputs, you are going to need one variable for each button in your game. In your current project, UP, DOWN, LEFT and RIGHT. You can add more buttons if you need them. Each of these variables starts off false, gets set to true when the onkeydown event fires and gets set back to false when the onkeyup event fires. During the game loop, if the program sees DOWN set to true, it will add 10 to the yPos variable. To keep things more organized, you should start using objects. You need a Controller object and a Character object. The controller contains information about which buttons are pressed and the character contains position information. The character could also contain information about the sprite, such as a reference to the image and the current animation frame. The following is a potential structure for these objects: var Controller = { UP : false, DOWN : false, LEFT : false, RIGHT : false }; var Character = { x : 0, y : 0, sprite : { image : document.getElementById("character"), width : 40, height : 40, currentFrame : 0 } }; We could go further into object-oriented programming and add methods to update the button values and to calculate the coordinates of the sprite.
  4. What you're asking for does not exist, to my knowledge. You can find a good back-end IDE, you can probably find a decent front-end code editor, but there isn't an IDE that mixes them together because the architectures and environments for front-end and back-end development are very different from each other. The most complete IDEs I can think of for PHP are Netbeans and Eclipse, but both of them were originally built for Java programming, so the PHP support is not perfect. I think Eclipse can integrate with version control, I haven't checked for that in Netbeans. For front end development specifically, a popular editor is Brackets. It is built with code completion for front end languges like HTML, CSS and Javascript and has a browser preview button. I'm not sure of all the features because I don't use it. Nobody has built compilers or debuggers for front end languages that I'm aware of and the reason is pretty clear to me: Browsers are updating all the time, the very best environment to compile and debug front-end languages is the browser itself. It would be a nightmare to maintain an independent front-end compiler/debugger because it would have to be updated every time any browser has an update. Browsers have built in tools for debugging Javascript, monitoring server requests and analyzing HTML elements and the CSS rules that are applied to them.
  5. At this point I would start debugging using the alert() function. To start off, put in alert() right at the beginning of the click5() function to see if it is even being called. If that works, try alerting different variables in the function to see if they contain what they are supposed to. Since you don't have a Javascript console available on the iPhone, you can set up a small script to show the errors in alert boxes like this: window.onerror = function(message, file, line) { alert("Error in " + file + " on line " + line + ": " + message); } Be sure to remove it after all issues are solved.
  6. Ingolme

    = vs like

    If the string is not exactly 30 characters long, use VARCHAR instead of CHAR. CHAR adds additional null bytes as padding if the string is not long enough for the field.
  7. Ingolme

    = vs like

    The semi-colon will not break the query, it will simply be ignored. The = operator will only return a row if the entire field exactly matches what is being searched. If you want to find rows that contain the search string along with more content then you must use the LIKE operator. If you think the fields do match exactly, make sure that they don't actually have spaces, tabs or other invisible characters that might be interfering with the search.
  8. According to the error message, output started on line 1. It could be that your file is encoded as UTF-8 with a Byte-Order Mark (BOM). The BOM are three bytes that appear at the beginning of the file and may be invisible in your editor. To make sure this does not happen, open the file in a code editor and make sure that the encoding of the file is UTF-8 without a BOM.
  9. Every meaningful sequence of symbols comes from a source that should have documentation that describes how to interpret the symbols in the sequence. If you have a meaningless sequence of symbols, no meaningful information can come from it.
  10. Breaking a long sequence of bytes into pieces is merely for the convenience of reading it easier, the computer does not know or care where you think they should be separated, it just reads the entire sequence. The only way to find out how the digits should be separated is if you can tell us where you found the sequence so that we may find documentation that describes how it should be interpreted.
  11. I don't see any code here that would make the link go behind a div.
  12. Any custom scrollbar will also work in an iframe. Just apply the custom scrollbar code to the body element of the document that is in the iframe.
  13. The logic is pretty simple and can be done easily with prepared statements. There are many ways to do it, here is one of them: <?php $username = $_POST['username']; $password = $_POST['password']; // Database connection logic. See documentation: // http://php.net/manual/en/pdo.construct.php // $pdo = new PDO(...) $query = $pdo->prepare('SELECT `hashed_password` FROM `users` WHERE `username` = :username LIMIT 1'); $query->bindParam(':username', $username); $query->execute(); $query->bindColumn('hashed_password', $hashed_password); if($query->fetch(PDO::FETCH_BOUND)) { if(password_verify($password, $hashed_password)) { echo 'User is logged in'; } else { echo 'Wrong username or password'; } } else { echo 'Wrong username or password'; }
  14. You don't need a keydown event to change styles. With Javascript you can change styles at any time. Seeing as it's using the jQuery version of Javascript's trim() method, the trim statement you provided earlier should be working. Looking closer, the issue seems to be that you mistyped your variable name. You've added an extra "L" to $email. // ↓ $emaill.css({"border-color":"red"}); // ↑ Whenever you come across an issue, try to look for typing mistakes first. Carefully analyze your code. If you don't find anything, then start printing out all the values as the program is running to see whether they are correct.
  15. Ingolme

    Blockchain

    Managing a blockchain is very expensive. One of the fundamental properties of blockchain technology, proof of work, requires wasting a whole lot of energy just to calculate meaningless numbers. Finding hashes for each block is taking a lot of energy and the more blocks you add to the chain the more expensive it becomes to calculate new hashes, this energy is not free. Last year, the amount of energy used for bitcoin mining surpassed the entire energy usage of some small countries and bitcoin is not exactly mainstream. If blockchain technology becomes mainstream it is going to end up becoming too expensive to maintain. Blockchain transactions will end up costing more money than doing the same transactions through a centralized agency.
  16. Could you explain what kind of result you're expecting from this statement? I can't tell you how to fix it if I don't know what it is supposed to do. (regex1.test($prenom.val())==true).onkeydown The trim() method belongs to the String object, it works like this: var x = " String "; x = x.trim(); It doesn't matter where you get the string, but you have to call the trim() method on the string itself.
  17. To add a page break, use the page-break-after rule. To select every fourth row, use the :nth-child selector with the formula 4n
  18. There has to be a <link> tag in your document and that tag needs to have the correct URL for your stylesheet.
  19. Ingolme

    Blockchain

    It's not an important new technology. It's the basis for cryptocurrencies. I'd actually label it a fad and I hope it dies quickly, the amount of energy used by people trying to exploit blockchains is alarming. If you want a clear computer science perspective on block chains, watch this video:
  20. Your problem is here: var $prenom = $('#prenom'); var regex1 = /[^\d\W]{2,20}[\-\s\']{0,1}/i; if($prenom != regex1){ You can't just compare a jQuery object to a regular expression. You have to get the field's value out of the object and then apply the regular expression using methods like match(), test() or exec(). You should be doing validation in PHP as well. Javascript validation is optional, PHP validation is necessary. If you only do validation in Javascript, people can bypass it easily. Should the last name be required? That's up to you, you design the requirements for your own software. If you don't mind not having a last name, you can choose to only validate it when it is not empty.
  21. The quotes look right to me, but perhaps you don't like how the font renders the curly quotes. You can flip things by using a negative value in the scale property: /* To flip horizontally */ transform: scaleX(-10.5) scaleY(10.5); /* To flip vertically */ transform: scaleX(10.5) scaleY(-10.5); Each of your quotes is in its own pseudo-element, so you can put the scale code in the selector the the specific quote that you want to flip.
  22. You should analyze the code on that website to see how they did it. There isn't one single solution to this, there are many ways to do it. What I would probably do is use the ::before and ::after pseudo-elements to create the quotes, then give them an absolute position relative to the box that contains them. You could also choose to not use absolute positioning, keep them in place but scale them up right where they are with the transform property and put them in the background with a negative z-index.
  23. The :invalid selector is the one that you have to use for form fields that had an error. The default border is probably using the outline property or box-shadow property, try setting those to "none". Don't just copy the example code I gave, you have to use the :invalid pseudo-class along with a selector to the specific element you want to change. You also should experiment with different CSS properties to see which one overrides the default style.
  24. You can use the CSS :invalid pseudo-class as in the following example: input[type=text]:invalid { border: 1px solid blue; }
  25. Ingolme

    PHP

    Is there a question here?
×
×
  • Create New...