You are here: Re: photo gallery question « PHP Programming Language « IT news, forums, messages
Re: photo gallery question

Posted by shror on 02/26/07 12:29

On Feb 25, 10:44 pm, OmegaJunior <omegajun...@spamremove.home.nl>
wrote:
> On Sun, 25 Feb 2007 21:10:57 +0100, shror <shahi...@gmail.com> wrote:
> > hi every body
> > I need help please
>
> > i have designed an image gallery of about 20 pictures and they are
> > shown in thumb nail views and for viewing the largeer version of the
> > images i have added a radio button and a push button, so that the user
> > choose the picture using the radio button and click on the push button
> > to open the larger version picture in another window, but my problem
> > is that i know how to pass the selection to the second page but the
> > problem is how to pass the selected picture not selected value.
>
> > the first html page code is:
>
> > <form method="POST" action="gallery.php">
> > <input type="radio" value="V1" name="nature">
> > <p><input type="radio" value="V1" name="nature"></p>
> > <p><input type="radio" value="V1" name="nature">
> > </form>
>
> > the gallery.php code is:
>
> > <?php
> > $image = $_POST['nature'];
> > echo "$image"
> > ?>
>
> > my problem is that this way gives me the name of the radio button i
> > select not the image so how i can make the image get shown not the
> > radio button name (not V1)
>
> > Thanks in advance for your help
>
> > shror
>
> I can see two methods to help you out in this case:
>
> 1) Alter your form: change the radio button names into the text "picture"
> and change the value of each radio button into the name of the actual
> picture, like so:
> <form method="post" action="gallery.php">
> <p><input type="radio" value="nature.jpg" name="picture"></p>
> <p><input type="radio" value="sun.jpg" name="picture"></p>
> <p><input type="radio" value="snow.jpg" name="picture"></p>
> <p><input type="submit" value="Show me" name="btnOK"></p>
> </form>
>
> That way, your gallery.php can read $_POST['picture'] and it'll give you
> "nature.jpg"
> "sun.jpg"
> "snow.jpg"
> which you then can show using fopen() for instance.
>
> This method however has a drawback: it'll show any file whose name is
> presented go the gallery.php, meaning that any person with ill intent
> could make it load any file at all. Thus there's a second method:
>
> 2) Alter your form and the gallery.php to use indexed picture numbers
> instead of picture names, like so:
> <form method="post" action="gallery.php">
> <p><input type="radio" value="1" name="picture"></p>
> <p><input type="radio" value="2" name="picture"></p>
> <p><input type="radio" value="3" name="picture"></p>
> <p><input type="submit" value="Show me" name="btnOK"></p>
> </form>
>
> That way, your gallery.php can read $_POST['picture'] and it'll give you
> 1, 2, or 3 respectively, which you can use in a routine as follows:
>
> $arrPictures = array();
> $arrPictures[1] = "nature.jpg";
> $arrPictures[2] = "sun.jpg";
> $arrPictures[3] = "snow.jpg";
>
> $imageIndex = $_POST['picture'];
> if (isset($arrPictures[$imageIndex])) {
> if (file_exists($arrPictures[$imageIndex])) {
> $imageFile = fopen($arrPictures[$imageIndex]);
> echo $imageFile;
> @fclose($imageFile);
> }
>
> }
>
> Don't forget to set a mime-type header!
>
> Hope this helps!
>
> --
> Using Opera's revolutionary e-mail client:http://www.opera.com/mail/- Hide quoted text -
>
> - Show quoted text -

thanks for your answer OmegaJunior,

i have tried the first method and i made a little bit small change and
it worked but i want to know about it and the draw back,

what i did is:
<input type="radio" value="<img src="www.mydomain.com/directory/
image.gif">" name="nature">

and i call it in the second page gallery.php in this way:
<?php
$picture = $_POST['nature'];
echo "$picture";
?>

what do you think about this is it the same having the same drawback
or its different, am sorry if my question means nothing but am still
beginner in php, so i dont know how any person with ill intent
could make it load any file at all.

-------------------------------------------------------------------
about the second way,

i dont know about mime-type header!

what is it and its use and how to set it.


am really so sorry for my silly dumb questions
and really very Thanksful and apreciate your help

shror

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация