Php adds and modifies data 2 to the same form. Well, in fact, I don't really care about visits, but today I have more visits than I published in the next year. I was a little surprised. as a technical cool. no, I am not okay. In fact, I don't pay much attention to visits, but today I have more visits than I published in the next year.
I was a little surprised. as a technical cool. no, I don't think I'm a diaosi. I think programming is a great job. although tired, it makes your daily life full.
No matter whether you believe it or not, anyhow I believe it.
Next, let's talk about uploading and modifying simple articles.
If attachments are involved, it is really a headache if attachments need to be changed during modification.
I don't know how it is implemented. let's share my methods.
On the page, I implemented it in this way.
I am adding data in the background.
First, we start to receive data. for example, the content of title and content. determine whether the content is empty. if the content is empty, it is returned directly.
If there is an attachment, we need to determine whether there is an attachment. if there is an attachment, we first move it to the project's uploads folder through the program,
If it fails, we will return it directly.
Okay, go to the program.
If (IS_POST ){
$ Title = $ _ POST ['title'];
$ Content = $ _ POST ['content'];
If ($ title & $ content ){
If ($ _ FILES ['file'] ['name'])
// Start processing the submitted attachments.
If the attachment is successfully uploaded, you can obtain the attachment name, the uploaded address, and other information.
If it fails
An error is returned.
}
$ Arr = array (
'Title' => $ title,
'Content' => $ content;
'Filename' => ///
'Filepath' => ///
);
$ Flag = insert operation ..
If ($ flag) $ str = "successful ";
Else $ str = "failed ";
$ This-> success ("add". $ str, // jump to list route .);
}
} // End of post.
// The following is the template content ....
If we want to modify the content.
I thought of a method ..
On the page, if there is an attachment, we will display the image name. if you need to modify it, we will display the file submission box ..
I only wrote the key part ..