Send data to another page via a [closed]

-2

I would like to know how to resolve the following situation: I have a page that has a loop in which it shows all the posts of a specific posttype, and in each post I put a button (no functionality for now).

I would like some way to make when the user clicked on this button, the post was saved somehow and appeared on another page called "my posts", and of course, if the person clicked the button again this post would disappear of the "my posts" page.

I have already researched plugins for this but it has not rolled and now I am trying to do some code right at hand, but I do not have that much knowledge for that. If anyone can help, I'll be grateful.

    
asked by anonymous 06.01.2017 / 16:15

1 answer

1

I think the best way to do this is to use GET. You will create for each button a link that will contain 2 things:

1) The file that will do the processing of the data sent. 2) The data itself.

At each post button, enter the address of a specific file by printing the post id (or any other id).

Follow the example below:

<div class="post"> <div class="thumb"></div> <h3 class="post-title"><?php echo $post['name'];?></h3> <a href="save_post.php?id=<?php echo $post['id'];?>"></a> </div>

Notice that immediately after the link address (href) I print a "? id=" (indicating the name of the variable that will be passed and the id of the post (which in your case will be the value that contains the information of the post Imagine that the post in question is the post of id 50. The address printed on the href will be:

06.01.2017 / 17:32