Simplest way to update website content without editing the page [duplicate] - php

This question already has answers here:
How do I make a div element editable (like a textarea when I click it)?
(8 answers)
Closed 8 years ago.
I've built a website for a friend and because he is not very techy and will be updating it relatively often.
My question is is there a way I can update the site using say, a PHP form and that will write a new div into the page?
So in standard english it would be the following:
Enter title
Enter date
Enter poster
Enter content
Submit
Can I do that simply in PHP? I'm open to other suggestions as well.
Thanks a lot!
Liam

I highly suggest you "Inplace Editing"
http://www.appelsiini.net/projects/jeditable
http://code.google.com/p/jquery-in-place-editor/
https://stackoverflow.com/questions/708801/whats-the-best-edit-in-place-plugin-for-jquery
The user has only to point and click on elements which he want to change. Plain simple... It's on you to implement an basic authentication system so that only the Owner of the Page is allowed to edit and save Data.

All in all it's just the editing of a file. You can write a php script that takes that input from the user and basically rewrites the html page accordingly.

Related

How to create a page using a form? php/html [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Similar to how you create a post in wordpress or even ask a question on this very website.
I want to know how to create a page by just filling out a form?
Here's what I know:
-I know how to make an html form
-I know how to place data in a database and take it out
-I know some php
What I don't know is how to to tie all of these things together. Please be as specific as possible and if you know of a tutorial on how to do this or you have the time to make a small example I would be very very grateful.
Thank you in advance for your time :-)
EDIT: To provide more details
I want to send data from a form (even a few text inputs would be enough) and for them to be placed in a page where I can display them.
And also that page should have an unique identifier so it gets stored similar to the questions on stack overflow where there is www.stackoverflow.com/posts/'identifiernumber'
And I would always to go back to that information provided I access the link which I assumed will be stored in the database.
Wordpress uses wysiwyg this is used to convert normal text into html code you can find jquery plugins for it.After user has entered the content of the page and hits submit. Wordpress directly stores the content in the database in HTML FORMAT . Now all it does is echo out the content stored in the database.
Now for the identifier , it should point out to the primary key of the database row where the content is stored. Wordpress stores a unique url as the identifier like the questions you asked is How to create a page using a form? php/html it will store it as how-to-create-a-page-using-a-form-php-html . This is then put in the href attribute of <a> tag , on click of this unique identifier it echo out the content of that row.
All you have to do now is make a form and textarea , apply the wysiwyg plugin on the textarea . Then onsubmit store the data in the database and also creating a unique identifier for it.
You question now is how to pass the identifier in the URL?
First you must know how to pass a variable in the URL and then capture it in the required place eg : www.yourwebsite.com?identifier=something and to make this a link on you website
Something
Once you have mastered this you can then study a concept called MOD REWRITE and in layman term for this is called clean URL or SEO URL . There are many blogs and methods of achieving this goal. You can google MOD REWRITE and SEO URL.
Create your website theme
on first page create form like you want
concept is like registration form and second page is edit profile
now what you stored in database from registration form
now echo in your edit profile form
for example username in database can be viewed in edit profile form
select * FROM registrationtable WHERE userid='$userid'
then store values in variables like for example
while ($query = mysql_fetch_array($request))
{
$username = $query['username'];
}
<input type="text" name="username" value="<?php echo $username; ?>"/>
p.s dont use mysql better options are mysqli and PDO

