Hello all,

I have a simple web form that use an email address to send information once it's submitted. I need to modify it to where it sends the info to an access database. How can I make that happen?

web form:

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
	<title>Untitled</title>
	<link href="wireless.css" rel="stylesheet" type="text/css"/>   
	<script type="text/javascript" src="form.js"></script>
</head>

<body onload="addOption_list(); addOption_list2(); divSelection()" >

   <div id="outer">
   	<img src="" alt="logo" usemap="#logomap" class="carrierLogo" />
	  <map id="logomap" name="logomap">
		<area shape="rect" coords="0,0,399,120" href="#" alt="home"/>
	  </map>
	  
   <div id="inner">	
	<form id="apply" name="apply" action="mailto:info@donate.com" method="post" enctype="text/plain">
	
	<fieldset>
	 	<legend>Donor Type</legend>
		   <label for="donerType">
		     <input type="radio" id="businessDoner" name="donerType"  value="business" checked="checked" onclick="toggle(this); " />
		   		  Business
		   </label>
		   
		   <label for="donerType">
		   	 <input type="radio" id="individualDoner" name="donerType" value="individual" onclick="toggle(this)" />
		   		  Individual
		   </label>
	 </fieldset>
	 
	 
	 <fieldset id="contact" >
	 	<legend>Donor Information</legend>
	 	<div id="busi" >
			  <label class="blockLabel" for="companyName">
				Company Name<span>*</span>
				<input type="text" id="companyName" name="companyName" />
			  </label>
			  
			  <label class="blockLabel" for="contactName">
		 		Contact Name<span>*</span>
				<input type="text" id="contactName" name="contactName" />
			  </label>  
			  
			  <label class="blockLabel" for="phone">
				Phone
				<input type="text" id="phone" name="phone" />
			 </label>
		
			  <label class="blockLabel" for="email">
		 		Email<span>*</span>
				<input type="text" id="email" name="email" />
			  </label> 
			
			 <label class="blockLabel" for="street">
				Street Address<span>*</span>
				<input type="text" id="street" name="street" />	
			 </label>
				
			 <label class="indentLabel" for="city">
		 		City<span>*</span>
		 		<input type="text" id="city" name="city" />
			 </label>
			
			 <label for="state">
				State<span>*</span>
		 		<input type="text" id="state" name="state" maxlength="2" />	
			 </label>
			
			 <label for="zip">
				ZIP<span>*</span>
				<input type="text" id="zip" name="zip" maxlength="10" />
			 </label><br/><br/>
			 
			 <label for="quantitys">
				Computer Quantity<span>*</span>
				<select id="quantitys" name="quantitys"  >
					<option value=""></option>
				</select>
			 </label>
	    </div>
	 	
                <div id="ind" style="display: none" >
			  <label class="blockLabel" for="firstName">
				First Name<span>*</span>
				<input type="text" id="firstName" name="firstName" />
			  </label>
			  
			  <label class="blockLabel" for="lastName">
		 		Last Name<span>*</span>
				<input type="text" id="lastName" name="lastName" />
			  </label>  
			  
			  <label class="blockLabel" for="phone">
				Phone
				<input type="text" id="phone" name="phone" />
			 </label>
		
			  <label class="blockLabel" for="email">
		 		Email<span>*</span>
				<input type="text" id="email" name="email" />
			  </label> 
			
			 <label class="blockLabel" for="street">
				Street Address<span>*</span>
				<input type="text" id="street" name="street" />	
			 </label>
				
			 <label class="indentLabel" for="city">
		 		City<span>*</span>
		 		<input type="text" id="city" name="city" />
			 </label>
			
			 <label for="state">
				State<span>*</span>
		 		<input type="text" id="state" name="state" maxlength="2" />	
			 </label>
			
			 <label for="zip">
				ZIP<span>*</span>
				<input type="text" id="zip" name="zip" maxlength="10" />
			 </label><br/><br/>
			 
			 <label for="quantity">
				Computer Quantity<span>*</span>
				<select id="quantity" name="quantity"  >
					<option value=""></option>
				</select>
			 </label>
	  </div>
	 </fieldset>

	 
	 <div>
		<label for="submitBtn">Submit <input type="button" value="Submit" onclick="submitForm();" id="submitBtn"/></label>
		&nbsp;&nbsp;&nbsp;&nbsp;<label for="cancelBtn">Cancel <input type="reset" value="Cancel"  id="cancelBtn"/></label>
	</div>
	
	</form>
	
