0
<iframe align="middle" src="http://www.example.com?id=5555555" width="100%" height="300">
</iframe>

How can I pass this id value to example.com. Suppose I put this iframe to any webpage and when the iframe loads with the webpage I want to get the value id = 5555555 in example.com.

How to do this, I have tried to google a lot but couldn't get a definite answer.

Thanks in advance.

1
  • By the way, in this case id is a parameter. That may help your future searches. Commented Feb 20, 2012 at 16:33

3 Answers 3

2

You'll need to use the PHP superglobal $_GET. in your script, the basic implementation is very simple:

$id = $_GET['id'];

However, you will want to check the value before you do anything with it, because any user can type into their browser URL bar and change that id value.

If you're going to save it in a database, make sure you escape the value and even better, use a stored procedure. Scrub it however you can - check the length, the value, anything that can be used to throw off your code. Failure to do so can result in anything from a silly looking output on a page to a compromised server.

Sign up to request clarification or add additional context in comments.

Comments

1

By putting it in the query string, you have passed it to www.example.com.

Since you've tagged this PHP:

You can retrieve it with <?php $foo = $_GET['id']; ?>

1 Comment

I have tried it ..but somehow its not working... I think this would work if a submit button is clicked on a form but here its only an iframe which is loaded with the webpage
0

You have to check $_GET array looking for that 'id' key value:

$id = $_GET['id'];

For more info: PHP: $_GET

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.