Hi all...
Am hoping someone can show me what I have done wrong here. I had a form with two select lists and one set of checkboxes that needed to get completed.. all well and good and it worked fine but I have eveolved the system and added a condition to only display those items if a condition was true. The resulting form had to show the select lists and checkboxes as well as display the already selected item in the database and although the form is displaying correctly against the conditon and the select lsits and checkbox items are displaying when they are supposed to the problem I cannot solve is that when making slections form the slect lists and checkboxes and submitting the form is submitting ok but it is inseritn ghe words "selected" or "checked" into the database together with the slected items like so for the checkboxeslcheckedfcheckedschecked and queenselected for the select lists.
My code looks like this

<td>&nbsp;</td>
                </tr>
                <?php if( $tour['accomm'] == "Yes" || $catid !="") {
				 echo "
				 <tr>
				 <td><b> Room Class</b></td>
                 	 <td> <select name=\"class\">
                      <option value=\"stateroom"; if($cat['class'] == "stateroom"); echo "selected\"; >Stateroom</option>
                      <option value=\"suite"; if($cat['class'] == "suite"); echo "selected\" >Suite</option>
                      <option value=\"superior"; if($cat['class'] == "superior"); echo "selected\" >Superior</option>
                      <option value=\"first class"; if($cat['class'] == "first class"); echo "selected\" >First Class</option>
                      <option value=\"standard"; if($cat['class'] == "standard"); echo "selected\" >Standard</option>
                      <option value=\"budget"; if($cat['class'] == "budget"); echo "selected\" >Budget</option>
                      <option value=\"dormitory"; if($cat['class'] == "dormitory"); echo "selected\" >Dormitory</option>
                      <option value=\"caravan"; if($cat['class'] == "caravan"); echo "selected\" >Caravan</option> 
                      <option vlue=\"Trailer"; if($cat['class'] == "trailer"); echo "selected\" >Trailer</option>
                      <option vlue=\"Tent"; if($cat['class'] == "tent"); echo "selected\" >Tent</option>
                    </select>
					</td>
                </tr>
						
                <tr> 
				
                <td><b>Type of Bed(s)</b></td>
                  <td> <select name=\"bedtype\">
                      <option value=\"queen"; if($cat['bedtype'] == "queen"); echo "selected\"; >Queen</option>
                      <option value=\"king"; if($cat['bedtype'] == "king"); echo "selected\"; >King</option>
                      <option value=\"double"; if($cat['bedtype'] == "double"); echo "selected\"; >Double</option>
                      <option value=\"three-quarter"; if($cat['bedtype'] == "three-quarter"); echo "selected\"; >Three-Quarter</option>
                      <option value=\"single"; if($cat['bedtype'] == "single"); echo "selected\"; >Single</option>
                      <option value=\"bunk"; if($cat['bedtype'] == "bunk"); echo "selected\"; >Bunk</option>
                      <option value=\"berth"; if($cat['bedtype'] == "berth"); echo "selected\"; >Berth</option>
                      <option value=\"mixed"; if($cat['bedtype'] == "mixed"); echo "selected\"; >Mixed</option>
                    </select></td>
                </tr>
                </table>
				
				<br>
              <b>HOTEL FACILITIES</b><br>
              <table width=\"40%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
                <tr> 
                  <td align=\"right\"><input type=\"checkbox\" name=\"fac_tel\" value=\"l"; if( strpos($cat['facilities'], "l") > -1); echo "checked\" ></td>
                  <td align=\"center\"><img src=\"../images/icons/ico_phone.gif\" width=\"26\" height=\"27\"></td>
                  <td align=\"left\">Telephone</td>
                </tr>
                <tr> 
                  <td align=\"right\"><input type=\"checkbox\" name=\"fac_safe\" value=\"f"; if( strpos($cat['facilities'], "f") > -1); echo "checked\" ></td>
                  <td align=\"center\"><img src=\"../images/icons/ico_safe.gif\" width=\"26\" height=\"27\"></td>
                  <td align=\"left\">Safe</td>
                </tr>
                <tr> 
                  <td align=\"right\"><input type=\"checkbox\" name=\"fac_smoke\" value=\"s"; if( strpos($cat['facilities'], "s") > -1); echo "checked\" ></td>
                  <td align=\"center\"><img src=\"../images/icons/ico_smoke.gif\" width=\"26\" height=\"27\"></td>
                  <td align=\"left\">Smoking Permitted</td>
                </tr>
                <tr> 
                  <td align=\"right\"><input type=\"checkbox\" name=\"fac_tv\" value=\"m"; if( strpos($cat['facilities'], "t") > -1); echo "checked\" ></td>
                  <td align=\"center\"><img src=\"../images/icons/ico_tv_sat.gif\" width=\"26\" height=\"27\"></div></td>
                  <td align=\"left\">Satelite Television</td>
                </tr>
                <tr>
                  <td align=\"right\"><input type=\"checkbox\" name=\"fac_pets\" value=\"e"; if( strpos($cat['facilities'], "e") > -1); echo "checked\" ></td>
                  <td align=\"center\"><img src=\"../images/icons/ico_pets.gif\" width=\"26\" height=\"27\"></div></td>
                  <td align=\"left\">No Pets</td>
                </tr>
                <tr>
                  <td align=\"right\"><input type=\"checkbox\" name=\"fac_park\" value=\"c"; if( strpos($cat['facilities'], "c") > -1); echo "checked\" ></td>
                  <td align=\"center\"><img src=\"../images/icons/ico_cover_park.gif\" width=\"26\" height=\"27\"></td>
                  <td align=\"left\">Covered Parking</td>
                </tr>
                <tr>
                  <td align=\"right\"><input type=\"checkbox\" name=\"fac_towels\" value=\"o"; if( strpos($cat['facilities'], "o") > -1); echo "checked\" ></td>
                  <td align=\"center\"><img src=\"../images/icons/ico_towels.gif\" width=\"26\" height=\"27\"></td>
                  <td align=\"left\">Towels Supplied</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td align=\"right\">&nbsp;</td>
                </tr>";
				}
				?>

