I am trying to send results to a new page.The results are fine.
i.e. once the form is submitted and all input validated I want the result to appear on the results.html page.
I have been able to display the results.html but no data displayed.
I attach some relevant code:
<?php
if (isset($_POST['name'])) $name = $_POST ['name'];
else $name = "(Not entered)";
echo <<<_END
<html>
<body>
<form method="post" action="working.php">
Enter Ship Name
<input type="text" name="name" size="25" maxlength ="35" />
<input type="image" name="submit" src="newindex_files/cooltext497898955.png" onmouseover="this.src='images/cooltext497898955MouseOver.png';" onmouseout="this.src='images/cooltext497898955.png';" alt="search"/>
</form>
</body>
</html>
_END;
// [B]placed here 'header' changes page to results.html, but no data displayed[/B]
if($name == "")
{
echo "<p><font color='red' size='4px'>You have not entered a name</font></p>";
exit;
}
else
{
echo "<p><font color='blue' size='4px'>You searched for: $name</font></p>";
}
require_once 'dbconnect.php';
// [B]placed here 'header' changes page to results.html but no data displayed[/B]
$query = "SELECT * FROM allnames WHERE name1 LIKE '$name%' OR name2 LIKE '$name%' OR name3 LIKE '$name%' OR name4 LIKE '$name%' OR name5 LIKE '$name%' OR name6 LIKE '$name%' OR name7 LIKE '$name%' OR name8 LIKE '$name%' OR name9 LIKE '$name%' OR name10 LIKE '$name%' OR name11 LIKE '$name%' OR name12 LIKE '$name%'";
$result = mysql_query($query);
if (!$result) die ("Database access failed: " . mysql_error());
$rows=mysql_num_rows($result);
//[B]header("Location:http://localhost/wsru/results.html");// placed here 'header' changes page to results.html[/B]
if(mysql_num_rows($result)==0)
{
echo "No data found for your request. Try a different query.";
exit;
//[B]placed beyond here here 'header' does not work at all.Only 'working.php' details shown.[/B]
}
for ($j=0; $j < $rows ; ++$j)
{
$row =mysql_fetch_row($result);
Am I on the right lines, or is a there a CORRECT way?