|
Posted by shror on 02/27/07 00:04
On Feb 27, 1:28 am, OmegaJunior <omegajun...@spamremove.home.nl>
wrote:
> On Mon, 26 Feb 2007 13:29:36 +0100, shror <shahi...@gmail.com> wrote:
>
> > 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.
>
> Adding the entire <img> element into the radiobutton value is a creative
> idea, but unfortunately you'll get into trouble with the quotes and the
> html validity. Instead, you may want to try something like this in your
> form:
> <input type="radio" value="sun" name="image">
>
> and this in your form handler:
> <?php
> $picture = $_POST['image']; //will now contain 'sun'
> echo '<img src="http://www.yourdomain.com/nature/'.$picture.'.jpg">';
> ?>
>
> The security problem comes in when someone creates a form on their own
> server like so:
>
> <form action="http://www.yourdomain.com/gallery.php" method="post">
> <input type="radio" value="../veryhidden.txt" name="nature">
> <input type="submit" value="OK">
> </form>
>
> That way they can have your gallery.php show the file 'veryhidden.txt' in
> the root directory of your site, unless you specifically test for the
> validity of the information passed to your gallery.php. Doesn't hurt if
> you don't have a 'veryhidden.txt' file, but you get the idea. Hackers will
> just guess some very common file names.
>
>
>
> > -------------------------------------------------------------------
> > about the second way,
>
> > i dont know about mime-type header!
>
> > what is it and its use and how to set it.
>
> It's just about being nice to the browser. Check out the 'header()'
> function onwww.php.net. One of the ways to use it is like this:
> header('content-type: image/jpg');
>
> If used, it should be the first thing after <?php, and <?php should be the
> first thing in your php file.
>
> By supplying this, you can tell the browser what kind of file to expect.
> Thus if you hand the browser an image you'd tell it to expect a mime-type
> of 'image/jpg', 'image/png', 'image/gif' or whatever image you're
> supplying. And if you hand the browser a web page you'd tell it to expect
> a mime-type of 'text/html'.
>
> In your case, because you're going to be printing html containing an img
> element to the browser, you'd either supply a header like 'content-type:
> text/html', or none at all, because for php files the default content-type
> usually already is set to text/html.
>
> --
> Using Opera's revolutionary e-mail client:http://www.opera.com/mail/- Hide quoted text -
>
> - Show quoted text -
I want to tell you OmegaJunior that am working on your answer and am
trying to get some results.
first thing
I have tested the radio button when i added the entire <img> tag in
its value part and gave me errors because of the quotes like you said.
but then i was trying and i removed the quotes and its working great
without any problem, its looking like this,
<input type="radio" value="<img src=/images/button1.png>"
name="nature">
its really working fine
second thing
about securing the form i have tested the file named 'veryhidden.txt'
and its not found, but i was wondering about what is this file and
what is the use of it how its useful for hacker.
third
am working on finding a security way for the forms and will sure get
your openion if you dont mind.
fouth and finally for now is
to Thanks you for your detailed answers and your help for now and
later :D
shror
www.s7els7.com
www.beachtoursegypt.com
www.mobidp.com
Navigation:
[Reply to this message]
|