PDA

View Full Version : validation issue


m1a2x3x7
09-29-2007, 05:27 AM
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

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']) > 0 )){
?> <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']) > 0 )){
?> <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']) > 0 )){
?> <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']) > 0 )){
?> <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']) > 0 )){
?> <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']) > 0 )){
?> <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']) > 0 )){
?> <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']) > 0 )){
?> <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
09-29-2007, 05:41 AM
nevermind...2 sunkists later it finally came to me WoOT!

davidj
09-29-2007, 10:40 AM
m1

please use your code formating tags when posting