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
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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.