I read that cookie values can be set after HTML content has been sent from a PHP script to the web server. However, when working with this, I have not been able to set the cookies as I had hoped. Can someone straighten out my discrepancy? Answer PHP can only set cookies while sending the headers of the page (…
Tag: html
PHP getting document path relative to site root
I’m trying to link a separate php document in the header files that contains all of the CSS link information so that if I want to change the site’s design I only have to change the css path in one …
Display special characters returned from mySQL in drop down select box
I am trying to display utf8 characters in a drop down box which is pulled from mySQL (utf8_general_ci) the characters are returning as diamonds with a ? in the middle on. I have tried htmlspecialchars and htmlentities. And it returns a blank string. Site also has the charset set to utf-8. Thank you very much.…
How to get id of submit type button, when button is pressed
I want to print out the id of the button I pressed. The id is set dynamically for each button in a table. This is my HTML code: And I want to print the id of the button here. Answer If you do not wish to use a hidden field, you could set your submit button like this: Then you
How can I save TXT Files from a HTML textarea, using PHP?
I am trying to make a text file storage system for my website. Here is what I have so far. I have gotten some parts to work, but am getting many more errors after making a few changes I thought would help. I am trying to accomplish this task without changing pages or url. If the only way is to
how to remember scroll position of page
I am submitting some data to my database then reloading the same page as the user was just on, I was wondering if there is a way to remember the scroll position the user was just on? Answer I realized that I had missed the important part of submitting, so, I decided to tweak the code to store the cookie
Do not escape html stored as string (execute or process html string) [closed]
In PHP (WordPress theme function, trying to add html stored in theme options to blog header), I’m trying to get the following line: $x=”
html
“; echo $x; To render html just like: …
Get Year From Date string
I want to check whether the current year is greater than a date string(D-M-Y) here is my code $OldDate = “09-30-2011”; $OldYear = strtok($OldDate, ‘-‘); $NewYear = date(“Y”); if ($OldYear < $…
PHP multiline string with PHP
I need to echo a lot of PHP and HTML. I already tried the obvious, but it’s not working: How can I do it? Answer You don’t need to output php tags:
PHP How to echo without HTML tags
I have a sort of system where everybody can type whatever he wants. Though, they can also seem to use tags like , etc. How …