Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: form questions

  1. #1
    New Coder
    Join Date
    Nov 2005
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    form questions

    me Again

    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

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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/showthre...build+dropdown
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can use the $_FILES array
    http://uk2.php.net/features.file-upload
    PHP Code:
    <!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>

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by degsy
    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...
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #5
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 Code:
    <?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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •