Leaderboard


Popular Content

Showing most liked content since 05/29/2017 in all areas

  1. 1 like
    You have not bound a parameter for the WHERE statment, for every ? There must be a type and variable/value defined in the same order.
  2. 1 like
    My suggestion is to add HTML DOM element object outerHTML attribute for the JavaScript reference. It seems that most, if not all, the browsers support this attribute. In addition, it is important and basic attribute that new JavaScript developers should know about.
  3. 1 like
    Well it would help if you place the style properties within the style attribute.
  4. 1 like
    You can't have multiple functions of the same name, Like in the film 'Highlander' there can be only one.
  5. 1 like
    No! the PHP file in its present state should not be included in to the form page, it is AJAX specific because of the if condition, which should be access by JavaScript AJAX code that uses url to that php file to retrieve required data using server script language PHP. I don't know what jquery.js is? is it the users own custom code or jquery framework code? either way it is perfectly all right if not the norm to place js code at bottom of page, as it will help in loading of page quicker as html and css needs to loaded primarily first, and JavaScript secondary as most of the time JavaScript is triggered by events by the user after the page is fully loaded. The main problem with include ("jquery.js"); is that is needs to be within <script>...</script> tags if custom js code, OR if jQuery framework file, it should link to it, using for example <script type="text/javascript" src="jquery.js"></script>
  6. 1 like
    OK. The advantage of using AJAX is to prevent having to reload the page each time the form is submitted, and the advantage of using PHP is to insure that the submitted data is sanitized and validated. Are implying with this that it is not possible to use Javascript for the purpose of sanitization and validation? If I have understood correctly, AJAX serves only as an intermediary between the form page and the PHP page. In other words, the PHP page should be written, as if the AJAX did not exist, and the AJAX should always refer to the PHP page via the following piece of code $.ajax({ url: 'ajax_comment.php', What is more, the PHP code should only be included in the page, if the following condition is satisfied. !isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) Thus, it was wrong for Loois to have included the following code at the bottom of his form page include ("jquery.js"); Under the assumption that all of the above is correct, why is the following code not entered at the top of the form page? include ("jquery.js"); My very best, Roddy
  7. 1 like
    You should always provide a pure php script, to sanitize and validate, BECAUSE JavaScript CAN be disabled, You can use AJAX to update content, make database requests/update/insert etc without the need to reload the page constantly, which is required for pure php code to do the same thing. Usually you would not include the php script in the form page, only the AJAX JavaScript code would access it externally, to process the form data and return results to a specific location, it makes more sense this way checking with $_SERVER['HTTP_X_REQUESTED_WITH'] that it is a AJAX request. Without this it could be included in the form page, it would retrieve default information or content on loading of page, a AJAX request could be made using form using the same php script externally, the new AJAX returned results can be use to update/overwrite the default content without reloading the page.
  8. 1 like
    So, why use AJAX at all? Since AJAX depends on Javascript being turned on or off, and since this decision is made by the user-client, why not use PHP whose functioning is determined solely by the host-server?
  9. 1 like
    It would transfer the problem to AJAX code, it depends on WHY the ajax php code was included in the form page if (isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )):include('../config.php'); will not run php code beyond this 'if' condition, if page reloads because JavaScript was disabled which prevents the form being submitted, it is no longer a JavaScript AJAX request. if (!isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )):include('../config.php'); Will allow the php code within the form to be processed if JavaScript disabled, BUT! will prevent AJAX request being processed if JavaScript is enabled and it goes directly to ajax_comment.php
  10. 1 like
    OK. Thank you for the correction, Dsonesuk. I have never used AJAX and looked only for what was different from what I use -- namely, PHP. Upon a more careful reading I now see the statement include ("ajax_comment.php"); If I have further understood, you find the following statement to be ill-conceived, if (isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )):include('../config.php'); and give as a reason that the PHP will only be used, if the Javascript succeeds. So, if Loois were to write, if (!isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )):include('../config.php'); would this fix his problem.
  11. 1 like
    Its AJAX, it does not require those, without action the form will submit to itself, and as that php file is included in the form page itself, which maybe used to takes into account if JavaScript is disabled it will then as said be submitted, page reloaded and processed by the same page, BUT! currently it will only show if AJAX request is sent ($_SERVER['HTTP_X_REQUESTED_WITH']), which seems pointless including in the form page as a non JavaScript alternative. While with JavaScript enabled, the form is prevented from being submitted, it gathers the input data and sends it to the php file specified in the JavaScript AJAX url code to be processed and return the result without reloading of page
  12. 1 like
    There is no action attribute in the following line of code <form id="form" method="post"> You must enter an URL for ajax_comment.php as the value of your action attribute in the above <form> element. <form id="form" method="post" action='pathto/ajax_comment.php'> Replace the word "pathto" with whatever is necessary to connect the document that contains your form with the document that processes your $_POST variable -- namely, ajax_comment.php.
  13. 1 like
    Unless specifically programmed otherwise, the server will serve the same content to everybody. If you have a PHP file that can manipulate files or the database then it's open for everybody to use and is an easy attack vector on your website, if you want to prevent other people from using it you will have to add some form of authentication. In summary, nothing is stopping me from sending a POST request to your web host.
  14. 1 like
    <form method="post" name="form_name" id="form_name" action="https://www.w3schools.com/comment.php"> <fieldset> <legend>Title</legend> <p>A brief explanation about what you would like to see entered.</p> <textarea name="comment" form="form_name" maxlength='400' rows="8" placeholder='Character Limit: 400'></textarea> </fieldset> <input type="submit" value="Submit comment"> </form> In addition you must decide what you want to do with the comments and how to process them one they are received via the post ($_POST) method at comment.php. Roddy
  15. 1 like
    The superglobal is like any other variable in the PHP process, it only exists during the time the script is running. If you want to store its value permanently somewhere you can use a database or write it to a file. If you want to store something for one user during a browsing session you can use PHP sessions.
  16. 1 like
    The PHP GD library can't open TIFF files, but it looks like ImageMagick can. If you don't have access to ImageMagick then you'll have to go through the tedious work of building a TIFF reader that parses binary TIFF files and extracts information from them.
  17. 1 like
    The RSS file can go anywhere you want, you just have to tell people where to find it. As I mentioned earlier, you can tell browsers where to find a feed by putting a <link> tag in your HTML page. There's no real best practice as to where to place your RSS feed files. I think RSS feeds have to use absolute URLs in the <link> tags including protocol and domain name to point to the location of the files. If you want a URL like "/feed" for your RSS feed you would have to use URL rewriting on the server, a regular URL would look like this instead: "/feed.xml" or "/feed.rss".
  18. 1 like
    For simple menu like yours no! The ul and li are not required, for menu that include sub or child menus, then a unordered listing (bullet list) would be preferable because of it nesting structure of UL and LI elements.
  19. 1 like
    OR var mil = function() { var min = $('#min').val(); var sec = $('#sec').val(); var millisec = ((min * 60) + sec) * 1000; return millisec; }; $('#item_encllength').mousedown(function() { $(this).val(mil()); });
  20. 1 like
    If you want to prevent the menu from hiding on mobile devices, remove the "w3-hide-small" class from the menu.
  21. 1 like
    It looks to me like hiding the menu was not a mistake but a deliberate part of the design. The menu wouldn't fit as it is on a mobile screen. I can't check the code right now, I might get to it later. You should use your browser's inspector to see which CSS rule is hiding the menu.
  22. 1 like
    The save() and restore() methods are useful for that. save() remembers the current state, restore brings back the state of the last save() call. ctx.save(); // Remember the current state ctx.translate(100,100); ctx.fillRect(0,0,100,100); ctx.restore(); // Return to the previous state ctx.fillRect(100,100,50,50);
  23. 1 like
    Like I mentioned in the other thread where the original question got removed, that is markup from versioning control software that is showing the differences between two versions of a file. You downloaded the diff instead of the source code.
  24. 1 like
    <?php $book = array( "Language" => array("English", "Franch", "Arabic"), "Programming" => array("PHP", "JAVA", "C++"), "Science" => array("Physics", "Geography", "Math"), ); $classRef = ""; $keysvalues = array_keys($book); echo '<ul>'; for ($i = 0; $i < sizeof($book); $i++) { $classRef = str_replace(" ", "_", strtolower($keysvalues [$i])); echo '<li class="' . $classRef . '">' . $keysvalues [$i]; echo '<ul>'; foreach ($book[$keysvalues [$i]] as $value) { echo '<li>' . $value . "</li>"; } echo '</ul>'; echo "</li>"; } echo '</ul>'; ?>
  25. 1 like
    Please PM me or the other moderators for suggestions about this topic. The topic will be locked to avoid clutter.This topic will provide some links to common tutorials, references, articles and downloads related to web servers.Check the posts below for further information.