preview to update then publish
Moderator: General Moderators
preview to update then publish
Every thread based site that has any clue how to run for the lay has a preview before posting... much like this BB forum.
How does one send to a preview area, without actually posting to the database, and from there, what makes it go on after it is approved?
How does one send to a preview area, without actually posting to the database, and from there, what makes it go on after it is approved?
I suppose just showing a template with the $_POST'd values.... with them each in their place. Then to submit, they need to insert into the database.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
switch ($_POST['submit']) {
case 'preview' :
echo 'This is a preview of '.$_POST['var'];
break;
case 'insert' :
mysql_query(...);
break;
}To revisit this topic:
I understand, loosely, that $_POST is a global variable
and that once something is set to $POST,
it sort of stores the info in a magic clipboard that knows
what you are talking about when you use $_GET.
However, I don't really understand how it does that...
Where is it saving it to?
If I have the ADD button $sql statement saying INSERT,
What would the PREVIEW button look like, and where does it go?
and that once something is set to $POST,
it sort of stores the info in a magic clipboard that knows
what you are talking about when you use $_GET.
However, I don't really understand how it does that...
Where is it saving it to?
If I have the ADD button $sql statement saying INSERT,
What would the PREVIEW button look like, and where does it go?
Code: Select all
if($_POST['bpress']=="add")
{
$sql = "INSERT INTO city (Blah) VALUES ('".$_POST["blah']."')";
}- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
if they are gonna preview it then you could do many things, you could set their post as a session them when they click yes submit that just use the session, you could put in a hidden field in the preview page and set the post to that hidden field so that it is submitted again, you could have a temp table for posts like that then just copy it from the temp table to the real table.
i don't understand.
if you are telling the $_POST to INSERT,
then how is it a preview?
my brain isn't making this connection.
say i make a preview page,
where is the information being grabbed from?
when i have made detail pages in the past,
it draws the info from a table.
i don't understand where to get the information from if it hasn't been posted to a database.
i bet that that is what the $_POST is about.
I can imagine on the other side of this block, I will grasp a lot more than preview pages.
if you are telling the $_POST to INSERT,
then how is it a preview?
my brain isn't making this connection.
say i make a preview page,
where is the information being grabbed from?
when i have made detail pages in the past,
it draws the info from a table.
i don't understand where to get the information from if it hasn't been posted to a database.
i bet that that is what the $_POST is about.
I can imagine on the other side of this block, I will grasp a lot more than preview pages.
When you submit your form, your form data is stored in an associative array called $_POST
this will look like
You can then use these values by calling out the indivual name of the field. In this example.. $_POST['field2'] would be 'value2' which is what was entered in your form element named 'field2'
You can then do whatever you wish with the data (such as display it) without inserting into a database.
for example:
this will look like
Code: Select all
Array (
['field1'] => value1
['field2'] => value2
['field3'] => value3
)You can then do whatever you wish with the data (such as display it) without inserting into a database.
for example:
Code: Select all
$name = $_POST['name'] // name was the name of your form input element
echo "Your name is $name";Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
okay.. default action of the form is to send to the preview page via the preview submit button being first (and if not set in the submission does a preview automatically), the post button has a different value on it than the preview one, thus changing which side of the divider it lands on. There are 3 pages in 1 script with this. That's how this board works (roughly).