I am new to PHP, and I have this website. I want to know if i can have a page that is password protected (i know how to do that part), where the user can edit a variable from a text area.

Example: if i had a $news variable, and it would equal the news text on the home page. Is there a way that I can make a Text Area where the admin can write in the news they want, and have it change the variable, so they can change the variable without knowing the code? (With the click of a button)

If so, could you please tell me how? Thanks in advance.

Recommended Answers

All 3 Replies

Member Avatar for diafol

I am new to PHP, and I have this website. I want to know if i can have a page that is password protected (i know how to do that part), where the user can edit a variable from a text area.

Example: if i had a $news variable, and it would equal the news text on the home page. Is there a way that I can make a Text Area where the admin can write in the news they want, and have it change the variable, so they can change the variable without knowing the code? (With the click of a button)

If so, could you please tell me how? Thanks in advance.

You could, but where is you data being stored: hard coded into the page / a DB / a text file?

You could, but where is you data being stored: hard coded into the page / a DB / a text file?

Lets say, for my sake, that it is in a seperate news.php file that will contain just the $news variable, that will be included on the main page. (If that is possible.) Thanks. .

Member Avatar for diafol

Lets say, for my sake, that it is in a seperate news.php file that will contain just the $news variable, that will be included on the main page. (If that is possible.) Thanks. .

Sorry, missed your reply - must have gone off the page. From this it seems you have a static news item (hard-coded in php) that is displayed on one page (news.php) and included in the main page (via include or require).

If you want to make changes to the actual news.php file, do so by hand (in your IDE). Otherwise, I'd think again about how you are storing this text. You can write to file via textarea, but seeing as your news.php isn't just plain html, it can get messy.

I'd suggest having a DB store your news articles which can then be ranked by date so that you always get the latest article.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.