Undefined Index

Alles, was PHP betrifft, kann hier besprochen werden.

Undefined Index

Postby Mehak » 02. July 2013 17:06

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
Mehak
 
Posts: 6
Joined: 30. June 2013 13:36
Operating System: windows 7

Re: Undefined Index

Postby Altrea » 02. July 2013 17:42

Hi Mehak,

This way please:
viewtopic.php?f=16&t=56672&p=211012#p211012

Best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to PHP

Who is online

Users browsing this forum: No registered users and 10 guests