<form> tags keep disappearing

Hi,
I have a small search button on a website which does a really basic search on the MySQL database. However, the form tags keep disappearing. This seems really strange. The search button should look like this:

<form name="form" action="catalogue.php" method="get">
<input type="text" name="qsearch" size="15"/>
<br />
<input type="submit" name="Submit" value="Search" width="6" size="6" height="6"/>
</form>

However, sometimes when the page loads the <form> tags are not generated, and so it ends up looking like this:

<input type="text" name="qsearch" size="15"/>
<br />
<input type="submit" name="Submit" value="Search" width="6" size="6" height="6"/>

I have never known something like this to happen before so don’t even know where to start in finding the problem. Has anyone had any experience of this before or know how to fix this problem???

Thanks
Russ

Very odd indeed. Is the form hard-coded or inserted via some kind of script?

Well the page is in .php and I am using a require_once include as it features on every page.

The basic structure of the document is:


<html>
<head></head>
<body>
<center>
<div class="container">
<div class="content">

Then the page with this form is included, and has structure of:


<div class="right">
<div class="block">
<form>
</form>
</div>
</div>

And then all the other tags close at the bottom of the page.

Any ideas on this? It is so strange. If I open the page directly, so not as an include, using its actual address, the <form> tags appear as normal but when looking at it once its been included sometimes the <form> tags are there and sometimes they’re not, and there doesn’t seem to be any rhyme or reason to why this is!

Have you enabled error reporting so you an see what issues are occurring?


error_reporting(E_ALL);

Additionally, what does your error log have to say?
http://eregie.premier-ministre.gouv.fr/manual/logs.html

I have error_reporting on but there are not any errors showing. Besides, I believe that the problem can’t be PHP related as although the pages are in php and the form is part of an include, all of the actual tags are written in PHP and I am using no PHP functions for this form.

To see this in action. The code is on two different pages.

http://www.bramcotebulbs.com

The really strange thing is how they sometimes seem to work perfectly and other times not at all. For instance, the first time the page is visited and a search is done using the box on the right, quite often the script will work and the search will be done. However, if you try and do a search again on the next page, pretty much everytime I have tried it it will not work, and if you look at that script you will see that the <form> tags have disappeared. Plus, the Bramcote Bulbs site seems to work the majority of the time, with just occasionally this happening. I have looked at both scripts in minute detail and they are identical so I just can’t work out how this is happening. Any help would be so much appreciated!!!

There is an incorrect assumption that you are making in your PHP code relating to the form.

I would suggest that you either post the PHP code that relates to it, or ask someone to kindly take a personal look at it for you.

I don’t know much about PHP, but I just use simple includes that never fail me. Could you just try include instead of require_once? Maybe for some reason it is not including a second time because already used?? I know this shouldn’t happen across different pages, but… :rolleyes:

I got it do that with a NULL search value if that is any help? After that it decided to do it every time it basically has to be the PHP. Yes, without looking at the PHP we don’t stand much chance.

I tried using include instead of require_once and still get the same results.

Well, the only actual PHP coding other than the includes is for the catalogue page and for showing each item. This starts like this:

include 'library/config.php';
include 'library/opendb.php';

$rowsPerPage = 5;
$pageNum = 1;

if(isset($_GET['page']))
{
   $pageNum = $_GET['page'];
}

$offset = ($pageNum - 1) * $rowsPerPage;

$self = $_SERVER['PHP_SELF'];

$catalogue_query  = "Product_ID, New_Release, FrontPage_NRelease, Genus, Division, Common_Name, Special_Offer, Description, Price, SO_Price, Description_Code, In_Stock, pricing, ImageName, multi1a, multi1b, multi2a, multi2b, multi3a, multi3b, multi4a, multi4b FROM products";
if (!empty($_GET['qsearch'])) {
$search = mysql_real_escape_string( trim($_GET['qsearch']) );
$catalogue_query .=" WHERE Common_Name LIKE '%$search%' OR Genus LIKE '%$search%'";
}

