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:

if (isset($_POST['name'])) $name = $_POST ['name'];
else $name = "(Not entered)";
echo <<<_END
	<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"/>
// [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>";
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());
 //[B]header("Location:http://localhost/wsru/results.html");// placed here 'header'  changes page to results.html[/B]
echo "No data found for your request. Try a different query.";
//[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?

5 Years
Discussion Span
Last Post by moneeshot

html pages can't display php unless you stipulate this in .htaccess. Change .html to .php and it should work (if your code is OK).


html pages can't display php unless you stipulate this in .htaccess. Change .html to .php and it should work (if your code is OK).

I just tested code blow and it didn't work!

<head> </head>
<?php echo "It works!"; ?>

adding this line in htaccess file worked:

AddType application/x-httpd-php .html .htm

Thank you for the advice. My ISP is not happy for .htaccess to be amended.
However, I have incorporated html coding for my website's logo between
echo<<<_END and echo _END: in the .php code
and this produces an acceptable page display above the results tables.


Thank you ardav for your suggestion, but I have struggled to make it work. There must be more to it than that - beyond what I have learned so far.


the test code you posted above is to simple to fail. change the extension!
I'm curious, why would you not change the extension? you are trying to force the html page to do something it was never meant to do?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.