Doubt passing parameters via form

Asked

Viewed 45 times

-2

Doubt, I can’t send the image.

Way: _img/_products/photo2-green.png

<input type="radio" name="cor" id="verde" value="verde"> 

<img src="_img/_produtos/foto<?=$_POST['???']?>-<?=$_POST['cor']?>.png">

That last code has to work on me : _img/_products/photo2-green.png

The way it is, it brings me to it: _img/_products/photo???-green.png

2 answers

0

Ai is only saying that your ID passed by post is undefined (does not exist), but this is normal, because you are only passing the 'color'

if you want to upload an image you will need to use a file input and then in php you will need to use $_FILE['filename'

  • so that’s not what I want, basically it would be this here. How to pass number as parameter? to be correct foto2-green.png

  • I edited the topic, take a look, please.

0

I solved the problem, the solution is below:

Just add an input type Hidden

<input type="hidden" name="numproduto" value="2">

And complement the display code:

<img src="_img/_produtos/foto<?=$_POST['numproduto']?>-<?=$_POST['cor']?>.png"
            class="img-thumbnail img-responsive">

Browser other questions tagged

You are not signed in. Login or sign up in order to post.