</div>
</div>
</body>
</html>

javascript file:

//collects the data
 function submitForm() {
	document.getElementById('apply').submit();
        clearForm();
}
//clears the form
 function clearForm(){

  	var i;
        for (i = 0; (i < document.forms.length); i++) {
         document.forms[i].reset();
  }
}

//create the  drop down list
function addOption(selectbox,text,value ){
	var optn = document.createElement("option");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}

function addOption_list(){
	var quan = new Array("1","2","3","4","5+");
	for (var i=0; i < quan .length;++i){
	
	addOption(document.apply.quantity, quan[i], quan[i]);
	}
}

function addOption_list2(){
	var quan = new Array("1","2","3","4","5","6","7","8","9","10+" );
	for (var i=0; i < quan.length;++i){
	
	addOption(document.apply.quantitys, quan[i], quan[i]);
	}
}

//switches between divs when one of the radio button is checked
  function toggle(obj) {
    var busDiv = document.getElementById('busi');
    var indDiv = document.getElementById('ind');

        if (obj.value == 'business'){
            busDiv.style.display = '';
            indDiv.style.display = 'none';
        }          
        else{
            busDiv.style.display = 'none';
            indDiv.style.display = '';
        }
      	                      
  }

Dani AI

Generated

A short, practical roadmap and a few fixes to get that form writing into a database (notes tie back to earlier replies from , and ).

The current form uses a mailto: action and client-side submission, so a server-side endpoint is required to insert into any database. The simplest, most portable path is what and suggested: switch to a server-side stack (PHP + MySQL) and post the form to a script that validates, sanitizes and INSERTs the data. If the environment must stay on Windows and Access (as noted), Access can work but needs ODBC/OLEDB on the server and has concurrency, driver and permission caveats — it’s not recommended for public/high-traffic sites.

Concrete checklist (apply in order):

  • Change form action from mailto: to something like action="submit.php" and use method="post" (remove enctype="text/plain"). Ensure every input has a proper unique name (avoid duplicate IDs).
  • When toggling business vs individual fields, disable the inactive inputs (set disabled) so only the intended fields are submitted — otherwise duplicate names will send confusing values.
  • On the server use prepared statements and parameterized queries. Example (PHP + PDO for MySQL):
<?php
// submit.php (illustration)
$data = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
$pdo = new PDO('mysql:host=localhost;dbname=donations;charset=utf8mb4','dbuser','dbpass',[PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION]);
$stmt = $pdo->prepare('INSERT INTO donors (type,company,contact,email,phone,street,city,state,zip,qty) VALUES (?,?,?,?,?,?,?,?,?,?)');
$stmt->execute([$data['donerType'],$data['companyName'],$data['contactName'],$data['email'],$data['phone'],$data['street'],$data['city'],$data['state'],$data['zip'],$data['quantity'] ?? $data['quantitys']]);

Access-specific cautions: use a DSN or DSN-less ODBC/OLEDB connection on IIS, ensure correct 32/64‑bit driver, give the IIS user write permissions to the .mdb/.accdb folder, and expect limited concurrency. For any server-side failures, check web-server error logs, confirm DB user privileges, and test inserts with a minimal script before integrating form logic.

Recommended Answers

All 3 Replies

As 'Agarsia' said, you would need to learn a different language for that, and I agree, PHP & MySql is a good choice...

When you are using Microsoft Access databasen, its very simple to config, but much "heavier".

Learn yourself:
Connecting to a mysql-database.
INSERT INTO.

then use the SELECT command to get out the data from the database.

Hope this helps!

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.