on submit form refreshes itself instead of adding info to db

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

on submit form refreshes itself instead of adding info to db

Post by fariquzeli »

I have a page that has a form on it with the following code:

Code: Select all

<?php 
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")  
{ 
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; 

  switch ($theType) { 
    case "text": 
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; 
      break;     
    case "long": 
    case "int": 
      $theValue = ($theValue != "") ? intval($theValue) : "NULL"; 
      break; 
    case "double": 
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; 
      break; 
    case "date": 
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; 
      break; 
    case "defined": 
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; 
      break; 
  } 
  return $theValue; 
} 

$editFormAction = $HTTP_SERVER_VARS['PHP_SELF']; 
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { 
  $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING']; 
} 

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) { 

copy($HTTP_POST_FILES['picture']['tmp_name'], "../images/".$HTTP_POST_FILES['picture']['name']) or die(mysql_error()); 
$imagepath = "http://www.pancorp.com/images/".$HTTP_POST_FILES['picture']['name'].""; 

copy($HTTP_POST_FILES['thmb']['tmp_name'], "../images/s/".$HTTP_POST_FILES['thmb']['name']) or die(mysql_error()); 
$thumbpath = "http://www.pancorp.com/images/s/".$HTTP_POST_FILES['thmb']['name'].""; 

  $insertSQL = sprintf("INSERT INTO products (id, type, category, picture, thumbnail, partA, nameA, priceA, partB, nameB, priceB, partC, nameC, priceC, partD, nameD, priceD, partE, nameE, priceE, partF, nameF, priceF, info, featured) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", 
                       GetSQLValueString($HTTP_POST_VARS['id'], "int"),  
                       GetSQLValueString($HTTP_POST_VARS['type'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['category'], "text"), 
                       GetSQLValueString($imagepath, "text"), 
                       GetSQLValueString($thumbpath, "text"), 
                       GetSQLValueString($HTTP_POST_VARS['partA'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['nameA'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['priceA'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['partB'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['nameB'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['priceB'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['partC'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['nameC'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['priceC'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['partD'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['nameD'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['priceD'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['partE'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['nameE'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['priceE'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['partF'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['nameF'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['priceF'], "text"), 
                       GetSQLValueString($HTTP_POST_VARS['info'], "text"), 
                       GetSQLValueString(isset($HTTP_POST_VARS['featured']) ? "true" : "", "defined","'Y'","'N'")); 

  mysql_select_db($database_userLogin, $userLogin); 
  $Result1 = mysql_query($insertSQL, $userLogin) or die(mysql_error()); 

  $insertGoTo = "admin.php"; 
  if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { 
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; 
    $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING']; 
  } 
  header(sprintf("Location: %s", $insertGoTo)); 
} 
?> 

<html> 
<head> 
<title>Add Product - Pancorp.com</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
</head> 

<body> 
<form method="post" name="form1" enctype="multipart/form-data" action="<?php echo $editFormAction; ?>" > 
  <table align="center"> 
    <tr valign="baseline"> 
      <td nowrap align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Category:</font></td> 
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <select name="category" id="category"> 
          <option value="#" selected>SELECT</option> 
          <option value="xraymachines">X-ray Machines</option> 
          <option value="filmcassettesandfilmsupplies">film, Cassettes & Film 
          Supplies</option> 
          <option value="darkroomchemicalsandcleaners">Darkroom Chemicals & 
          Cleaners</option> 
          <option value="darkroomaccessories">Darkroom Accessories</option> 
          <option value="xrayaccessories">X-ray Accessories</option> 
          <option value="xrayinstructionalliterature">X-ray Instructional Literature</option> 
          <option value="dentalofficeproducts">Dental Office Products</option> 
          <option value="emergencymedicalproducts">Emergency Medical Products</option> 
          <option value="handpieceproductsandrepair">Handpiece Products & 
          Repair</option> 
        </select> 
        (general for product index)</font></td> 
     
    <tr valign="baseline"> 
      <td nowrap align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Type:</font></td> 
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <select name="type" id="select"> 
          <option value="#" selected>SELECT</option> 
          <option value="PC-1000 Cassette Sleeve /Intensifying Screens">PC-1000 
          Cassette Sleeve /Intensifying Screens</option> 
          <option value="Radio Opaque Marking Tape">Radio Opaque Marking Tape</option> 
          <option value="Clear Image Processor Cleaner">Clear Image Processor 
          Cleaner</option> 
          <option value="Clean Image Roller Sheets">Clean Image Roller Sheets</option> 
          <option value="Star Dip Tank">Star Dip Tank</option> 
          <option value="Ambient Light Film Duplicator">Ambient Light Film Duplicator</option> 
          <option value="Star Illuminated Film Duplicator">Star Illuminated Film 
          Duplicator</option> 
          <option value="Beam Filter Kit">Beam Filter Kit</option> 
          <option value="Star X-ray Darkroom Safelight">Star X-ray Darkroom Safelight</option> 
          <option value="Dial Thermometer">Dial Thermometer</option> 
          <option value="Star Film Hangers">Star Film Hangers</option> 
          <option value="Marking Pencils">Marking Pencils</option> 
          <option value="Pano Shield Lead Apron">Pano Shield Lead Apron</option> 
          <option value="Adult Size Lead Poncho">Adult Size Lead Poncho</option> 
          <option value="Bite Guides">Bite Guides</option> 
          <option value="Remote Switch Kit">Remote Switch Kit</option> 
          <option value="Mailing & Filing Envelopes">Mailing & Filing 
          Envelopes</option> 
          <option value="Disposable Ear Rod Barriers">Disposable Ear Rod Barriers</option> 
          <option value="User Manuals">User Manuals</option> 
          <option value="User Videos">User Videos</option> 
          <option value="Gleco Solid Waste Trap&#8482;">Gleco Solid Waste&#8482;</option> 
          <option value="Emergency Drug Kit">Emergency Drug Kit</option> 
          <option value="Basic Emergency Drug Kit">Basic Emergency Drug Kit</option> 
          <option value="Firstsave&reg; Automated External Defibrillator">Firstsave&reg; 
          Automated External Defibrillator</option> 
          <option value="On Demand Oxygen System">On Demand Oxygen System</option> 
          <option value="Oxygen System">Oxygen System</option> 
          <option value="Ambu&reg; MediBag&#8482; Resuscitator">Ambu&reg; MediBag&#8482; Resuscitator</option> 
          <option value="New Life CPR Resuscitator Kit">New Life CPR Resuscitator 
          Kit</option> 
          <option value="XXV First Aid Kit">XXV First Aid Kit</option> 
        </select> 
        (specific for individual pages)</font></td> 
     
    <tr valign="baseline"> 
      <td nowrap align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Picture:</font></td> 
      <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input type="file" name="picture" value="" size="30"> 
        </font></td> 
    </tr> 
    <tr valign="baseline"> 
      <td nowrap align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Thumbnail:</font></td> 
      <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="thmb" type="file" id="thmb" value="" size="30"> 
        </font></td> 
    </tr> 
    <tr valign="baseline"> 
      <td nowrap align="right" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Part 
        Number A:</font></td> 
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="partA" type="text" id="partA" value="" size="15"> 
        Name A: 
        <input name="nameA" type="text" id="nameA"> 
        Price A: 
        <input name="priceA" type="text" id="priceA" value="" size="12"> 
        </font></td> 
    </tr> 
    <tr valign="baseline"> 
      <td nowrap align="right" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Part 
        Number B:</font></td> 
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="partB" type="text" id="partB" value="" size="15"> 
        Name B: 
        <input name="nameB" type="text" id="nameB"> 
        Price B: 
        <input name="priceB" type="text" id="priceB" value="" size="12"> 
        </font></td> 
    </tr> 
    <tr valign="baseline"> 
      <td nowrap align="right" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Part 
        Number C:</font></td> 
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="partC" type="text" id="partC" value="" size="15"> 
        Name C: 
        <input name="nameC" type="text" id="nameC"> 
        Price C: 
        <input name="priceC" type="text" id="priceC" value="" size="12"> 
        </font></td> 
    </tr> 
    <tr valign="baseline"> 
      <td nowrap align="right" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Part 
        Number D:</font></td> 
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="partD" type="text" id="partD" value="" size="15"> 
        Name D: 
        <input name="nameD" type="text" id="nameD"> 
        Price D: 
        <input name="priceD" type="text" id="priceD" value="" size="12"> 
        </font></td> 
    </tr> 
    <tr valign="baseline"> 
      <td nowrap align="right" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Part 
        Number E:</font></td> 
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="partE" type="text" id="partE" value="" size="15"> 
        Name E: 
        <input name="nameE" type="text" id="nameE"> 
        Price E: 
        <input name="priceE" type="text" id="priceE" value="" size="12"> 
        </font></td> 
    </tr> 
    <tr valign="baseline"> 
      <td nowrap align="right" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Part 
        Number F:</font></td> 
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="partF" type="text" id="partF" value="" size="15"> 
        Name F: 
        <input name="nameF" type="text" id="nameF"> 
        Price F: 
        <input name="priceF" type="text" id="priceF" value="" size="12"> 
        </font></td> 
    </tr> 
    <tr valign="baseline"> 
      <td nowrap align="right" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Info:</font></td> 
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <textarea name="info" cols="80" rows="12"></textarea> 
        </font></td> 
    </tr> 
    <tr valign="baseline"> 
      <td nowrap align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Featured:</font></td> 
      <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input type="checkbox" name="featured" value="" > 
        </font></td> 
    </tr> 
    <tr valign="baseline"> 
      <td nowrap align="right">&nbsp;</td> 
      <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input type="submit" value="Submit"> 
        </font></td> 
    </tr> 
  </table> 
  <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
  <input type="hidden" name="MM_insert" value="form1"> 
  </font> 
</form> 
<p>&nbsp;</p> 
   
</body> 
</html>
Now rather than simply parsing the PHP and adding the form's info to a database, the form resets itself bringing me back to the addProduct.php page (name of page) reather than adding info to a database and redirecting me to admin.php. I get no errors whatsoever.

Any help would be greatly appreciated:

http://www.pancorp.com/siteadmin/addProduct.phps if you want to see the code on a seperate page.
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

If you put var_dump($HTTP_POST_VARS); at the top of your script, then we can see if anything is posted.
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

Post by fariquzeli »

Code: Select all

<?php
 var_dump($HTTP_POST_VARS);
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
  $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {

copy($HTTP_POST_FILES['picture']['tmp_name'], "../images/".$HTTP_POST_FILES['picture']['name']) or die(mysql_error());
$imagepath = "http://www.pancorp.com/images/".$HTTP_POST_FILES['picture']['name']."";

copy($HTTP_POST_FILES['thmb']['tmp_name'], "../images/s/".$HTTP_POST_FILES['thmb']['name']) or die(mysql_error());
$thumbpath = "http://www.pancorp.com/images/s/".$HTTP_POST_FILES['thmb']['name']."";

  $insertSQL = sprintf("INSERT INTO products (id, type, category, picture, thumbnail, partA, nameA, priceA, partB, nameB, priceB, partC, nameC, priceC, partD, nameD, priceD, partE, nameE, priceE, partF, nameF, priceF, info, featured) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
					   GetSQLValueString($HTTP_POST_VARS['id'], "int"), 
					   GetSQLValueString($HTTP_POST_VARS['type'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['category'], "text"),
                       GetSQLValueString($imagepath, "text"),
                       GetSQLValueString($thumbpath, "text"),
                       GetSQLValueString($HTTP_POST_VARS['partA'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['nameA'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['priceA'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['partB'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['nameB'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['priceB'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['partC'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['nameC'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['priceC'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['partD'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['nameD'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['priceD'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['partE'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['nameE'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['priceE'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['partF'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['nameF'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['priceF'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['info'], "text"),
                       GetSQLValueString(isset($HTTP_POST_VARS['featured']) ? "true" : "", "defined","'Y'","'N'"));

  mysql_select_db($database_userLogin, $userLogin);
  $Result1 = mysql_query($insertSQL, $userLogin) or die(mysql_error());

  $insertGoTo = "admin.php";
  if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>

<html>
<head>
<title>Add Product - Pancorp.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form method="post" name="form1" enctype="multipart/form-data" action="<?php echo $editFormAction; ?>" >
  <table align="center">
    <tr valign="baseline"> 
      <td nowrap align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Category:</font></td>
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <select name="category" id="category">
          <option value="#" selected>SELECT</option>
          <option value="xraymachines">X-ray Machines</option>
          <option value="filmcassettesandfilmsupplies">film, Cassettes & Film 
          Supplies</option>
          <option value="darkroomchemicalsandcleaners">Darkroom Chemicals & 
          Cleaners</option>
          <option value="darkroomaccessories">Darkroom Accessories</option>
          <option value="xrayaccessories">X-ray Accessories</option>
          <option value="xrayinstructionalliterature">X-ray Instructional Literature</option>
          <option value="dentalofficeproducts">Dental Office Products</option>
          <option value="emergencymedicalproducts">Emergency Medical Products</option>
          <option value="handpieceproductsandrepair">Handpiece Products & 
          Repair</option>
        </select>
        (general for product index)</font></td>
    
    <tr valign="baseline"> 
      <td nowrap align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Type:</font></td>
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <select name="type" id="select">
          <option value="#" selected>SELECT</option>
          <option value="PC-1000 Cassette Sleeve /Intensifying Screens">PC-1000 
          Cassette Sleeve /Intensifying Screens</option>
          <option value="Radio Opaque Marking Tape">Radio Opaque Marking Tape</option>
          <option value="Clear Image Processor Cleaner">Clear Image Processor 
          Cleaner</option>
          <option value="Clean Image Roller Sheets">Clean Image Roller Sheets</option>
          <option value="Star Dip Tank">Star Dip Tank</option>
          <option value="Ambient Light Film Duplicator">Ambient Light Film Duplicator</option>
          <option value="Star Illuminated Film Duplicator">Star Illuminated Film 
          Duplicator</option>
          <option value="Beam Filter Kit">Beam Filter Kit</option>
          <option value="Star X-ray Darkroom Safelight">Star X-ray Darkroom Safelight</option>
          <option value="Dial Thermometer">Dial Thermometer</option>
          <option value="Star Film Hangers">Star Film Hangers</option>
          <option value="Marking Pencils">Marking Pencils</option>
          <option value="Pano Shield Lead Apron">Pano Shield Lead Apron</option>
          <option value="Adult Size Lead Poncho">Adult Size Lead Poncho</option>
          <option value="Bite Guides">Bite Guides</option>
          <option value="Remote Switch Kit">Remote Switch Kit</option>
          <option value="Mailing & Filing Envelopes">Mailing & Filing 
          Envelopes</option>
          <option value="Disposable Ear Rod Barriers">Disposable Ear Rod Barriers</option>
          <option value="User Manuals">User Manuals</option>
          <option value="User Videos">User Videos</option>
          <option value="Gleco Solid Waste Trap&#8482;">Gleco Solid Waste&#8482;</option>
          <option value="Emergency Drug Kit">Emergency Drug Kit</option>
          <option value="Basic Emergency Drug Kit">Basic Emergency Drug Kit</option>
          <option value="Firstsave&reg; Automated External Defibrillator">Firstsave® 
          Automated External Defibrillator</option>
          <option value="On Demand Oxygen System">On Demand Oxygen System</option>
          <option value="Oxygen System">Oxygen System</option>
          <option value="Ambu&reg; MediBag&#8482; Resuscitator">Ambu® MediBag™ Resuscitator</option>
          <option value="New Life CPR Resuscitator Kit">New Life CPR Resuscitator 
          Kit</option>
          <option value="XXV First Aid Kit">XXV First Aid Kit</option>
        </select>
        (specific for individual pages)</font></td>
    
    <tr valign="baseline"> 
      <td nowrap align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Picture:</font></td>
      <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input type="file" name="picture" value="" size="30">
        </font></td>
    </tr>
    <tr valign="baseline"> 
      <td nowrap align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Thumbnail:</font></td>
      <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="thmb" type="file" id="thmb" value="" size="30">
        </font></td>
    </tr>
    <tr valign="baseline"> 
      <td nowrap align="right" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Part 
        Number A:</font></td>
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="partA" type="text" id="partA" value="" size="15">
        Name A: 
        <input name="nameA" type="text" id="nameA">
        Price A: 
        <input name="priceA" type="text" id="priceA" value="" size="12">
        </font></td>
    </tr>
    <tr valign="baseline"> 
      <td nowrap align="right" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Part 
        Number B:</font></td>
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="partB" type="text" id="partB" value="" size="15">
        Name B: 
        <input name="nameB" type="text" id="nameB">
        Price B: 
        <input name="priceB" type="text" id="priceB" value="" size="12">
        </font></td>
    </tr>
    <tr valign="baseline"> 
      <td nowrap align="right" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Part 
        Number C:</font></td>
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="partC" type="text" id="partC" value="" size="15">
        Name C: 
        <input name="nameC" type="text" id="nameC">
        Price C: 
        <input name="priceC" type="text" id="priceC" value="" size="12">
        </font></td>
    </tr>
    <tr valign="baseline"> 
      <td nowrap align="right" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Part 
        Number D:</font></td>
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="partD" type="text" id="partD" value="" size="15">
        Name D: 
        <input name="nameD" type="text" id="nameD">
        Price D: 
        <input name="priceD" type="text" id="priceD" value="" size="12">
        </font></td>
    </tr>
    <tr valign="baseline"> 
      <td nowrap align="right" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Part 
        Number E:</font></td>
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="partE" type="text" id="partE" value="" size="15">
        Name E: 
        <input name="nameE" type="text" id="nameE">
        Price E: 
        <input name="priceE" type="text" id="priceE" value="" size="12">
        </font></td>
    </tr>
    <tr valign="baseline"> 
      <td nowrap align="right" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Part 
        Number F:</font></td>
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="partF" type="text" id="partF" value="" size="15">
        Name F: 
        <input name="nameF" type="text" id="nameF">
        Price F: 
        <input name="priceF" type="text" id="priceF" value="" size="12">
        </font></td>
    </tr>
    <tr valign="baseline"> 
      <td nowrap align="right" valign="top"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Info:</font></td>
      <td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <textarea name="info" cols="80" rows="12"></textarea>
        </font></td>
    </tr>
    <tr valign="baseline"> 
      <td nowrap align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Featured:</font></td>
      <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input type="checkbox" name="featured" value="" >
        </font></td>
    </tr>
    <tr valign="baseline"> 
      <td nowrap align="right">&nbsp;</td>
      <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input type="submit" value="Submit">
        </font></td>
    </tr>
  </table>
  <font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
  <input type="hidden" name="MM_insert" value="form1">
  </font> 
</form>
<p>&nbsp;</p>
  
</body>
</html>
That's with the var_dump($HTTP_POST_VARS); at the top

I get this printed at th etop of the page before and after submitting:

array(0) { }

That's all that happens.

?>
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

Why don't use just $featured instead of $HTTP_POST_VARS['featured'].

If you have that var set, it sould be working.
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

Post by fariquzeli »

That's irrelevant, it's not going to change whether the form submits or not, it is still going to refresh the page and not add any information to the databse.

please help someone!
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

It's not loaded into the database becouse it won't pass this if.

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {

The $HTTP_POST_VARS is empty.

If you replace it with this if:
if(isset($MM_insert) && $MM_insert=="form1"){

If will pass. (i think).
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

Post by fariquzeli »

even after changing this it still just refreshes the form.

Any other IDEAS?
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

? Strange ?

Maybe there scared and hidden in the $_POST value.
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

Post by fariquzeli »

hmm, its a possibility, but I doubt it. I'll check and get back to you here.

http://pancorp.com/siteadmin/phpinfo.php

That's my php info I have php 4.1.2

Am I using the right type of variables?
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

Depents on the settings of your php,

But can if you do a php_info, and you POST or GET your data, the data must be in there.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

[]InTeR[] wrote:Why don't use just $featured instead of $HTTP_POST_VARS['featured'].

If you have that var set, it sould be working.
[]InTeR[] wrote:It's not loaded into the database becouse it won't pass this if.

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {

The $HTTP_POST_VARS is empty.

If you replace it with this if:
if(isset($MM_insert) && $MM_insert=="form1"){

If will pass. (i think).
I just want to clear this up - register_globals is now off by default, this is the setting that used to allow you to access posted variables (and those in the query string or cookies) simply by their name - e.g. $MM_insert. However, you really shouldn't be doing things this way any more - register_globals is deprecated, ie. it will not be available in all future versions of PHP and if you are using PHP 4.1 or above then you should be accessing variables using the superglobals $_POST (for posted data), $_GET (for data from the query string), $_COOKIE (for cookie information), $_SESSION (for session information) etc.

For more info:
viewtopic.php?t=511

In older versions of PHP $_POST was called $HTTP_POST_VARS and in current versions both are available. If you could access the data as $MM_insert (i.e. register_globals is on) then you could access it as $_POST['MM_insert'] or $HTTP_POST_VARS['MM_insert'] - however, if you cannot access it in $_POST or $HTTP_POST_VARS then you will not be able to access it directly as $MM_insert even if register_globals is on.

Another thing to note is that Dreamweaver's attempt at PHP code is dismal to say the least.

Mac
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

Thnx for the tip.

The most of my programming is still done the 'old' way.
I will change my way of programming to the register_globals = off method.

But we whil keep the register_globals turned on, becouse whe have 100's of scripts on our server that are still writen the 'old' way.
Or is this not supported in the new versions of php (like 5)?
nophp
Forum Newbie
Posts: 1
Joined: Fri Aug 08, 2003 1:52 am

Post by nophp »

How do you turn on register_globals on a Red Hat Linux 9 system? We have over 150 files containing old PHP scripts.
Post Reply