My PHP page: <?php // **************************************************************************** ********** // * Module: startquote.php * // * Author: J D Stoops [[EMAIL PROTECTED]] * // * Last Updated: 16/03/2001 * // * Version: 1.0 * // **************************************************************************** ********** // * This is an unpublished work the copyright in which vests in Nuera Ltd. * // * All rights reserved. * // * The information contained herein is the property of Nuera Ltd and is supplied * // * without liability for errors or omissions. No part may be reproduced, disclosed * // * or used except as authorised by contract or other written permission. * // * The copyright and the foregoing restriction on reproduction, disclosure and use * // * extend to all media in which the information may be embodied. * // **************************************************************************** ********** ?> <html> <head> <title>Start New Quote</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="Description" content="Starts and saves a new quote for a client company of Nuera Limited" </head> <body bgcolor="#FFFFFF"> <?php // Show form function show_form() { // Setup database connection $conId = odbc_connect ("neuquote", "", "") or die ("An error1 has occured/n"); ?> <h1><font face="Arial, Helvetica, sans-serif">Start New Quote</font></h1> <form name="StartQuote" method="post" action="startquote.php"> <input type="Hidden" name="Action" value="1"> <table width="60%" border="0"> <tr> <td width="39%"><font face="Arial, Helvetica, sans-serif" size="4">Company Name </font></td> <td width="61%"><font face="Arial, Helvetica, sans-serif" size="4"> <?php // Select companies to display $result = odbc_exec ($conId, "SELECT CompanyId, CompanyName FROM Company ORDER BY CompanyName") or die ("An error1 has occured/n"); if (odbc_fetch_row ($result)) { ?> <select name="Company"> <option value=0>Please select or enter new company name below</option> <?php // Display all companies found echo "<option value=".odbc_result($result, "CompanyId").">".odbc_result($result, "CompanyName")."</option>"; while ($row = odbc_fetch_row ($result)) { echo "<option value=".odbc_result($result, "CompanyId").">".odbc_result($result, "CompanyName")."</option>"; } ?> </select> </font></td> </tr> <tr> <td width="39%"><font face="Arial, Helvetica, sans-serif" size="4">New Company Name </font></td> <td width="61%"><font face="Arial, Helvetica, sans-serif" size="4"> <?php } ?> <input type="text" name="CompanyName" maxlength="100"></font></td> </tr> <tr> <td width="39%"><font face="Arial, Helvetica, sans-serif" size="4">Employee</font></td> <td width="61%"><font face="Arial, Helvetica, sans-serif" size="4"> <select name="Employee"> <option value=0>Please select</option> <?php // Select employees to display $result = odbc_exec ($conId, "SELECT EmployeeId, EmployeeName FROM Employee ORDER BY EmployeeName") or die ("An error2 has occured/n"); // Display all employees found while ($row = odbc_fetch_row ($result)) { echo "<option value=".odbc_result($result, "EmployeeId").">".odbc_result($result, "EmployeeName")."</option>"; } ?> </select> </font></td> </tr> <tr> <td width="39%"><font face="Arial, Helvetica, sans-serif" size="4">Comment</font></td> <td width="61%"><font face="Arial, Helvetica, sans-serif" size="4"> <textarea name="Comment"></textarea> </font></td> </tr> <tr> <td width="39%"><font face="Arial, Helvetica, sans-serif" size="4">Start Date </font></td> <td width="61%"><font face="Arial, Helvetica, sans-serif" size="4"> <input type="text" name="StartDate" maxlength="10"> </font></td> </tr> <tr> <td width="39%"><font face="Arial, Helvetica, sans-serif" size="4">End Date</font></td> <td width="61%"><font face="Arial, Helvetica, sans-serif" size="4"> <input type="text" name="EndDate" maxlength="10"> </font></td> </tr> </table> <p> <input type="submit" name="Submit" value="Submit"> <input type="reset" name="Reset" value="Reset"> </p> </form> <?php odbc_free_result ($result); } // show_form // start_new_quote function start_new_quote($companyName,$companyId,$employeeId,$comment,$startDate,$end Date) { // Check all required inputs are present if ($companyId == "0" && $companyName == "") { die ("An error1 has occured/n"); } elseif ($employeeId == "" || $employeeId == "0") { die ("An error2 has occured/n"); } elseif ($startDate == "") { die ("An error3 has occured/n"); } elseif ($endDate == "") { die ("An error4 has occured/n"); } // Setup database connection $conId = odbc_connect ("neuquote", "", "") or die ("An error5 has occured/n"); if ($companyId == "0" || $companyId == "") { // Insert new company $result = odbc_exec ($conId, "INSERT INTO Company (CompanyName) VALUES ('".$companyName."')") or die ("An error7 has occured/n"); odbc_free_result ($result); // Select new companyid $result = odbc_exec ($conId, "SELECT CompanyId FROM Company WHERE CompanyName = '".$companyName."' ORDER BY CompanyId DESC") or die ("An error8 has occured/n"); // Store companyid if (odbc_fetch_row ($result)) { $companyId = odbc_result($result, "CompanyId"); } else { die ("An error7 has occured/n"); } } else { // Select company name $result = odbc_exec ($conId, "SELECT CompanyName FROM Company WHERE CompanyId = ".$companyId."") or die ("An error8 has occured/n"); // Store company name if (odbc_fetch_row ($result)) { $companyName = odbc_result($result, "CompanyName"); } else { die ("An error7 has occured/n"); } } odbc_free_result ($result); // Insert new quote $result = odbc_exec ($conId, "INSERT INTO Quote (CompanyId, EmployeeId, Comment, StartDate, EndDate) VALUES (".$companyId.", ".$employeeId.", '".$comment."', #".$startDate."#, #".$endDate."#)") or die ("An error8 has occured/n"); odbc_free_result ($result); // Select new quoteid $result = odbc_exec ($conId, "SELECT QuoteId FROM Quote WHERE CompanyId = ".$companyId." AND EmployeeId = ".$employeeId." ORDER BY QuoteId DESC") or die ("An error9 has occured/n"); // Store quoteid if (odbc_fetch_row ($result)) { $quoteId = odbc_result($result, "QuoteId"); } else { die ("An error10 has occured/n"); } odbc_free_result ($result); // Select services $result = odbc_exec ($conId, "SELECT * FROM Service") or die ("An error11 has occured/n"); ?> <h1><font face="Arial, Helvetica, sans-serif">Select Services Required By <?php echo $companyName ?></font></h1> <form name="form1" method="post" action="startquote.php"> <input type="Hidden" name="Action" value="2"> <input type="Hidden" name="Quote" value=<?php echo $quoteId ?>> <table width="83%" border="0"> <tr> <td width="0%" height="33"></td> <td width="13%" bgcolor="#FFFFFF" height="33"><font face="Arial, Helvetica, sans-serif" size="4">Service Title</font></td> <td width="1%" bgcolor="#FFFFFF" height="33"><font face="Arial, Helvetica, sans-serif" size="4">Use</font></td> <td width="15%" height="33"><font face="Arial, Helvetica, sans-serif" size="4">From</font></td> <td width="15%" height="33"><font face="Arial, Helvetica, sans-serif" size="4">To</font></td> <td width="15%" height="33"><font face="Arial, Helvetica, sans-serif" size="4">No Services</font></td> <td width="15%" height="33"><font face="Arial, Helvetica, sans-serif" size="4">No Units/ Service</font></td> <td width="26%" height="33"><font face="Arial, Helvetica, sans-serif" size="4">Comment</font></td> </tr> <?php $counter = "1"; while ($row = odbc_fetch_row ($result)) { ?> <tr> <td width="0%" height="13"> <input type="Hidden" name=Service<?php echo $counter ?> value=<?php echo odbc_result($result, "ServiceId") ?>> </td> <td width="13%" bgcolor="#FFFFFF" height="33"><font face="Arial, Helvetica, sans-serif" size="3"><?php echo odbc_result($result, "ServiceTitle") ?></font></td> <td width="1%" bgcolor="#FFFFFF" height="33"> <font face="Arial, Helvetica, sans-serif" size="3"> <input type="checkbox" name=Use<?php echo $counter ?> value="checkbox"> </font></td> <td width="15%" height="33"> <font face="Arial, Helvetica, sans-serif" size="3"> <input type="text" name=From<?php echo $counter ?> maxlength="10" size="10"> </font></td> <td width="15%" height="33"> <font face="Arial, Helvetica, sans-serif" size="3"> <input type="text" name=To<?php echo $counter ?> maxlength="10" size="10"> </font></td> <td width="15%" height="33"><font face="Arial, Helvetica, sans-serif" size="3"> <input type="text" name=NoServices<?php echo $counter ?> maxlength="3" size="6" value="0"> </font></td> <td width="15%" height="33"><font face="Arial, Helvetica, sans-serif" size="3"> <input type="text" name=NoUnits<?php echo $counter ?> maxlength="3" size="6" value="0"> </font></td> <td width="26%" height="33"><font face="Arial, Helvetica, sans-serif" size="3"> <textarea name=Comment<?php echo $counter ?>></textarea> </font></td> </tr> <?php $counter++; } $counter--; echo "<input type=Hidden name=ServiceCount value=".$counter.">\n"; ?> </table> <p> <input type="submit" name="Submit" value="Submit"> <input type="button" name="PayOption" value="Payment Options"> </p> </form> <?php odbc_free_result ($result); } // start_new_quote // Save new quote function save_quote($quoteId,$noServices) { $counter = "1"; while ($counter <= $noServices) { $serviceId = $HTTP_POST_VARS['Service$counter']; $use = $HTTP_POST_VARS["Use".$counter]; $from = $HTTP_POST_VARS["From".$counter]; $to = $HTTP_POST_VARS["To".$counter]; $noServicesUsed = $HTTP_POST_VARS["NoServices".$counter]; $noUnits = $HTTP_POST_VARS["NoUnits$counter"]; $comment = $HTTP_POST_VARS["Comment.$counter"]; // Would save to db as opposed to being printed out echo $serviceId." Use: ".$use." From: ".$from." To: ".$to." No Services: ".$noServicesUsed." No Units: ".$noUnits." Comment: ".$comment."<br>"; $counter++; } } // save_quote // Check action if (@$HTTP_POST_VARS['Action']) { // Get action to perform $action = $HTTP_POST_VARS['Action']; } else { $action = "0"; } // Start new quote if ($action == "1") { start_new_quote($HTTP_POST_VARS['CompanyName'],@$HTTP_POST_VARS['Company'],$ HTTP_POST_VARS['Employee'],$HTTP_POST_VARS['Comment'],$HTTP_POST_VARS['Start Date'],$HTTP_POST_VARS['EndDate'], "0"); // Save new quote } elseif ($action == "2") { save_quote($HTTP_POST_VARS['Quote'],$HTTP_POST_VARS['ServiceCount']); // Show new quote input form } else { show_form(); } ?> </body> </html> -----Original Message----- From: Bug Database [mailto:[EMAIL PROTECTED]] Sent: Friday, March 16, 2001 11:38 To: [EMAIL PROTECTED] Subject: PHP 4.0 Bug #9782 Updated: Warning: Undefined variable: HTTP_POST_VARS ID: 9782 Updated by: sniper Reported By: [EMAIL PROTECTED] Old-Status: Open Status: Feedback Bug Type: Strings related Assigned To: Comments: It would be easier to find what is wrong with your example if it would have been complete. Try these in your script: print_r($HTTP_POST_VARS); print_r($HTTP_GET_VARS); --Jani Previous Comments: --------------------------------------------------------------------------- [2001-03-16 06:32:14] [EMAIL PROTECTED] The number of inputs from my form varies so I have distinguished them using a counter that increments for each record: <input type="text" name=Service<?php echo $counter ?> size="10"> When requesting them from the header I loop through using another counter: while ($counter <= $noServices) { $serviceId = $HTTP_POST_VARS['Service$counter']; $counter++ } No matter how I try to build the name of the post variable I always get the following error: Warning: Undefined variable: HTTP_POST_VARS in C:Inetpubwwwroot/php/neuquote/startquote.php on line 251 I have tried buiding the string as follows: 'Service$counter' 'Service'.$counter "Service".$counter $postVar = "Service".$counter // put $postVar between [] I have done this in ASP before and from what I have seen from PHP so far it is more powerful, thus hopefully one of u guys can help by a different string build or a different approuch to creating the inputs Thank you for your time. John Stoops, Neutralize (**) --------------------------------------------------------------------------- ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=9782&edit=2 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]