...

View Full Version : form questions



NTGre
02-09-2006, 08:04 PM
me Again :D

I got some questions

1)when you want to display the last submited value in a form (text field) i type

<input name="artist" type="text" size="34" value = $_POST[artist] >

Right?

what i must set as value in a upload field??

<input name='photo_filename[]' type='file' class="style22" value =?????? />

2)how i can do the same with a list/menu ???

Thnx for your time:thumbsup:

raf
02-10-2006, 07:49 AM
i don't think the actual fileadress (path on the client-machine) is posted when you submit the form, so that wount be possible.

regarding the listbox --> chack my post here http://www.codingforums.com/showthread.php?t=43353&highlight=dynamically+build+dropdown

degsy
02-10-2006, 02:02 PM
You can use the $_FILES array
http://uk2.php.net/features.file-upload


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<?php
if(isset($_POST['Submit'])){
echo 'You submitted:<br>';
echo $_POST['name'];
echo '<br>';
echo $_FILES['file']['name'];
}
?>

<form action="" method="post" enctype="multipart/form-data" name="form1">
<p>
<input type="text" name="name">
</p>
<p>
<input type="file" name="file">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>

raf
02-10-2006, 02:09 PM
You can use the $_FILES array
http://uk2.php.net/features.file-upload
does that contain the path to the file or only the filename? because the filename isn't gonne be enough...

degsy
02-10-2006, 02:28 PM
Ah, I was just thinking of passing the name.

If you want you could use javascript to pass the value. Not recommended though as JS can be disabled.



<?php
if(isset($_POST['Submit'])){
echo 'You submitted:<br>';
echo $_POST['name'];
echo '<br>';
echo $_POST['hidden_file'];
}
?>

<form action="" method="post" enctype="multipart/form-data" name="form1">
<p>
<input type="text" name="name">
</p>
<p>
<input type="file" name="file" onblur="this.form.hidden_file.value=this.value">
<input type="hidden" name="hidden_file">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>


You can have the javascript onsubmit or in a function.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum