Send a variable through the Iframe url

Asked

Viewed 175 times

1

I’m starting programming in PHP and I have a page in PHP and I want a send a variable to an ASP page.

The problem is that I am not able to send the variable $codselecionado, if I put the value in hand, it is right, the ASP page identifies this value and the progress in the project

echo '<iframe name="atualizaguia1" allowfullscreen=true frameborder=0 src="atualizaguia1.asp?codtitulo=52022"  target="_self" scrolling=auto>';

I wonder what I’m doing wrong in this shipment

echo '<iframe name="atualizaguia1" allowfullscreen=true frameborder=0 src="atualizaguia1.asp?codtitulo=$codselecionado"  target="_self" scrolling=auto>';       

The variable $codselecionado is correctly filled with the value, I’ve done several tests on it.

  • Friend, post the code you’ve developed so far so we can help you.

1 answer

1


You are using simple quotes to delimit the return of echo. When using single quotes, the variable $codselecionado inside is not processed (see this topic), that is, it will be sent literally: the ASP will receive the value "$codselected" and not the value that the variable represents in PHP.

What you can do is delimit the echo double quotes, because inside double quotes the variable is processed, only double quotes of the iframe attributes need to be exchanged for single quotes:

echo "<iframe name='atualizaguia1' allowfullscreen=true frameborder=0
src='atualizaguia1.asp?codtitulo=$codselecionado'  target='_self' scrolling=auto>";

Or else keep as is and concatenate the variable:

echo '<iframe name="atualizaguia1" allowfullscreen=true frameborder=0
src="atualizaguia1.asp?codtitulo='. $codselecionado. '"  target="_self" scrolling=auto>';
  • Sam I appreciate the help, really both ways worked perfectly

Browser other questions tagged

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