I have tried echoing each line but that dod not display anything and it also seemed a rather long way around.. can anyone point me right?

Recommended Answers

All 8 Replies

Member Avatar for diafol

Suggestion:
Use some full stops in your explanation - I got lost in the second sentence - all 102 words of it!
Also your code is not indented to a format that can be easily read. The mixed html/php code is extremely hard to maintain.Perhaps if you create your variables to begin with (ifs) and then echo them in the correct place.

Hi Ardav and thanks for the reply. I apologise for my post which is a mess.. let me try again..

Am hoping someone can show me what I have done wrong here. I had a form with two select lists and one set of checkboxes that needed to get completed.. That worked fine but I have now evolved the system and added a condition to only display those items if a condition was true.
The resulting form had to show the select lists and checkboxes as well as display the already entered item that was previously added to the database.

The form is displaying correctly against the set conditon.

The problem I cannot solve is that when making selections from the select lists and/or checkboxes and clicking "submit" the form is submitting ok but it is inserting the words "selected" or "checked" into the database together with the selected item vslue like so:- for the checkboxes "lcheckedfcheckedschecked" and "queenselected" for the select lists.

My code looks like this

<td>&nbsp;</td>
</tr>
<?php if( $tour['accomm'] == "Yes" || $catid !="") {
echo "
<tr>
<td><b> Room Class</b></td>
<td> <select name=\"class\">
<option value=\"stateroom"; if($cat['class'] == "stateroom"); echo "selected\"; >Stateroom</option>
<option value=\"suite"; if($cat['class'] == "suite"); echo "selected\" >Suite</option>
<option value=\"superior"; if($cat['class'] == "superior"); echo "selected\" >Superior</option>
<option value=\"first class"; if($cat['class'] == "first class"); echo "selected\" >First Class</option>
<option value=\"standard"; if($cat['class'] == "standard"); echo "selected\" >Standard</option>
<option value=\"budget"; if($cat['class'] == "budget"); echo "selected\" >Budget</option>
<option value=\"dormitory"; if($cat['class'] == "dormitory"); echo "selected\" >Dormitory</option>
<option value=\"caravan"; if($cat['class'] == "caravan"); echo "selected\" >Caravan</option>
<option vlue=\"Trailer"; if($cat['class'] == "trailer"); echo "selected\" >Trailer</option>
<option vlue=\"Tent"; if($cat['class'] == "tent"); echo "selected\" >Tent</option>
</select>
</td>
</tr>
<tr>
<td><b>Type of Bed(s)</b></td>
<td> <select name=\"bedtype\">
<option value=\"queen"; if($cat['bedtype'] == "queen"); echo "selected\"; >Queen</option>
<option value=\"king"; if($cat['bedtype'] == "king"); echo "selected\"; >King</option>
<option value=\"double"; if($cat['bedtype'] == "double"); echo "selected\"; >Double</option>
<option value=\"three-quarter"; if($cat['bedtype'] == "three-quarter"); echo "selected\"; >Three-Quarter</option>
<option value=\"single"; if($cat['bedtype'] == "single"); echo "selected\"; >Single</option>
<option value=\"bunk"; if($cat['bedtype'] == "bunk"); echo "selected\"; >Bunk</option>
<option value=\"berth"; if($cat['bedtype'] == "berth"); echo "selected\"; >Berth</option>
<option value=\"mixed"; if($cat['bedtype'] == "mixed"); echo "selected\"; >Mixed</option>
</select></td>
</tr>
</table>
     
<br>
<b>HOTEL FACILITIES</b><br>
<table width=\"40%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td align=\"right\"><input type=\"checkbox\" name=\"fac_tel\" value=\"l"; if( strpos($cat['facilities'], "l") > -1); echo "checked\" ></td>
<td align=\"center\"><img src=\"../images/icons/ico_phone.gif\" width=\"26\" height=\"27\"></td>
<td align=\"left\">Telephone</td>
</tr>
<tr>
<td align=\"right\"><input type=\"checkbox\" name=\"fac_safe\" value=\"f"; if( strpos($cat['facilities'], "f") > -1); echo "checked\" ></td>
<td align=\"center\"><img src=\"../images/icons/ico_safe.gif\" width=\"26\" height=\"27\"></td>
<td align=\"left\">Safe</td>
</tr>
<tr>
<td align=\"right\"><input type=\"checkbox\" name=\"fac_smoke\" value=\"s"; if( strpos($cat['facilities'], "s") > -1); echo "checked\" ></td>
<td align=\"center\"><img src=\"../images/icons/ico_smoke.gif\" width=\"26\" height=\"27\"></td>
<td align=\"left\">Smoking Permitted</td>
</tr>
<tr>
<td align=\"right\"><input type=\"checkbox\" name=\"fac_tv\" value=\"m"; if( strpos($cat['facilities'], "t") > -1); echo "checked\" ></td>
<td align=\"center\"><img src=\"../images/icons/ico_tv_sat.gif\" width=\"26\" height=\"27\"></div></td>
<td align=\"left\">Satelite Television</td>
</tr>
<tr>
<td align=\"right\"><input type=\"checkbox\" name=\"fac_pets\" value=\"e"; if( strpos($cat['facilities'], "e") > -1); echo "checked\" ></td>
<td align=\"center\"><img src=\"../images/icons/ico_pets.gif\" width=\"26\" height=\"27\"></div></td>
<td align=\"left\">No Pets</td>
</tr>
<tr>
<td align=\"right\"><input type=\"checkbox\" name=\"fac_park\" value=\"c"; if( strpos($cat['facilities'], "c") > -1); echo "checked\" ></td>
<td align=\"center\"><img src=\"../images/icons/ico_cover_park.gif\" width=\"26\" height=\"27\"></td>
<td align=\"left\">Covered Parking</td>
</tr>
<tr>
<td align=\"right\"><input type=\"checkbox\" name=\"fac_towels\" value=\"o"; if( strpos($cat['facilities'], "o") > -1); echo "checked\" ></td>
<td align=\"center\"><img src=\"../images/icons/ico_towels.gif\" width=\"26\" height=\"27\"></td>
<td align=\"left\">Towels Supplied</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align=\"right\">&nbsp;</td>
</tr>";
}
?>

