Jump to content

Recommended Posts

At the very bottom of my php script you'll see a html link just before the </html>: <a href="main.php">Return To Main</a>. For some reason this is coming up on the page at the top of the page above the php generated table

 

How wierd?

 

<?php
session_start();
include("config.php");
include("inc.php");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Search Employee</title>
</head>

<div id="main">
<a name="TemplateInfo"></a>
<h1>Search Employee</h1>

<?php
if (isset($_POST['submit'])) {
// Form Is Submitted

  // Validate Search Query
    if ($_POST['searchquery'] != "") {   
      $searchquery = filter_var($_POST['searchquery'], FILTER_SANITIZE_STRING);   
      if ($searchquery == "") {   
        $errors .= 'Please enter a valid search query.<br/><br/>';   
      }   
    } else {   
      $errors .= 'Please enter a search query.<br/>';   
    }

  // Validate Search Type
    if ($_POST['searchtype'] != "") {   
      $searchtype = filter_var($_POST['searchtype'], FILTER_SANITIZE_STRING);   
      if ($searchtype == "") {   
        $errors .= 'Please enter a valid search type.<br/><br/>';   
      }   
    } else {   
      $errors .= 'Please enter a search type.<br/>';   
    }

echo $searchtype;
echo $searchquery;			

	// Check For Errors
		if (!$errors) {
$results = mysql_query("SELECT * FROM staffdb WHERE $searchtype LIKE '$searchquery'");

$numrows = mysql_num_rows($results);
	if ($numrows == 0)
	  {
	echo "<p>Sorry, your search returned no results</p>";
	  } else {

	echo'<table><TR>
	<TD>Staff ID</TD>
	<TD>Forname</TD>
	<TD>Surname</TD>
	<TD>Department</TD>
	<TD>Vehicle Reg</TD>
	<TD>Locker ID</TD>
	<TD>Locker Key</TD>
	</TR>';

		while ($row = mysql_fetch_array($results)) {
		echo "<TR>
		<TD><a href=\"viewemployee.php?id={$row['staffid']}\">{$row['staffid']}</a></TD>
		<TD>{$row['fname']}</TD>
		<TD>{$row['sname']}</TD>
		<TD>{$row['dept']}</TD>
		<TD>{$row['vehiclereg']}</TD>
		<TD>{$row['lockerid']}</TD>
		<TD>{$row['lockerkey']}</TD>
		</TR>";
		}
	}

} else {
echo '<div style="color: red">' . $errors . '<br/></div>';
}

} else {
// No Form Is Submitted
?>

<form name="searchemployee" action="searchemployee.php" method="post">

<select name="searchtype">
<option value="fname">Forename</option>
<option value="sname">Surname</option>
<option value="dept">Department</option>
<option value="vehiclereg">Vehicle Reg</option>
<option value="lockerid">Locker ID</option>
<option value="lockerkey">Locker Key</option>
</select>

<br/>
Search Query*<br /><input type="text" name="searchquery" size="35" /><br />
<input type="submit" name="submit" value="Search Employee" />
</form>

<?php
}
?>

</div>

<a href="main.php">Return To Main</a>

</body>
</html>

 

The HTML output...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Search Employee</title>
</head>

<div id="main">
<a name="TemplateInfo"></a>
<h1>Search Employee</h1>

fnametest<table><TR>
	<TD>Staff ID</TD>
	<TD>Forname</TD>
	<TD>Surname</TD>
	<TD>Department</TD>
	<TD>Vehicle Reg</TD>
	<TD>Locker ID</TD>
	<TD>Locker Key</TD>
	</TR><TR>
		<TD><a href="viewemployee.php?id=0">0</a></TD>
		<TD>test</TD>
		<TD>test</TD>
		<TD></TD>
		<TD>dfgdf</TD>
		<TD>2345234</TD>
		<TD>345</TD>
		</TR><TR>
		<TD><a href="viewemployee.php?id=0">0</a></TD>
		<TD>test</TD>
		<TD>test</TD>
		<TD></TD>
		<TD>test</TD>
		<TD>987</TD>
		<TD>9879</TD>
		</TR>
</div>

<a href="main.php">Return To Main</a>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/184212-html-in-wrong-place/
Share on other sites

The missing </table> tag is what is causing your most immediate problem. But if you are trying for a XHTML strict doctype, you need to work on the missing <body> tag, the UPPER-CASE tags, and everything else in the HTML output that is resulting in 28 Errors and 2 warning(s) at the w3.org validator.

Link to comment
https://forums.phpfreaks.com/topic/184212-html-in-wrong-place/#findComment-972579
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.