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 6 of 6

Thread: Images in Forms

  1. #1
    Regular Coder Deacon Frost's Avatar
    Join Date
    Feb 2008
    Location
    Between the Lines
    Posts
    279
    Thanks
    31
    Thanked 4 Times in 4 Posts

    Images in Forms

    It's a php form that I need to also edit, so I'm asking all of the questions here...

    What i have:

    PHP Code:
    <?php
    include("/home/stage/public_html/css/inc/theaterconn.php"); 

    $result mysql_query("SELECT filmid,name FROM theater WHERE status=2") or die('mysql_error()' 'Error:  ' mysql_errno() );
    $row mysql_fetch_assoc($result);

    $filmid $row['filmid'];
    $name $row['name'];

    ?>

    <form action="theater.php" method="get">
     <input type="submit" value=<img src="http://images.stage6.com/video_images/<? echo $filmid ?>t.jpg</img> <br /> <center> "<? echo $name ?>" </center> />
    </form>
    What I need it to do...

    There's a few fields in the database. The only one I need it to send to theater.php in the get function is the "id" for the video. filmid is the code, but id is the unique video's, well, id.

    What it will need to do is show 5 images where the status=2 (approved). These images are like above. <? echo $filmid ?> will finish the image, and $name is just the name of the movie. When this is clicked, I need it to use the method get to grab the id for the $filmid and $name image (form) clicked.

    Basically (once I have this i can do everything else) I need an image on a form. Not a button, but a form. How do I put an image on a form?

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Why does it have to be a form?

    You can do this and still use $_GET in the receiving script:

    <a href="receiving_script.php?id=<?=$filmid?>"><img src="<?=$filmid?>t.jpg"></a>

    The receiving script has this:
    $id=$_GET['id'];

  • #3
    Regular Coder
    Join Date
    Dec 2007
    Location
    Nebraska
    Posts
    113
    Thanks
    0
    Thanked 2 Times in 2 Posts
    If you have to use a form, use an image button. ASFAIK It doesn't work to put HTML markup in the value attribute of a submit button, and it certainly isn't valid HTML.
    Deliver yesterday, code today, think tomorrow.

  • #4
    Regular Coder Deacon Frost's Avatar
    Join Date
    Feb 2008
    Location
    Between the Lines
    Posts
    279
    Thanks
    31
    Thanked 4 Times in 4 Posts
    that won't make it so the id = the id number for that video, but it will equal the filmid for that video. It has to be the unique id for that video...

    I got it to work, now I just need help on...

    How to use the get function properly. Basically I have ID FilmID and Name. FilmID and Name are what is used to MAKE up the form that I have. However, I need the ID that is for the form matching FilmID and Name to be sent to the theater.php (receiving). That way in the receiving I can set it up to $_GET['id'] and when doing so it'll put it in a query string in the url, and change the id number of which movie was selected.

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    You can send more than one variable with the URL ...

    <a href="theater.php?id=1234&filmid=37362&name=name of the film">


    With the form, you can have hidden variables ...

    <form action="theater.php" method="post">
    <input type="hidden" name="name" value="name of the film">
    ... other stuff
    </form>

    if you use the URL, the script uses $_GET ...
    $id=$_GET['id'];

    if you use method="post" in a form, your script uses $_POST
    $name=$_POST['name'];

    By using POST in a form, you won't see the variables in the URL

    ==========

    Final method, you have each one stored in a database.
    You only send the ID and the script called "theater.php" matches
    that ID to the database and then it knows everything else about
    the film by matching the ID and reading the database.

  • #6
    Regular Coder Deacon Frost's Avatar
    Join Date
    Feb 2008
    Location
    Between the Lines
    Posts
    279
    Thanks
    31
    Thanked 4 Times in 4 Posts
    Ok, well, I got that part done... I used forms cause doing the link could cause problems in the future. (Format and ****)
    Last edited by Deacon Frost; 02-15-2008 at 08:08 PM.


  •  

    Posting Permissions

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