Cand in textarea se scrie cuvintele "youtube" sau "odnoklassniki" sau "facebook" , voi apasa pe buton si il va transforma in link ca cand apas sa ma duca pe http://www.youtube.com respectiv http://www.facebook.com.
Daca in textarea se introduce oricare alte cuvinte exceptand acestea sa nu mi-l transforme in link ce sa-l afiseze simplu.
La mine problema e ca orice ce introduc in textarea imi transforma in link:
Cod: Selectaţi tot
<body bgcolor="#A9A9A9">
<center>Type your text here: <br />
Available link: <b>youtube, odnoklassniki, facebook.</b><br />
<form action="" method="post">
<textarea rows="4" cols="60" name="textarea" ></textarea>
<br />
<input type="submit" name="submit" value="Transform">
</center>
Cod: Selectaţi tot
<?php
if(isset($_POST['submit']))
{
echo "<center>";
$textarea = $_POST['textarea'];
if($textarea == 'youtube' or 'odnoklassniki' or 'facebook')
{
if($textarea == 'youtube')
{
$link = 'http://www.youtube.com/';
}
elseif($textarea == 'odnoklassniki')
{
$link = 'http://www.odnoklassniki.ru/';
}
elseif($textarea == 'facebook')
{
$link = 'http://www.facebook.com/';
}
GLOBAL $link;
$link_univ = '<a href='.$link.'>';
$transform = $link_univ.'<font color="#0E46FF" size="20" face="comic sans ms"><b>'.$textarea.'</b></font></a>';
echo $transform;
}
else
{
$transform = '<font color="#0E46FF" size="20" face="comic sans ms"><b>'.$textarea.'</b></font></a>';
echo $transform;
}
}
?>