Jump to content

[SOLVED] adding & previewing


aggrav8d

Recommended Posts

Say you have a store that sells cars.  You want to be able to add, remove, and edit cars.

The tricky part I can't figure out is an easy way to preview changes to a car before you hit save.

Opening a new window is not a problem.  Posting to the new window is also not a problem.

Making the system understand that I want it to show the temporary version of the Car and not the last saved version is my problem.

 

How would you do this?

 

On a related topic, when a user starts to create a new instance of something do you save it immediately to the database and delete it again if they hit cancel OR do you wait for them to hit SAVE before you write to the database?  I can see advantages to both methods.

Link to comment
https://forums.phpfreaks.com/topic/175033-solved-adding-previewing/
Share on other sites

To make a preview of something, all you need to do is pass the post variables to the preview page, and output them. You also want to store those variables in hidden forms, and when the user wants to save the changes, hit submit, else, bring them back to the previous page, and repopulate the data. for example

 

preview.php

<?php
$post = $_POST['my_var'];//post variable to preview
echo "The value: $post";
?>
<form name="form" action="submit.php" method="post">
<input type="hidden" name="my_var" value="<?php echo $post; ?>" />
<input type="submit" value="submit" />

 

and submit.php would be the page that you process the form, and all that stuff

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.