Jump to content

Ingolme

Moderator
  • Content count

    13,464
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by Ingolme

  1. Ingolme

    How to Replace an Insert from Another Insert

    I'm not sure what "from inside the div" means. Does that mean that the script that's doing the replacement is inside the div? As far as replacing the content of any element, you can either set its innerHTML property or use DOM methods such as removeChild() and appendChild().
  2. Ingolme

    cookie coding

    Remove the echo statement. The header has to be sent before any output, which includes all echo statements. In this case, the echo statement can be removed because the location header does the redirect. If you are working with sessions, you have to call session_write_close() before sending a redirect header.
  3. Ingolme

    cookie coding

    The PHP manual says prior to any output. The reason being that it has to be in the HTTP headers section. If you have studied the HTTP protocol it should be clear. An HTTP response consists of two sections: The headers and the body. The headers provide information about the data being sent, such as the amount of bytes, the file type and also cookies. After the headers goes two line breaks and then the body. The body is the actual file contents. In order to be efficient, PHP goes sending data back to the client while it is still processing, which means that as soon as any content is printed, whether it be HTML or anything else, it immediately sends the two line breaks and enters the body section of the HTTP response. Once those two line breaks have been sent it is impossible to go back an send any more headers to the client because whatever you send is going to be considered part of the body. While PHP is usually used to send HTML, it can also send any other kind of content, like image data, a video or an excel file. PHP can output content of any kind, so saying that headers have to be sent before the <html> tag just covers the specific case that the first part of your output is the string "<html>". The general case is that the headers have to be sent prior to any output.
  4. Ingolme

    cookie coding

    The setcookie() call has to be done before any HTML is printed, even before the <!DOCTYPE> declaration, because cookies are sent with the headers which have to go before the content.
  5. You probably should go through the Javascript tutorial and become familiar with it. If there's still something you need help with after that then you can ask about it here.
  6. Ingolme

    CSS Color styles changing upon being hosted

    Without seeing any code I can't give an answer. If I had to guess I would say that the stylesheet version on your local server is probably different than on the live website. Another possibility is that there's some kind of dark overlay on the page. Open the developer tools in your browser and inspect the elements on the page to see more information.
  7. Ingolme

    cookie coding

    It makes no sense to set the same cookie twice in the same script. The first line will be ignored.
  8. Ingolme

    cookie coding

    To delete a cookie, set its expiry date to a past date. If you set the same cookie twice the first one will be ignored. You're not actually deleting the cookie, you're giving it a different value.
  9. The browser will do validation if you use the <form> element's submit event. Do not use the click event.
  10. Ingolme

    Question on rel="nofollow"

    Google will index the page when it finds it.
  11. Your requirements were not clear. You asked to "make the output of the cURL call visible in the file that produces it" but it's not clear what "visible" means in this context. My interpretation was that you wanted the curl data visible to the script itself instead of being passed on straight to the client. The idea behind that would be that the script can manipulate the data before sending it to the client. It seems that is not what you are looking for. Seeing that you've changed the method to GET, I suspect that you wanted to see the output in your browser by sending a GET request to the script. If your code is designed to only show content when POST data is available then you have to send POST data to see the content.
  12. Ingolme

    Improperly Displayed Submit Button

    I don't have an iPhone with me and can't reproduce it on my emulators, so I'll have to make a guess. It might have something to do with setting the width to "-webkit-auto". At best that would do nothing and at worst it's going to behave unpredictably. Remove the -webkit-auto rule because there will never be a circumstance where it is needed. My second guess would be that it has something to do with the OS's button styles. You should set appearance/-webkit-appearance property so that it behaves like a regular element, like this: #pc_signup form input[type="submit"] { -webkit-appearance: none; apperance: none; } On the topic of -webkit- prefixed rules, they must always go above the real rule, so that browsers that support both will use the most updated version of the rule. I have no idea what you mean by "bubbling" in the context of CSS.
  13. You don't echo it, you store it into a variable and do some processing on it.
  14. Ingolme

    Question on rel="nofollow"

    All it means is that Google will not follow the link, but unless the page itself has a noindex meta tag or is blocked by robots.txt Google can still index it. The nofollow link is usually used for links to external websites.
  15. Ingolme

    Responsive Design Dysfunction

    You're missing a meta viewport tag in overview.html.
  16. You can do testing by typing the URL of the PHP script in your browser instead of using AJAX. This way you can easily see what's being printed to the screen. curl_exec() returns a boolean value, you should check to see if it's false, and if so then you can use curl_error() to see why it failed.
  17. Ingolme

    <i Tag Question used in Smarty

    Javascript searches for all elements on the page that have a certain value in their class attribute. Then it puts another element next to it. To open a file dialog, you just need a file type input, like this: <input type="file"> The Javascript library is putting one of those in the place of the original <i> element.
  18. Ingolme

    <i Tag Question used in Smarty

    It has nothing to do with the <i> tag itself. The Javascript library just looks for any elements with certain class names and replaces them with videos, links and other things. Any other element could have been used, but <i> was probably chosen because it's very short and has no semantic meaning. Everything you know about HTML, Javascript can break it. If you want to understand all of this better you will have to learn Javascript in depth.
  19. Ingolme

    Would all news journals use XML?

    I would place my bets on most large websites using tabular databases because they are very efficient. I do believe that a lot of phone apps render HTML and CSS as well since it's a really convenient way to specify the layout of text and media. XML is not a good language, neither for transferring data nor storing it. It has too much redundant information and is slow to parse. For transferring data in a human-readable format, JSON is currently the best option.
  20. Ingolme

    Reading a $_SERVER Variable with an AJAX Call

    I'm not aware of a REMOTE_REFERER key in the $_SERVER array. Perhaps you meant to use HTTP_REFERER. But even then, an undefined key would not throw a 500 error. I can't tell you why it's doing that from just the code you provided, you should check the server's error log. If all you need is the referrer, though, Javascript already has that available without needing to send a request to the server. Use the document.referrer property.
  21. Ingolme

    Calling an Image File with AJAX

    AJAX is not the correct tool for this problem. Why do you insist on using it? I already gave a solution that does not require reloading the page, use Javascript. It does not need AJAX.
  22. Ingolme

    Calling an Image File with AJAX

    You can add query string parameters to the PHP file to decide which graph to show and use those query string parameters in the src attribute. PHP would use those parameters to decide which graph to show. One PHP file can show as many graphs as you want it to. It would be done like this: <img src="practice.php?graph=1"> <img src="practice.php?graph=2"> On the PHP end, you would show this: <?php header('Content-Type: image/png'); $graph_type = isset($_GET['graph']) ? $_GET['graph'] : 1; if($graph_type == 1) { $url ='https://.../matomo/index.php ?module=API &method=ImageGraph.get &idSite=1 &apiModule=Referrers &apiAction=getReferrerType &token_auth= ... &period=day &date=2018-04-10,2018-05-09'; } else if($graph_type == 2) { $url = 'Something else'; } else if($graph_type == 3) { $url = 'A third URL'; } else { $url = 'A fallback URL'; } $curl_request = curl_init(); curl_setopt($curl_request, CURLOPT_URL, $url); curl_exec($curl_request); curl_close($curl_request); You can use more parameters in the query string if you want to more clearly identify the graph, I just use a graph number for simplicity. If you want the user to be able to change the image using dropdowns or sliders you can have Javascript generate the image URL, like this: <img id="image" src="practice.php?graph=1"> <select id="graph-type-dropdown"> <option value="1">Graph type 1</option> <option value="2">Graph type 2</option> </select> <script> var dropdown = document.getElementById("graph-type-dropdown"); dropdown.addEventListener("change", changeImage, false); function changeImage(e) { var type = e.currentTarget.value; var img = document.getElementById("image"); img.src = "practice.php?graph=" + type; } </script> There is no need for AJAX here. It would make the process much slower.
  23. Ingolme

    Calling an Image File with AJAX

    You can't just assign a giant set of bytes to the src attribute of an image. What you actually should do is set the URL practice.php as the src of the image. On the PHP side, you should send a header indicating the type of image that is being displayed. I'm going to assume PNG, but you need to guarantee that you know the correct image type to make this work. PHP: <?php header('Content-Type: image/png'); $url ='https://.../matomo/index.php ?module=API &method=ImageGraph.get &idSite=1 &apiModule=Referrers &apiAction=getReferrerType &token_auth= ... &period=day &date=2018-04-10,2018-05-09'; $curl_request = curl_init(); curl_setopt($curl_request, CURLOPT_URL, $url); curl_exec($curl_request); curl_close($curl_request); HTML: <img src="practice.php" alt="Line Chart of Referral Types"> Or you can even skip out on the PHP part and have the browser directly resolve the image for you: <img src="https://.../matomo/index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=Referrers&apiAction=getReferrerType&token_auth= ...&period=day&date=2018-04-10,2018-05-09" alt"Line Chart of Referral Types">
  24. Ingolme

    How do I include AngularJS in JS file?

    If you're working in a browser, the best approach is to add another <script> tag to your HTML document, everything declared globally in one Javascript file is accessible in all the other files that follow it. You seem to be working in Node.js. My experience with server-side Javascript is limited but there's a discussion about it here: https://stackoverflow.com/questions/4481058/load-and-execute-external-js-file-in-node-js-with-access-to-local-variables
  25. Ingolme

    sessionStorage vs Global Variables

    The difference between a regular Javascript variable and sessionStorage is that the global variable disappears as soon as the user leaves the page. sessionStorage remains as long as the user hasn't closed their browser, even if they leave your site and return to it in a few minutes.
×