Jump to content

Recommended Posts

Hello everyone.

 

I've got a problem with a webform that uses PHP. I'm sure it's very obvious but can't find the problem.

 

What I want to do is basically enter a numerical value into a field on a form, which then sends the value to a mysql database, requesting a record linked to that value. A window opens with the record requested.

 

The problem I am getting is that the value is not being taken properly when I hit the 'submit' button, but will take the previous value that was submitted a previous query.

 

For example, I want to retrieve a record that has an 'id' of 1. I enter '1' into the field (the id of the field is 'identry'), I get an error. The error basically signifies staes that I have not entered a value into the 'id' field, for some reason. Then I access the search field again, enter a value of '2', and hit the 'submit'. I then get a result that it has just accessed record with 'id' of '1' (the previous query!!!!)

 

Any ideas??

 

This is my code for the form.....

 

<form id="form1" name="form1" method="post" >
					 <table width="400" border="0">
		 <tr>
			 <td width = "150" ><div align="right">HPOV reference </div></td>

			 <td width = "150"><label>
			 <input name= "identry" type="text" id="identry" />
			 </label></td>
			 <td width = "100"><label>
			 <div align="left">
			 <input name="Submit" type="submit" onclick="MM_openBrWindow('HPOVwindow.php?id=<?php echo $_POST['identry']; ?>','','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=1000,height=1000')" />
			 </div>
			 </label></td>
		 </tr>
		 </table>
	 </div>
	 </form>

 

Apologies if this is in the wrong place.

 

Thank you for reading.

 

Chris

Link to comment
https://forums.phpfreaks.com/topic/269724-problem-with-web-form/
Share on other sites

Here is the full code for the page

<?php require_once('../Connections/HPOV.php'); ?>
<?php
mysql_select_db($database_HPOV, $HPOV);
$query_rsjob_id = "SELECT distinct id FROM jobs";
$rsjob_id = mysql_query($query_rsjob_id, $HPOV) or die(mysql_error());
$row_rsjob_id = mysql_fetch_assoc($rsjob_id);
$totalRows_rsjob_id = mysql_num_rows($rsjob_id);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"[url="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%22>"]http://www.w3.org/TR...nsitional.dtd">[/url]
<html xmlns="[url="http://www.w3.org/1999/xhtml%22>"]http://www.w3.org/1999/xhtml">[/url]
<head>
<title>Outer Space - Free Web Template by WebTemplateOcean.com</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/Javascript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
 window.open(theURL,winName,features);
}
//-->
</script>
</head>
<body>

<div id="page">		
	<div id="header"> <a href="#"><img id="logo" src="images/logo.jpg" alt="" /></a>
		<h1><a href="#">HP Openview Listings</a></h1>
  </div>
	<div id="menu">
		<ul>
<li><a href="#">Search</a></li>
<li><a href="fulllist.php">Full List</a></li>
<li><a href="#">Help</a></li>
<li><a href="#">Contact</a></li>
</ul>
	</div>				
	<div id="main"><div id="main2">
	  <p>
		<!-- content --></p>



	  <form id="form1" name="form1" method="post" >
		<div align="center">
		  <table width="397" border="0">
			<tr>
			  <td width = "150" height="24" ><div align="right">HPOV reference </div></td>

			  <td width = "150"><label>
			  <input name= "identry" type="text" id="identry" />
			  </label></td>
			  <td width = "100"><label>
				<input name="Submit" type="submit" onclick="MM_openBrWindow('HPOVwindow.php?id=<?php echo $_POST['identry']; ?>','','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=1000,height=1000')" />
			  </label></td>
			</tr>
		  </table>
		</div>
	  </form>
	  <p> </p>
	  <p> </p>
	  <p> </p>
	  <p> </p>
	  <div class="clearing"> </div>
	</div>
	</div><!-- main --><!-- main2 -->
	<div id="footer">

	</div>

 

Hope this helps.

Edited by chrisboydell71

It submits to itself, so the action attribute shouldn't be necessary (with most browsers), although it doesn't comply with the specs. The best way to handle it would be to use an empty action attribute, e.g., action=""

Edited by Pikachu2000
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.