PDA

View Full Version : PHP: Detect URL in "text".


Harlequin
06-06-2005, 02:40 AM
So here I am again asking for something that seems simple to me, but for one reason or another I can't visualize how to put this on paper.. so to speak.

User inputs in a form:

<HTML>
<HEAD>
</HEAD>
<BODY>
Hello, check this iframe:
<IFRAME SRC="http://www.someaddress.com"></IFRAME>
</BODY>
</HTML>

When this is output, this can be fine and dandy (for -my- purpose).. if the source URL of the iframe is controlled to a minimal number of possibilities.

So, to work around this, I've came up with the following solution, but I'm not sure how implement it in PHP:

If the user inputs the above in a form.. upon submission, the <IFRAME SRC="" URL would be detected and/or changed to whatever URL I've predetermined (so users can access material only on one site URL, not every site URL).

So, in the above example, if you were to replace the above IFRAME statement with what is below:

User would input:

<HTML>
<HEAD>
</HEAD>
<BODY>
Hello, check this iframe:
<IFRAME SRC="http://www.badaddress.com">
</BODY>
</HTML>

Script would output:

<HTML>
<HEAD>
</HEAD>
<BODY>
Hello, check this iframe:
<IFRAME SRC="http://www.goodaddress.com">
</BODY>
</HTML>

Or, for that matter, the script could just give an error and be done with it, too. Either way works for this purpose.

Whatever a user puts in for the URL of the iframe source is dynamic -- there's no set address that is a good address.

Suggestions?