View Single Post
Old 09-29-2007, 04:27 AM   #1
m1a2x3x7
m1a2x3x7's Avatar
 
Join Date: Mar 2007
Posts: 297
Default validation issue

When i create my validation script i have a slight problem. once you submit the form it clears all the boxes so the stuff they did fill out is empty with no red * and the stuff they didnt fill out is with a red * how can i keep the information that they did fill out in the boxes if they submit with out completion?

my code

PHP Code:
<?php
 
ob_start
();
require_once(
"../connection.php");
session_start();
 
 
$artist $_POST['artist'];
$targetPath $artist;
$targetPathSm$artist;
$targetPath $targetPath basename$_FILES['LGupload']['name']);
$targetPathSm $targetPathSm basename$_FILES['SMupload']['name']);
$error "*";
 
 
 
 
 
if (isset(
$_POST['submit']) && ($_POST['artist']) && ($_FILES['LGupload']['name']) && ($_POST['imageW']) && ($_POST['imageH']) && ($_FILES['SMupload']['name']) && ($_POST['title']) && ($_POST['description']) && ($_POST['artSize']) && ($_POST['price'])) {
 
$query =sprintf("INSERT INTO art (artist, lg_picture, lg_width, lg_height, sm_picture, title, description, art_size, price) VALUES ('{$_POST['artist']}', '{$_FILES['LGupload']['name']}', '{$_POST['imageW']}','{$_POST['imageH']}', '{$_FILES['SMupload']['name']}', '{$_POST['title']}', '{$_POST['description']}', '{$_POST['artSize']}', '{$_POST['price']}')"); 
$result = @mysql_query($query);
 
move_uploaded_file($_FILES['LGupload']['tmp_name'], $targetPath);
move_uploaded_file($_FILES['SMupload']['tmp_name'], $targetPathSm); 
}
?>
 
<form enctype="multipart/form-data" action="<?php $_SERVER['PHP_SELF'];?>" method="post">
<table width="776" border="0">
<tr>
<td width="100" align="right" valign="top"><div align="right"><span class="style3">Artist | </span></div></td>
<td width="619" class="style3"><select name="artist" class="style3" id="artist">
<option value="mcfee/" selected="selected">Mcfee</option>
<option value="allen/">Allen</option>
<option value="olga/">Olga</option>
<option value="athomas/">Athomas</option>
<option value="craig/">Craig</option>
</select></td>
</tr>
<tr>
<td width="100" align="right" valign="top"><div align="right"><span class="style3">
<?php 
if (isset($_POST['submit'])) {
 
if (!(
strlen($_FILES['LGupload']['name']) > )){
?> <font color="#FF0000"> 
<?php echo $error;
}}
?> </font>Large Image | </span></div></td>
<td width="619" class="style3"><input type="hidden" name="MAX_FILE_SIZE2" value="524288" />
<input name="LGupload" type="file" class="style3" /></td>
</tr>
<tr>
<td width="100" align="right" valign="top"><div align="right"><span class="style3">
<?php 
if (isset($_POST['submit'])) {
 
if (!(
strlen($_POST['imageW']) > )){
?> <font color="#FF0000"> 
<?php echo $error;
}}
?> </font> Image Width | </span></div></td>
<td width="619" class="style3"><input name="imageW" type="text" class="style3" id="imageW" /></td>
</tr>
<tr>
<td width="100" align="right" valign="top"><div align="right"><span class="style3">
<?php 
if (isset($_POST['submit'])) {
 
if (!(
strlen($_POST['imageH']) > )){
?> <font color="#FF0000"> 
<?php echo $error;
}}
?> </font>Image Height | </span></div></td>
<td width="619" class="style3"><input name="imageH" type="text" class="style3" id="imageH" /></td>
</tr>
<tr>
<td width="100" align="right" valign="top"><div align="right"><span class="style3">
<?php 
if (isset($_POST['submit'])) {
 
if (!(
strlen($_POST['title']) > )){
?> <font color="#FF0000"> 
<?php echo $error;
}}
?> </font>Title | </span></div></td>
<td width="619" class="style3"><input name="title" type="text" class="style3" id="title" /></td>
</tr>
<tr>
<td width="100" align="right" valign="top"><div align="right"><span class="style3"> 
<?php 
if (isset($_POST['submit'])) {
 
if (!(
strlen($_POST['description']) > )){
?> <font color="#FF0000"> 
<?php echo $error;
}}
?> </font>Description | </span></div></td>
<td width="619" class="style3"><textarea name="description" class="style3" id="description"></textarea></td>
</tr>
<tr>
<td width="100" align="right" valign="top"><div align="right"><span class="style3">
<?php 
if (isset($_POST['submit'])) {
 
if (!(
strlen($_FILES['SMupload']['name']) > )){
?> <font color="#FF0000"> 
<?php echo $error;
}}
?> </font>Thumbnail |</span></div></td>
<td width="619" class="style3"><input type="hidden" name="MAX_FILE_SIZE" value="524288" />
<input name="SMupload" type="file" class="style3" />
Image must be 100x100px </td>
</tr>
<tr>
<td width="100" align="right" valign="top"><div align="right"><span class="style3">
<?php 
if (isset($_POST['submit'])) {
 
if (!(
strlen($_POST['artSize']) > )){
?> <font color="#FF0000"> 
<?php echo $error;
}}
?> </font>Art Size | </span></div></td>
<td width="619" class="style3"><input name="artSize" type="text" class="style3" id="artSize" /></td>
</tr>
<tr>
<td width="100" align="right" valign="top"><div align="right"><span class="style3">
<?php 
if (isset($_POST['submit'])) {
 
if (!(
strlen($_POST['price']) > )){
?> <font color="#FF0000"> 
<?php echo $error;
}}
?> </font>Price | </span></div></td>
<td width="619" class="style3"><input name="price" type="text" class="style3" id="price" /></td>
</tr>
<tr>
<td width="100"><div align="right"></div></td>
<td width="619" class="style3"><div align="right">
 
 
<div align="right">
<input name="hiddenField" type="hidden" value="1" />
<input name="submit" type="submit" class="style3" value="Submit" />
</div></td>
</tr>
</table>
 
 
 
</form>
Thanks for the help.

-M
m1a2x3x7 is offline   Reply With Quote