slip22.html-
<html>
<body>
<form action ="slip22.php" method="get">
<center> <table>
<tr> <td>enter the first string: </td> <td> <input type="text" name="str1"> </td> </tr>
<tr> <td>enter the second string: </td> <td> <input type="text" name="str2"> </td> </tr>
<tr> <td>enter string to replace: </td> <td> <input type="text" name="str3"> </td> </tr>
<tr> <td>occurences </td> <td> <input type="radio" name="ch" value=1> </td>
<td>replace </td> <td> <input type="radio" name="ch" value=2> </td> </tr>
<tr> <td> </td> <td> <input type="submit" value="next"> </td> </tr>
</table>
</body>
</html>
slip22.php-
<?php
$str1=$_GET['str1'];
$str2=$_GET['str2'];
$str3=$_GET['str3'];
$ch=$_GET['ch'];
echo "first string is =".$str1."<br><br>";
echo "second string is =".$str2."<br><br>";
echo "third string is =".$str3."<br><br>";
if(strlen($str1)>strlen($str2))
{
switch($ch)
{
case 1:$pos=strpos($str1,$str2);
if($pos!=0)
echo "string '$str2' not present in start of '$str1'.<br>";
echo "string '$str2' present in start of '$str1'.<br>";
break;
case 2:$str4=str_replace($str2,$str3,$str1);
echo "after replacing string $str4";
break;
}
}
else
{
switch($ch)
{
case 1:$pos=strpos($str2);
echo "after repalcing sring $str;
break;
}
}
?>