Jump to content


Popular Content

Showing most liked content since 09/22/2017 in Posts

  1. 2 points
    There's nothing formal to tell you things like that. People do it themselves, and it tends to illustrate the Dunning-Kruger effect. People who just recently started tend to rate themselves highly, and only when you get more into something do you realize how much you don't know. I wouldn't put any weight on things like that. If you want to evaluate someone's capabilities look for a portfolio or things they've actually finished.
  2. 1 point
    According to the documentation for the ajax method, beforeSend is called before the request is even sent. The 2 parameters that the function gets passed are the jQuery XHR object, and the settings object. So in your code, podType is set to the jQuery XHR object. The beforeSend function is really for modifying the request before it goes out (or canceling it), so I would think your code for changing the page should all go in the success function. Inside that success function podType will still have the value it had when you send the request, unless you change the value inside the function. You also need to quote all of those values in your case statements, otherwise you're trying to compare the value with different variables.
  3. 1 point
    The reason why your code isn't working is because $con is not defined in those functions (and $pass and $conf_pass are not defined in newUser either). You can use global variables inside the function, but it's better to avoid globals and pass in any variables you want the functions to use. So you should pass $con to the functions. You should add this to the top of your code: ini_set('display_errors', 1); error_reporting(E_ALL); You should switch your database code to use prepared statements instead of trying to manually escape everything. Prepared statements offer better security. You can use prepared statements with mysqli, but it's better to use PDO. The PDO code is shorter and easier to understand, and PDO works with databases other than only MySQL. e.g.: $stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?"); if ($stmt->execute(array($username))) { if ($row = $stmt->fetch()) { // it found a user } } http://php.net/manual/en/book.pdo.php For the code I posted above, I was saying that each function should only do one thing. Your newUser function should only validate and add the user if necessary, it should not also output anything or redirect. Your main code should do that based on what the function returned. If you want to return multiple values you can use an array like I did above to return a "success" value for whether the user was added, and a message to show them. So your main code would call that function and then decide what to do. Those header redirects wouldn't work though, because you sent output to the browser first. $result = newUser(...); if ($result['success']) { // maybe redirect to a thank-you page or something } else { // show the error in $result['message'] }
  4. 1 point
    The forum completely wiped out my reply when I tried to edit my post, because the forum software is awesome. I'll try that again.
  5. 1 point
    function newUser ($username, $password){ $return = ['success' => false, 'message' => '']; if (!isExist($username)) { if (passChk($pass, $conf_pass)){ // insert into the database here $return['message'] = 'Username Created successfully'; $return['success'] = true; } else { $return['message'] = "Password and confirmed password do not match"; } } else { $return['message'] = 'Username already exists'; } return $return; }
  6. 1 point
    .w3-cell-row { margin: auto; margin-top: 0; width: 79%; border-collapse: collapse; /* margin-bottom: -10px;*/ } .w3-cell { background-color: #fff; border: 5px solid #00c; /* margin-bottom: -10px;*/ border-bottom: none; } .w3-cell-row:before, .w3-cell-row:after { content: none; } .w3-cell-row:last-child {border-bottom: 5px solid #00c;}
  7. 1 point
    Yes, you would use an array of objects as shown. As far as file types, it's not very common to have a static file only containing JSON that you read from, they just do that because it's an easy example. It's more likely that you'll be sending ajax requests to PHP or another language on the backend which would dynamically generate the JSON (from a database, as in your example). You can use PHP or whatever language to set the content-type for JSON though, rather than saying it's HTML.
  8. 1 point
    Thank you Gabrielphp, that worked perfectly. I tested for the negative. if(!is_numeric($phonenum1)){ $phonenum1Err="Only numbers0-9"}
  9. 1 point
    You can use a php function called is_numeric(). if(is_numeric($var)) { //do stuff } else { //do other stuff } Hope this is what you want.
  10. 1 point
    The slideIndex will always be 1; When function called var slideIndex = 0; then further on slideIndex++;
  11. 1 point
    If $(this).attr('id') returns the correct ID, then this (and the jQuery-wrapped $(this)) refer to the same element. There's no reason to get the ID from the element, then get the element again. You already have it, you're getting the ID from it.
  12. 1 point
    You could also use $(this) to refer to each element, instead of getting the ID of $(this) and then looking up the same element.
  13. 1 point
    You're telling to find an element with the ID "podType". If you want to use the value of the variable, you need to specify that. $('#' + podType)
  14. 1 point
    1) Anything using below class will use pointing finger cursor .style1 { font-family: Verdana; font-size: 10pt; text-align:justify; cursor:pointer; } 2) You said Which means you would have to apply this styling class name to container element, which would either be a Paragraph, or Anchor, or Strong element that surround the text ' Click to Read More'. BUT! you have applied class name to This is outside the scope of what you are trying to target, its scope starts from opening span <span class="style1"> and finishes at </span>, all the text "W3Schools is a popular web site for learning web technologies online.[2] Content includes tutorials and references relating to..." will have the pointer cursor, but anything outside this will work as default styling, which is what is happening to anchor text you are attempting to target, because its outside '<span class="style1">....</span>' scope.
  15. 1 point
    You wouldn't really say the "and", it's more like an if statement if window.console exists. The reason that works is because logical operators get short-circuited. Since everything in an AND expression needs to be true for the entire thing to be true, if it finds something that is false then it stops evaluating the rest of the expressions and the result is false. Similarly with OR, if it finds any expression that is true then it stops evaluating the rest and the result is true. So in that expression above, if window.console is logically false then it does not try to execute console.log. Note that they just use console.log instead of window.console.log because window is the default global scope. They don't need window on the left side either but I guess put it there to make it more explicit. There's something else a little weird about logical expressions in Javascript. Take this example: var x = 1; var y = 2; var z = 3; var result = (x && y && z && (x+y+z)); What do you think result is going to be set to? That expression is a bunch of logical AND operators, so it's going to be set to boolean true, right? Wrong, it's going to be set to 6, the value of the last expression that was evaluated. You can use that with OR to have a variable set to the first thing which has a non-falsy value, e.g.: var ajax_object = which || of || these || exists; That can be shorter than writing a bunch of if/else statements, but it only works if things like false, zero, or the empty string are not possible values for those variables.
  16. 1 point
    You have to build it or hire somebody to build it for you. A PHP script will work if your server supports PHP, but there are tons of other server-side languages with which to build your website.
  17. 1 point
    You're going to need software on your server to do anything. HTML does not do anything on its own.
  18. 1 point
    The issue isn't the location of the files relative to each other, it's how you're accessing them. If the URL bar in your browser starts with http:// or https:// then your browser uses one security model, if it starts with file:// or anything like that it uses another. I don't know if ajax even really works for non-HTTP requests, because part of that process is communication with a web server. It might work, but I wouldn't count on it. If you want to download a server for testing, the easiest are packages like XAMPP. That includes the Apache web server, and also PHP and MySQL and some other tools pre-configured. After you install that and start Apache, you'll be able to access it at http://localhost/ There will be a specific folder on your computer that Apache uses as the document root, that's where the root level of your website is. So if you create a file and save it in that folder as index.html, you can access it at http://localhost/index.html, or if you put a folder called images in the document root then that will be at http://localhost/images/ etc
  19. 1 point
    What you're asking for is called pagination and it's usually done by adding a page or offset number to the query string and putting that value into the LIMIT clause of the SQL query. You can use AJAX to do it, but I'd recommend first using just PHP and then adding the Javascript layer on top of that for convenience.
  20. 1 point
    That is mainly done by using JavaScript https://www.w3schools.com/howto/howto_js_slideshow.asp but you may need to ask permission before using another sites images first.
  21. 1 point
    Only 'get' request uses querystring, the passing of 'post' data is hidden and not shown in the address bar.
  22. 1 point
    You should sanitize for any request $_GET, $_POST (data from forms) or $_REQUEST, any of these can be used to insert code. Check out exploits section of https://www.w3schools.com/PhP/php_form_validation.asp
  23. 1 point
    What does that mean? How are you opening it? Are you just double-clicking on a file on your computer or something? If so, the PHP code won't run at all. Or, if it's actually on a web server, then there's always a request. The server responds to requests, that's its job.
  24. 1 point
    The page is reloaded because you are clicking a link which will call itself because no other url is requested, but! the current page url will have the querystring attached to it as well. When the page reloads if this page has php code that will check and read the name and value transferred with the querystring using $_GET[], this value can be passed onto a php variable. Yes! you should sanitize, as it is a querystring viewable and editable from address bar. You could prevent page reloading by using JavaScript, then by using AJAX, process the data from external php page and return result.
  25. 1 point
    There's no uncertainty. When you click on a link like that and the browser is building the URL to request, if the link only contains a querystring then the browser will use the current page, add the querystring to it (or replace an existing one), and use that as the URL for the request. There's honestly not a lot to say on this topic, it's pretty basic. It's just a link to the current page with a new querystring. It wouldn't matter whether or not someone managed to actually create a file with that name on the server because the browser wouldn't request that file anyway, it's going to request the current page again.
  26. 1 point
    Thank you so much - I understand it now after finally putting all the pieces together. I also figured out (from the link you provided) that the pattern string has to be enclosed by a delimiter, thus the two "/". Then the ending "i" mean case-insensitive alpha match. Just for anyone else that reads this post... It looks to me like someone could specialize just in regex coding! Thanks again.
  27. 1 point
    It's fine to use that style to refer to the current page. PHP's magic constants wouldn't help though, there's not one that refers to the current URL. You can build the URL from the $_SERVER array, but it's not necessary if you're just linking to the current page.
  28. 1 point
    The problem with using echo statements is that code editors will not highlight the HTML syntax. If you're building a template file, you usually have large amounts of HTML with small amounts of PHP. I personally do not like the BASIC style syntax even for templates. When you use curly braces, most code editors will show you where the current brace ends and allow you to show or hide the block of code. With proper formatting and indentation the code becomes easier to read. <?php if(isset($_GET['edit'])) { ?> <button type="submit" name="update">update</button> <?php } else { ?> <button type="submit" name="save">save</button> <?php } ?>
  29. 1 point
    Yes! because the chances of it plucking any url or actually landing on a page called ?edit=whatever is pretty substantial.
  30. 1 point
    Just to clarify, if the link is a query string only and does not contain the rest of the URL, it uses the current URL of the page with the new query string.
  31. 1 point
    It should be, it's kind of lazy to leave it out. It should be listed along with the visibility. They don't need to give it a value in that list, they can just specify the visibility.
  32. 1 point
    It doesn't have a plain reading. You use that question mark because it is a query string. From https://www.freeformatter.com/url-parser-query-string-splitter.html What's the 'query string' in a URL? The query contains extra information that is usually in the key-pair format. Each pair is usually separated by an ampersand & character. It follows the ? character. Examples: http://www.foo.bar/image.jpg?height=150&width=100 https://www.secured.com:443/resource.html?id=6e8bc430-9c3a-11d9-9669-0800200c9a66#some-heade
  33. 1 point
    it will reload the page with querystring '?edit=whatever' then php will read this using $_GET['edit']
  34. 1 point
    If you are doing such coding use the : form and not { }, it will be much easier to understand the code when you mix them. <?php if(condition): ?> Html here <?php else: ?> Html here <?php endif; ?>
  35. 1 point
    Echo or escaping and entering by opening/closing php, are both valid, but i think separating php from html is much cleaner as you have it.
  36. 1 point
    Unfortunately this site has no connection with the administrators of w3shools.com, posting this error here, won't receive any attention to fix this error, but I suggest you go to 'About' page on W3schools.com then at bottom of page, click report error link.
  37. 1 point
    That class doesn't seem all that useful, it doesn't provide any protection and really only gives a way to send an array of conditions for a select query. I would suggest using PDO instead, or looking into prepared statements with mysqli and using those. The first error message sounds like the database connection failed.
  38. 1 point
    You are not getting the value, but text content of option list? Every time the loop completes a cycle it overrides the previous html, you need to add to previous, then at the end add to label html var join = ""; $.each(tous, function(index, value) { join += value + "<br>"; //return (value !== ""); ///// why? }); $("#label").html(join); I think this is what you are asking for? As I said, you are using innerHTML not value, so you need to adjust this to your requirements. instead of var l = selectliste.options[selectliste.selectedIndex].innerHTML; you could use var l = $(this).val(); // for value or var l = $(this).text(); // for actual text description
  39. 1 point
    That's because you set it to false right before you alert it. Go back and look at the code I posted, notice how the variable definitions are outside the load handler. They first get defined with those default values, maybe at some point later down the page PHP will redefine them, and then once the page finishes loading the rest of the Javascript runs, using either the default values or the values that were set by PHP.
  40. 1 point
    In its current layout form, you can only make the text fade In, and instantly close , it will take a lot of redesigning of layout to make this work how you want it. https://www.w3schools.com/code/tryit.asp?filename=FJJ9PV6DH1YJ
  41. 1 point
    SublimeText works best for me