Page 1 of 1
make a text as url to another text
Posted: Wed Nov 23, 2011 12:19 pm
by tanares
i want to take from user two texts
the second one (will be url), i want to make it as url to the first text.
can you help me, how can i do it with php
Re: make a text as url to another text
Posted: Wed Nov 23, 2011 12:31 pm
by maxx99
Could you provide an example of 2 inputs and 2 outputs?
Re: make a text as url to another text
Posted: Thu Nov 24, 2011 8:29 am
by mikeashfield
I think you mean a link generator right? The form:
Code: Select all
<html>
<body>
<form action="/createURL.php" method="POST">
<input type="text" name="URLtitle"></br>
<input type="text" name="URLlink"></br>
<input type="submit" name="submit" value="Make URL">
</form>
</body>
</html>
And, the PHP file:
Code: Select all
<?php
if (isset($_POST['URLtitle']) && isset($_POST['URLlink'])) {
$URLlink=$_POST['URLlink'];
$URLtitle=$_POST['URLtitle'];
if (preg_match('((mailto\:|(news|(ht|f)tp(s?))\://){1}\S+)', $URLlink)) {
echo "<a href='".$URLlink."'>".$URLtitle."</a>";
}
}
?>