Best way to simple frontend that stores data [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have a simple page that shows 4 different divs, all with a <h1> title (or other tag that shows text) and a form (with 1 input text) and a submit button... so far so good.
My answer is simple: I am looking for a way that:
when the user inserts a text and submit the form, the <h1> title shows the text that the user wrote
the form disappear (or takes style display:none)
this will take effect even if I refresh the page or view page in a different computer (probably need to save the data in a DB)
restart this process from the beginning (even if I need to code again).
This is for a mini game to provide to users 4 different choices and, if the user A select option 1, the <h1> will show text something like "User A was the first to choose this option. Please select a blank option" and, after the 1st raw over (point 4 described above), restart all forms.
NOTE: I am not asking in the way to "please do the code for me". I also searching for a way to store data in <php ?> - finding redbeanphp project.
I am also a newbie in SQL (just started to study SQLi last month to android development). My question is ONLY to looking for the best way to do this and what I need.
This would be the workflow:
When you click a button to submit the form JavaScript will send the form data to the server as an AJAX request and wait for a response from the server.
The PHP code on the server will read the data from the AJAX request and save it in a database and echo a success response along with the text to display.
Your JavaScript will receive this success message and hide form from the DOM and display the text in the header.
If you want the data to persist on the page on reload then you can save a flag in PHP session. Sessions persist in until you close browser window.
4.1 Use another AJAX call remove the flag from the session and reload the content.
So, if you are good with HTML and CSS you need:
JavaScript, AJAX, a JavaScript library to make things easier such as JQuery.
A server side language such as PHP.
A database to persist data. There are many choices. I am going to recommend MySQL just because there so many tutorials for it out there.

Is there a way to disable cookies in your HTML/PHP Code for Logins [duplicate]

This question already has answers here:
How do you disable browser autocomplete on web form field / input tags?
(101 answers)
Closed 9 years ago.
total Web Dev noob here, but I've been working on a website that involves logging in- The user puts his/her username and password. That's all fine and dandy, but the way that cookies work here can be a bit of a pain-Everytime I enter something in the text box, log in, and then go back to the log in page, whenever i want to type something in the login text box, there is a drop down menu for usernames and it can be really annoying- is there a way to prevent this in the actual code?
Your problem is not within the cookie but with the browsers autocomplete feature.
If you want to disable it you should look to this answer: How do you disable browser Autocomplete on web form field / input tag?
The dropdown menu you are referring to is due to your browser, not the cookies your website may or may not be using. You can usually find the option to delete saved form history somewhere in your browser options near where you would clear your history.

Reload previous link on click-event of back button of browser? [duplicate]

This question already has answers here:
How to detect the back button
(2 answers)
Closed 9 years ago.
i am developing one website in which main content is getting load by jquery ajax according to selected menu item.
on selecting any menu item, url get changed according to this pattern:
http://host/domain/index.php?pageid=page
here page refers to the page that i want to load into main content using ajax.
now in this case, i want to reload the previous page if user clicks on back button of browser.
can anyone help me out how could i achieve this?
If you do not change a url, then I'm afraid that is not possible.
Suppose you should better try to use window.history which provides onpopstate event when user clicks back button. But you will need to modify url in browser with history.pushState/history.replaceState functions. Possibly, you can add same url to history, so it will not be changed visually. And then take previous URL from your custom history array. But not sure if popstate will work if you place same url with pushState
But that will work in modern browsers only. To make it work in all browsers, you should better use some history plugin (for example this) which will also handle IE using hashtags

Re-ask: How do I use php so that when a user presses a specific button, they can write to a specific .txt file? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How do I use php so that when a user presses a specific button, they can write to a specific .txt file?
First of all, am I able to re-ask a question? I got two answers, yes, but I tried both and they didn't work. I'm worried that people will forget about my question and I might not ever get the answer to my question and patch up my code. Anyway, here it is. If, however, re-asking questions is against some rule I was not aware of, I will refrain from this in the future. Thanks!
Basically, as in other questions I've asked related to my php chat application, I am trying to get it so that there is a text field where $msg is displayed via msg.txt. Two users can communicate to another in this way. This would be easy if I wanted to use a simple include function. But I don't want to take all the trouble to make and upload all those pages to my server. So how can I have it where when the user, say named Aaron, clicks on a button titled Benjamin, and types to a file called aaronbenjamin.txt, and if Aaron wants to talk to another user, he can press on a button titled Chris, and type to a file called aaronchris.txt? And all from the same box and text field? Thanks, I appreciate it.
The most important thing about my question was that the user is able to press the name of another user and they will be able to chat with the user. This means that they will be switching to a different .txt file whenever they click on a user. Thank you to #Cyclone and #cronoklee for your answers, but sadly they didn't work.
Use this for the buttons:
<textarea name=msg></textarea>
<input type=submit name=file value=Aaron>
<input type=submit name=file value=Benjamin>
And this for the PHP:
$fn = preg_replace('/\W+/', '', $_REQUEST["file"]);
file_put_contents("$fn.txt", $_REQUEST["msg"]);

Categories