I have tried echoing each line but that dod not display anything and it also seemed a rather long way around.. can anyone point me right?

Member Avatar for diafol

OK it's a mess:

try this - perhaps a bit messier with the html generation, but I hope you get the idea.

<?php
if( $tour['accomm'] == "Yes" || $catid !="") {
	
	function getHTML($r,$check){
		$out = "";
		foreach($r as $item){
			$sel = ($check == $item) ? ' selected = "selected"' : '';
			$out .= "\n\t\t\t<option value=\"" . strtolower($item) . "\"$sel>$item</option>";	
		}
		return $out;
	}
	
	function getTable($r,$c){
		$out = "";
		foreach($r as $item){
			$sel = (strpos($c,$item[1]) > -1) ? ' checked = "checked"' : '';
			$out .= "\n\t\t<tr>\n\t\t\t<td align=\"right\"><input type=\"checkbox\" name=\"fac_{$item[0]}\" value=\"{$item[1]}\"$sel></td>\n\t\t\t<td align=\"center\"><img src=\"../images/icons/{$item[2]}\" width=\"26\" height=\"27\"></td>\n\t\t\t<td align=\"left\">{$item[3]}</td>\n\t\t</tr>";
		}
		return $out;
	}
	
	$ops1 = array("Stateroom","Suite","Superior","First Class","Standard","Budget","Dormitory","Caravan","Trailer","Tent");
	$ops2 = array("Queen","King","Double","Three-Quarter","Single","Bunk","Berth","Mixed");
	$checks = array(
		//name|value|image|label
		array('tel','l','ico_phone.gif','Telephone'),
		array('safe','f','ico_safe.gif','Safe'),
		array('smoke','s','ico_smoke.gif','Smoking Permitted'),
		array('tv','t','ico_tv_sat.gif','Satellite Television'),
		array('pets','e','ico_pets.gif','No Pets'),
		array('park','c','ico_cover_park.gif','Covered Parking'),
		array('towels','o','ico_towels.gif','Towels Supplied')
	);
	
	$cat['facilities'] = "t";//get this in the usual way
	
	$c1 = "First Class"; //get these from global vars??
	$c2 = "Single";
	$c3 = $cat['facilities']; //for convenience

?>
<table>
    <tr>
        <td>
            <strong>Room Class</strong>
        </td>
        <td>
            <select name="class">
                <?php echo getHTML($ops1,$c1);?>
            </select>
        </td>
    </tr>
    <tr>
        <td>
            <strong>Type of Bed(s)</strong>
        </td>
        <td>
            <select name="bedtype">
                 <?php echo getHTML($ops2,$c2);?>
            </select>
        </td>
	</tr>
</table>
     
    <br>
    <b>HOTEL FACILITIES</b><br>
    <table width="40%" border="0" cellspacing="0" cellpadding="0">
    	<?php echo getTable($checks,$c3);?>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td align="right">&nbsp;</td>
</tr>
</table>
<?php
}
?>

