Location: PHPKode > projects > QUICKLYWEB > quicklyweb/admin/entercustomer.php
<?
# Enter customer displays a form that allows the entry of a customer, and 
# handles the submission
session_start();

require("quicklyweb.php");
require("security/secure.php");

beginDocument($lEnterCustomer, $_SESSION['sess_user']);

if(isset($_POST['action']) == 'newuser') {
	if (($_POST['first'] == "") OR ($_POST['last'] == "") OR ($_POST['address'] == "") OR ($_POST['city'] == "") OR ($_POST['country'] == "")) {
			echo "<table><form method='POST' action='entercustomer.php'>\n";
			echo "<tr><input type='hidden' name='first' value='$_POST[first]'>\n";
			echo "<input type='hidden' name='mid' value='$_POST[mid]'>\n";
			echo "<input type='hidden' name='last' value='$_POST[last]'>\n";
			echo "<input type='hidden' name='company' value='$_POST[company]'>\n";
			echo "<input type='hidden' name='address' value='$_POST[address]'>\n";
			echo "<input type='hidden' name='city' value='$_POST[city]'>\n";
			echo "<input type='hidden' name='zip' value='$_POST[zip]'>\n";
			echo "<input type='hidden' name='country' value='$_POST[country]'>\n";
			echo "<input type='hidden' name='phone' value='$_POST[phone]'>\n";
			echo "<input type='hidden' name='fax' value='$_POST[fax]'>\n";
			echo "<input type='hidden' name='mobile' value='$_POST[mobile]'>\n";
			echo "<input type='hidden' name='email' value='$_POST[email]'>\n";
			echo "<td>First Name, Last Name, Address, City and Country may not be blank.</td>\n";
			echo "<td><input type='image' type='submit' value='submit' src='images/logout.png' alt='Back to Customer'></td></tr></form>\n";
			echo "</table>\n";
			die;
	}

	$first = strip_tags(addslashes($_POST['first']));
	$mid = strip_tags(addslashes($_POST['mid']));
	$last = strip_tags(addslashes($_POST['last']));
	$company = strip_tags(addslashes($_POST['company']));
	$address = strip_tags(addslashes($_POST['address']));
	$city = strip_tags(addslashes($_POST['city']));
	$state = strip_tags(addslashes($_POST[state]));
	$zip = strip_tags(addslashes($_POST[zip]));
	$country = strip_tags(addslashes($_POST['country']));
	$phone = strip_tags(addslashes($_POST['phone']));
	$fax = strip_tags(addslashes($_POST['fax']));
	$mobile = strip_tags(addslashes($_POST['mobile']));
	$email = strip_tags($_POST['email']);
        $username= strip_tags(addslashes($_POST['username']));
	$password = crypt($_POST['password'], $SALT);

	$db = getDBConnection();
	$result = DBquery("INSERT INTO Customers (CustomerID, BillTypeID, First, Mid, Last, Company, Address, City, State, Zip, TaxID, Country, Telephone, Fax, Mobile, Email, Username, Password) 
	VALUES ('','$_POST[BillTypeID]','$first','$mid','$last','$company','$address','$city','$state','$zip','$_POST[TaxInfoID]','$country',
	'$phone','$fax','$mobile','$email','$username','$password')", $db); 
	
	checkDBError($db);
	$cust = mysql_insert_id();
	PostDBReport($result, $lCustomerAddition, 'showprofile.php', 'CustomerID', $cust, "Customer ".$cust, $db);
} else { 
	$bill_result = DBquery("SELECT BillTypeID, BillName FROM BillingInfo", $db);
	$default_results = DBquery("SELECT * FROM Configuration", $db);
	$taxresult = DBquery("SELECT * FROM TaxInfo",$db);
	
	beginPrettyTable("2", $lEnterCustomer);
	openForm("entercustomer", $_SERVER['PHP_SELF']);
	makeHiddenField("action", "newuser");
	print("<tr class='small'><td><b>$lBillTypeId</b></td><td><SELECT name='BillTypeID'>");
	while ($bill_row = DBfetch_array($bill_result)) {
	print("<OPTION Value='$bill_row[BillTypeID]'>$bill_row[BillName]");	
	}
	print("</SELECT></td></tr>");
	print("<tr class='small'><td><b>$lTaxType<b></td><td><SELECT name='TaxInfoID'>");
	while($tax_row = DBfetch_array($taxresult)){
	print("<OPTION Value='$tax_row[TaxInfoID]'>$tax_row[TaxTag] ($tax_row[Description] $tax_row[Quantity]%)");	
	}
	print("</SELECT></td></tr>");
	  makeTextField($lFirst, "first", $_POST['first']);
	  makeTextField($lMid, "mid", $_POST['mid']);
	  makeTextField($lLast, "last", $_POST['last']);
	  makeTextField($lCompany, "company", $_POST['company']);
	  makeTextField($lAddress, "address", $_POST['address']);
	  makeTextField($lCity, "city", $_POST['city']);
	  while ($default_row = DBfetch_array($default_results)) {
	  makeTextField($lState, "state", $default_row["State"] );
	  makeTextField($lZip, "zip", $_POST['zip']);
	  makeDropBox($lCountry, "country", $default_row["Country"], "Afghanistan", "Algeria", "Andorra", "Angola", "Anguila", "Antigua", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "The Bahamas", "Bahrain", "Bangladesh", "Barbados", "Barbuda", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bolivia", "Bosnia", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Columbia", "Congo", "DR Congo", "Cook Islands", "Costa Rica", "Cote D'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Dijbouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Estonia", "Ethiopia", "Faroe Islands", "Fiji Islands", "Finland", "France", "French Guiana", "French Polynesia", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Herzegovina", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea", "Kuwait", "Kyrgyzstan", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania",  "Luxembourg", "Macao Sar", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nepal", "Netherlands Antilles", "The Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norfolk Island", "North Korea", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russia", "Rwanda", "St. Kitts & Nevis", "St. Lucia", "St. Vincent & Grenadines", "Samoa", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Tobago", "Togo", "Tonga", "Trinidad", "Tunisia", "Turkey", "Turkmenistan", "Turks & Caicos islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "Uruguay", "USA", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin islands", "Wallis & Futuna", "Yemen", "Zambia", "Zimbabwe");
	  };
	  makeTextField($lPhone, "phone", $_POST['phone']);
	  makeTextField($lFax, "fax", $_POST['fax']);
	  makeTextField($lMobile, "mobile", $_POST['mobile']);
	  makeTextField($lEmail, "email", $_POST['email']);
          makeTextField($lUsername, "username", "");
	  makeTextField($lPassword, "password", "");
	makeSubmitter();
	endPrettyTable();
	closeForm();
}
endDocument();
?>

Return current item: QUICKLYWEB