And then has a couple more IF clauses and then the while clause which contains the code for each catalogue item. The actual form and all the coding on the right-hand side of the page, except for the Shopping Basket, which is generated by PHP, is written in HTML.

I also tried getting rid of all the includes by pasting all my code into the one document. I have tried this on the index.php and catalogue.php and it made no difference. After doing this it meant that the only php code on my page was the code to load up my database configurations, code to generate the items in the New Releases box on the left, code used to generate the items in the catalogue and also the shopping basket on the right.

Generally I am testing this on the www.showglads.com site as this is the one that has the biggest problem. It seems that it is okay to search on the Index page but as soon as the catalogue.php page loads up the <form> tags have already disappeared and it’s impossible to do another search. By getting rid of these ‘include’ statements it means that the <form> is in no possible way being generated by PHP, it is all in HTML and this is why this thing is so confusing. I’ve never know anything like this to happen before!!!

You don’t happen to have another <form> tag somewhere before that? If you do, the second <form> tag will be ignored (you can’t nest forms).

I tried to replicate the error but the form tags always showed up for me so no help there.

The PHP code is for getting info from the db. What exactly does the code involved with

<div class="block">
<br />
Search the catalogue for a keyword.
<form name="form" action="catalogue.php" method="get">
<input type="text" name="qsearch" size="15"/>
<br />
<input type="submit" name="Submit" value="Search" width="6" size="6" height="6"/>
</form>
</div>

look like? Thats all in a hard-coded include file? If so, what does the code at and before the include() line look like? Everything except only the form tags alone still gets shown OK?

There is this other form tag, that has no matching closing tag.


<form action="" method="post" name="form2">

That may-well be causing the symptoms that you’re experiencing.

If I can clarify, the form tags still appear in the source code. They do not appear when you inspect the input element.

This means that there is something else in the code causing the DOM parsing to fail for the form tag.

That other something, will be the lonesome <form> tag that appears before the form that we’re interested in.

I don’t see that anywhere. But that definately could cause a problem. Need to see the PHP code involved with the actual tags.

You don’t see it on the main page at http://www.showglads.com/

Where you do see it is after performing a search, for example:

It’s within the search results. Below the item heading and above the item description.


<h4>WHITE ICE (Jones 1987)</h4> 
<form action="" method="post" name="form2"> 
<br/> 
<p>Still in the Top Ten American cultivars, this great exhibition variety...

Yep that’s the problem. The browser ignores the second form tag. The first form needs to go away or be closed properly before the second form.

On the caterlogue page you have 6 opening form tags and just 1 closing form tag. You need to remove the 5 opening form tags that are not needed.

Those 5 form tags would be due to the 5 results showing on your search results page.

It is the template for the search results that needs to be corrected here.

Ahh, I tried searches for “red” and then “white” and I see the other “form2” tags. They are paired with closing tags, but the tags are not nested correctly.

<div class="catalogue">
	<div class="catalogue_left" align="center">
		<img height="82" width="122" src="images/no_image-122x82.jpg" />
		<br />
		<p>Hover over image to enlarge</p>
	</div>
	<div class="catalogue_right">
		<h4>CHERRY BERRY (Fredericks 2007)</h4>
		<form action="" method="post" name="form2">
		<br/>
			<p>A very attractive formal glad, rose red with a deeper red throat. Opens 7 of 22 buds on a 22" flower head. Florets are 3" in size with medium ruffling. Red cards at BGS Midland show.	</p>
			<div style='float:right;'>
				<a href="basket.php?action=add&id=227"><img height="17" width="79" border="0" src="images/addtobasket.jpg" /></a>
			</form>
		</div>
		<h5>2.50 each</h5>
	</div>
</div>

I don’t see why any form tags are needed there anyway, the links are GET.