There were a few typos and I'm not sure about:

<td align=\"right\"><input type=\"checkbox\" name=\"fac_tv\" value=\"m"; if( strpos($cat['facilities'], "t") > -1); echo "checked\" ></td>

I took this to be value="t"

Also the:

<option vlue=\"Trailer"; if($cat['class'] == "trailer"); echo "selected\" >Trailer</option>
<option vlue=\"Tent"; if($cat['class'] == "tent"); echo "selected\" >Tent</option>

Notice 'vlue' instead of 'value'. Anyway, the code I supplied *should* send the correct data.

Many thanks Ardav... Appreciate you pointing out the typos.. that comes from em fiddling too much :)

You code does the trick on inserting the correct data now and thanks for that. It is completely different to what I was attempting so have learnt something new.

It does not however display the items that are already in the database so will try and sort that out and see how far I get :)
Thanks once again..

Member Avatar for diafol

It does not however display the items that are already in the database so will try and sort that out and see how far I get
Thanks once again..

You need help with that? Show your code for the php/SQL

Hi Ardav.
Here is my whole page. Have not gotten round to trying anything yet on my side as was getting to learn your code so I could understand the flow better...

<?php
include '../dbfunctions.php';
 
session_start();
$link = dbConnect();
 
$tcode = $_GET['tcode']; 
echo $tcode;

if( isset($_GET['catid']) )
$catid = $_GET['catid'];
echo $catid;
 
