How to make a preview page before submitting?

Ok so here is my image and other info php upload script. How do I preview this before the user submits it?
<?php 
session_start();
$error="";

//error_reporting(E_ALL); 


	// image upload folder
    $image_folder = 'images/classified/'; 
	// fieldnames in form
	$all_file_fields = array('image1', 'image2' ,'image3', 'image4');
	// allowed filetypes
	$file_types = array('jpg','gif','png','pdf');
	// max filesize 5mb
	$max_size = 5000000;
	//echo'<pre>';print_r($_FILES);exit;
	
	$time = time();
	$count = 1;
	
	foreach($all_file_fields as $fieldname){ 
		if($_FILES[$fieldname]['name'] != ''){
			
			$type = substr($_FILES[$fieldname]['name'], -3, 3);
						
			// check filetype
			if(in_array(strtolower($type), $file_types)){
				
				//check filesize
				if($_FILES[$fieldname]['size']>$max_size){
					$error = "File too big. Max filesize is ".$max_size." MB";
				
				}else{
				
					// new filename	
					$filename = str_replace(' ','',$myusername).'_'.$time.'_'.$count.'.'.$type;
			
					// move/upload file
					$target_path = $image_folder.basename($filename);
					move_uploaded_file($_FILES[$fieldname]['tmp_name'], $target_path);
				
					//save array with filenames
					$images[$count] = $image_folder.$filename;
					$count = $count+1;

				}//end if

			}else{ $error = "Please use jpg, gif, png or pdf files";
			
			}//end if
		}//end if
	}//end foreach



if($error != ''){ echo $error;	
}else{


/* --------------------------------------------------------------------------------------------------
SAVE TO DATABASE ------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------- */


$con = mysql_connect("localhost","","");
if (!$con){die('Could not connect: ' . mysql_error());}

// if residential
if($_POST['type'] == "residential"){
		mysql_select_db("", $con);
		$sql = "INSERT INTO apartments (username, title, county, town, type, description, phone, rooms, bath, square, rent, fees, imageurl1, imageurl2, imageurl3, imageurl4) VALUES ('".$myusername."', '".$_POST['title']."', '".$_POST['county']."', '".$_POST['town']."', '".$_POST['type']."', '".$_POST['description']."','".$_POST['phone']."','".$_POST['rooms']."','".$_POST['bath']."','".$_POST['square']."','".$_POST['rent']."','".$_POST['fees']."','".$images[1]."','".$images[2]."','".$images[3]."','".$images[4]."')";

		$result = mysql_query($sql) or die(mysql_error());
}


// if commercial
else if($_POST['type'] == "commercial"){
		mysql_select_db("", $con);
		$sql = "INSERT INTO comm (username, title, county, town, type, description, phone, rooms, bath, square, rent, fees, imageurl1, imageurl2, imageurl3, imageurl4) VALUES ('".$myusername."', '".$_POST['title']."', '".$_POST['county']."', '".$_POST['town']."', '".$_POST['type']."', '".$_POST['description']."','".$_POST['phone']."','".$_POST['rooms']."','".$_POST['bath']."','".$_POST['square']."','".$_POST['rent']."','".$_POST['fees']."','".$images[1]."','".$images[2]."','".$images[3]."','".$images[4]."')";

		$result = mysql_query($sql) or die(mysql_error());
}


	echo "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><br /><h1>You Have Successfully Posted</h1>";
	echo "<p>&nbsp;</p><p>&nbsp;</p><br /><a href='index.php'>go to your ACCOUNT page</a>";

	
}//end if		
	
	?>

Open in new window

genesisvhAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

h2g2guyCommented:
PDF's would probably be really tricky to preview, unless you want to use frames...and I HATE frames...

The way I'd do a confirmation page for photos, at least, would just be to create another two pages.  First of all, the page that you already have will save the photos to a temporary location, without updating any databases.  When you submit the page, it will lead to the first new page which will be a simple yes or no, 'is this the right information' page.  If you hit yes on that page, it'll lead to the second new page.  THIS page will be the one that saves the pictures in a more permanent location, as well as saving all the information to the database.  
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
genesisvhAuthor Commented:
To be honest all I want is the text to be previewed. Not to concern with the images since the user will be able to change them later if he/her chooses so.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.