input data doesnt compare with the text data
Posted: Thu Jan 07, 2010 10:00 pm
the code gives the message as "no match" even when there is a match
below is the xml file it checks the data in.
Code: Select all
<?php
$myheading="";
$mylink="";
$mybody="";
if (isset($_POST['submit'])) {
$mylink = $_POST["link"];
$myheading = $_POST["heading"];
$mybody = '<image heading="'.$myheading.'" links="'.$mylink.'"/>';
$file = "article.xml";
$handle = fopen($file, "r");
if ($handle) {
while (!feof($handle)) {
$temp = fgets($handle);
if ($temp==$mybody)
{
echo "match";
}
else
{ echo "no match";}
}
fclose($handle);
}
}
?>
<table id="structure">
<tr>
<td id="page">
<h2>delete data</h2>
<form action="delete5.php" method="post">
<table>
<tr>
<td>heading</td>
<td><input type="text" name="heading" maxlength="23" value="<?php echo htmlentities($myheading); ?>" /></td>
</tr>
<tr>
<td>links</td>
<td><input type="text" name="link" maxlength="40" value="<?php echo htmlentities($mylink); ?>" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="delete data" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
Code: Select all
<gallery>
<image heading="roses" links="roses"/>
<image heading="grapes" links="grapes"/>
</gallery>