$cats = dbGetRows("tourcategories", "id = '".$_GET['catid']."'");
$cat = mysql_fetch_array($cats, MYSQL_ASSOC);
$catid = $cat['id'];
//echo $catid;
$tid = $_GET['tid'];
$tours = dbGetRows("tours", "tourops_id = '".$tid."'");
$tour = mysql_fetch_array($tours, MYSQL_ASSOC);

if(isset($_POST['Delete']))
{
$query = ("DELETE FROM tourcategories WHERE id = '".$catid."'");
var_dump($query);
$result = mysql_query($query) or die( "Error: " . mysql_error() );
}
 
if( isset($_POST['Submit']) ) {

$facs = "";
foreach( $_POST as $k => $v )
if( substr($k,0,4) == "fac_" ) $facs .= $v;
  
if( $_POST['catid'] == "" ) //new category
$query = "INSERT INTO tourcategories (`tour_code`, `name`, `class`, `bedtype`, `facilities`, `description`) VALUES ('".$_POST['tour_code']."','".$_POST['name']."', '".$_POST['class']."', '".$_POST['bedtype']."', '".$facs."', '".$_POST['description']."')";
else //update
$query = "UPDATE tourcategories SET `name` = '".$_POST['name']."', `class` = '".$_POST['class']."', `bedtype` = '".$_POST['bedtype']."', `facilities` = '".$facs."', `description` = '".$_POST['description']."' WHERE id = '".$_POST['catid']."'";
var_dump($query);

if( $_POST['name'] != "" ) $result = mysql_query($query, $link) or die("Query failed : ".$query."<br>". mysql_error());
}
elseif(isset($_POST['Delete']))
{
$query = "DELETE FROM `tourcategories` WHERE id = '".$_POST['catid']."'"; 
$result = mysql_query($query) or die( "Error: " . mysql_error() );
 
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Modify Category</title>
<link href="../bb.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFF4DC"
<?php if(isset($_POST['Submit']) && $result) echo "onLoad=\"window.close(); opener.location.reload(true);\""; 
else if (isset($_POST['Delete']) && $result) echo "onLoad=\"window.close(); opener.location.reload(true);\""; ?>>

<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr> 
<td width="32"><img src="../images/admin_03.gif"></td>
<td width="0*" bgcolor="#FFFFFF" background="../images/admin_04.gif" style="background-repeat: repeat-x;">&nbsp;</td>
<td width="35"><img src="../images/admin_07.gif" width="32" height="33"></td>
</tr>
<tr> 
<td bgcolor="#FFFFFF" background="../images/admin_15.gif" style="background-repeat: repeat-y;"></td>
<td bgcolor="#FFFFFF"><table width="93%" border="0" cellspacing="0" cellpadding="0" style="margin-left: 10px; margin-right: 10px;">
<tr>
<td><?php echo $tcode; ?>        
<tr> 
<td><font size="3"><b> 
<?php if( $catid != "") echo "MODIFY CATEGORY"; else echo "ADD NEW CATEGORY"; ?>
</b></font><br>
<font size=1>
Enter a category below to specify a type of tour you offer.<br>
E.g. You could create a 'Luxury' tour type which would be used to describe all three of your '5 Star' tours.</font><br>
<br>
<?php
if( isset($_POST['name']) && $_POST['name'] == "") echo "<font color=\"#FF0000\">Please enter a category name!</font><br><br>";
?>
<form name="form1" method="post" action="modifycat.php">
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr> 
<td width="104"><b>Category Name:</b></td>
<td width="286" valign="top"><input type="text" name="name" value="<?php echo $cat['name']; ?>"> 
<a href="javascript:;" onClick="alert('Enter a descriptive name for this room type\n\nExamples could be `Five Star` or `Budget`');"><img src="../images/help.png"></a>
<input type="text" name="tour_code" value="<?php echo $tcode; ?>">
<input type="text" name="catid" value="<?php echo $catid; ?>"></td>
<td width="286" valign="top">&nbsp;</td>
<td width="113">&nbsp;</td>
</tr>
<tr> 
<td valign="top"><b>Description:</b></td>
<td valign="top"><textarea name="description"><?php echo $cat['description']; ?></textarea>
<a href="javascript:;" onClick="alert('Enter full description for this category of accommadtion\n\nAn example could be `A luxury room with en-suite and majestic views over the valley.`');"><img src="../images/help.png" width="16" height="16"></a></td>
<td valign="top">&nbsp;</td>
</tr>
<tr> 
<td>&nbsp;</td>
</tr>
<?php
if( $tour['accomm'] == "Yes" || $catid !="") {
   
function getHTML($r,$check){
$out = "";
foreach($r as $item){
$sel = ($check == $item) ? ' selected = "selected"' : '';
$out .= "\n\t\t\t<option value=\"" . strtolower($item) . "\"$sel>$item</option>";
}
return $out;
}
function getTable($r,$c){
$out = "";
foreach($r as $item){
$sel = (strpos($c,$item[1]) > -1) ? ' checked = "checked"' : '';
$out .= "\n\t\t<tr>\n\t\t\t<td align=\"right\"><input type=\"checkbox\" name=\"fac_{$item[0]}\" value=\"{$item[1]}\"$sel></td>\n\t\t\t<td align=\"center\"><img src=\"../images/icons/{$item[2]}\" width=\"26\" height=\"27\"></td>\n\t\t\t<td align=\"left\">{$item[3]}</td>\n\t\t</tr>";
}
return $out;
}
     
$ops1 = array("Stateroom","Suite","Superior","First Class","Standard","Budget","Dormitory","Caravan","Trailer","Tent");
$ops2 = array("Queen","King","Double","Three-Quarter","Single","Bunk","Berth","Mixed");
$checks = array(
//name|value|image|label
array('tel','l','ico_phone.gif','Telephone'),
array('safe','f','ico_safe.gif','Safe'),
array('smoke','s','ico_smoke.gif','Smoking Permitted'),
array('tv','t','ico_tv_sat.gif','Satellite Television'),
array('pets','e','ico_pets.gif','No Pets'),
array('park','c','ico_cover_park.gif','Covered Parking'),
array('towels','o','ico_towels.gif','Towels Supplied')
);
     
$cat['facilities'] = "t";//get this in the usual way
	     
$c1 = "First Class"; //get these from global vars??
$c2 = "Single";
$c3 = $cat['facilities']; //for convenience
     
?>
<table>
<tr>
<td>
<strong>Room Class</strong>
</td>
<td>
<select name="class">
<?php echo getHTML($ops1,$c1);?>
</select>
</td>
</tr>
<tr>
<td>
<strong>Type of Bed(s)</strong>
</td>
<td>
<select name="bedtype">
<?php echo getHTML($ops2,$c2);?>
</select>
</td>
</tr>
</table>
     
<br>
<b>HOTEL FACILITIES</b><br>
<table width="40%" border="0" cellspacing="0" cellpadding="0">
<?php echo getTable($checks,$c3);?>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right">&nbsp;</td>
</tr>
</table>
<?php
}
?>
<tr> 
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right"><label></label></td>
</tr>
<tr> 
<td><input type="submit" name="Submit" value="Submit"></td>
<td><input type="button" name="Cancel" value="Close Window" onClick="window.close();"></td>
<td><input type="submit" name="Delete" value="Delete Room"></td>
<td>&nbsp;</td>
</tr>
</table>
</form>
</table></td>
<td bgcolor="#FFFFFF" align="right" background="../images/admin_14.gif" style="background-position: right; background-repeat: repeat-y;"></td>
</tr>
<tr>
<td><img src="../images/admin_21.gif" width="32" height="33"></td>
<td bgcolor="#FFFFFF" background="../images/admin_23.gif" style="background-position: bottom; background-repeat: repeat-x;">
</td>
<td><img src="../images/admin_20.gif" width="32" height="33"></td>
</tr>
</table>

</body>
</html>
Member Avatar for diafol

OK, just a tidy up, there are a lot of hard-coded layout/design attributes here. You'd be better to tidy them up into a css file and use 'class' or 'id' attributes to assign design/layout.

It seems as though your form is being sent to itself. This isn't always the best idea as a refresh/back button etc can send the form data again.
I usually send form data to a form handler page.

I suggest that you split the form handling from the form display code. But that's up to you. You can redirect back to the form page once all processing has been done. If you need to preserve form values, you can pass them as session data.

Thanks Ardav. I normally just close and refresh the opener page if the submit was succesful. Your advice is appreciated and I will look into changing my pages to clean things up..
Many thanks once again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.