Hi Friends
I'm using xamp to develop a php application. My problem is that everytime I call a variable that sometimes happens to not have a value, I get an error that says it's an undefined index.
This is my source code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Find and Replace</title>
</head>
<body>
<center><h1 style="color:#C6F">Find And Replace</h1>
<form action="findandrep.php" method="post">
Find: <input type="text" name="text" />
Replace: <input type="text" name="text1" />
<br />
<textarea name="text2" rows="15" cols="30"> </textarea>
<br/>
<br/>
<input type="submit" name = "submit" value = "Go" />
</form>
</center>
</body>
</html>
<?php
print_r;
$Find=$_POST["text"];
$_Replace=$_POST["text1"];
$string=$_POST["text2"];
for($i=0; $i<strlen($string) ; $i++){
$text=substr($text,$i,1);
if($text == $Find){
$text=$_Replace;
echo $text;
}
}
?>
Notice: Undefined index: text in C:\xampp\htdocs\myphpsite\String Function\findandrep.php on line 25
Notice: Undefined index: text1 in C:\xampp\htdocs\myphpsite\String Function\findandrep.php on line 26
Notice: Undefined index: text2 in C:\xampp\htdocs\myphpsite\String Function\findandrep.php on line 27