By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,415 Members | 1,568 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,415 IT Pros & Developers. It's quick & easy.

insert html web page/form to sql database

P: 23
hi my knowledgeable comrads

I have created a web form using html, css with the addition of some basic javascript validation. Although now im having trouble to insert this information to my local SQL database - can someone point me in the right direction please or refer me to a good example/pre written code?

I am using Vista Business operating system in conjunction with SQL server 2005 express edition, SQL server service pack 2, SQL server management studio express. SQL is installed and setup properly but really confused on how to go about inserting the web form fields in to my sql database?

my webform code is as follows;

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>webform</title>
  6. <link rel="stylesheet" href="includes/divs.css" style="text/css" />
  7. <link rel="stylesheet" href="includes/text.css" style="text/css" />
  8.  
  9. <script type="text/javascript">
  10. <!--
  11.  
  12.     function validate_form ( )
  13.     {
  14.     valid = true;
  15.  
  16.     if ( document.contact_form1.txtAmount.selectedIndex == 0 ) 
  17.     { 
  18.         alert ( "Please select how much you would like to borrow!" ); 
  19.         valid = false; 
  20.     }
  21.  
  22.     if ( document.contact_form1.txtPurpose.selectedIndex == 0 ) 
  23.     { 
  24.         alert ( "Please select purpose of loan" ); 
  25.         valid = false; 
  26.     }
  27.  
  28.     if ( document.contact_form1.txtResidentialStatus.selectedIndex == 0 ) 
  29.     { 
  30.         alert ( "Please select your residential status" ); 
  31.         valid = false; 
  32.     }
  33.  
  34.     if ( document.contact_form2.txtTitle.selectedIndex == 0 ) 
  35.     { 
  36.         alert ( "Please select an appropriate title" ); 
  37.         valid = false; 
  38.     }
  39.  
  40.     if ( document.contact_form2.txtFirstName.value == "" )
  41.     {
  42.         alert ( "Please fill in your First Name" );
  43.         valid = false;
  44.     }
  45.  
  46.     if ( document.contact_form2.txtSurname.value == "" )
  47.     {
  48.         alert ( "Please fill in your Surname" );
  49.         valid = false;
  50.     }
  51.  
  52.     if ( document.contact_form2.txtContactNumber.value == "" )
  53.     {
  54.         alert ( "Please enter a daytime contact number" );
  55.         valid = false;
  56.     }
  57.  
  58.     if ( document.contact_form2.txtEveningNumber.value == "" )
  59.     {
  60.         alert ( "Please enter an evening contact number" );
  61.         valid = false;
  62.     }
  63.  
  64.     if ( document.contact_form2.txtEmailAddress.value == "" )
  65.     {
  66.         alert ( "Please enter your email address" );
  67.         valid = false;
  68.     }
  69.  
  70.     if ( document.contact_form2.change_supplier[0].checked == false ) 
  71.     { 
  72.         alert ( "Please check 'Yes' or 'No' if you are interested in switching energy suppliers" ); 
  73.         valid = false;
  74.     } 
  75.  
  76.         if ( document.contact_form2.change_supplier[1].checked == false ) 
  77.     { 
  78.         alert ( "Please check 'Yes' or 'No' if you are interested in switching energy suppliers" ); 
  79.         valid = false;
  80.     } 
  81.  
  82.     if ( document.contact_form2.termsconditions.checked == false ) 
  83.     { 
  84.         alert ( "Please check the Terms & Conditions box." ); 
  85.         valid = false;
  86.     } 
  87.  
  88.     return valid;
  89. }
  90.  
  91. //-->
  92. </script>
  93. </head>
  94. <body>
  95. <div id="container">
  96.   <h1>Apply Now!</H1>
  97.   <p> Borrow between 2,000 and 250,000<br />
  98.     Just one short form to get the finance you need</p>
  99.   <div id="loandetails">
  100.     <p class="contentstyle1">Loan Details</p>
  101.     <span class="contentstyle2"> How much would you like to borrow? </span><span class="contentstyle1">(&pound;)</span><br />
  102.     <span class="contentstyle2">Purpose of loan</span><br />
  103.     <span class="contentstyle2">Residential Status</span> </div>
  104.   <!-- Closed loandetails div -->
  105.   <div id="inputbox1">
  106.     <form name="contact_form1" method="post" action="submit.asp" onSubmit="ValidateForm()">
  107.       <select name="txtAmount" id="txtAmount" class="inputboxstyle1" >
  108.         <option value="">Please Select</option>
  109.         <option value="2000" >&pound;2000</option>
  110.         <option value="3000" >&pound;3000</option>
  111.         <option value="4000" >&pound;4000</option>
  112.         <option value="5000" >&pound;5000</option>
  113.       </select><span class="asterisk"> * </span>
  114.       <br />
  115.       <select name="txtPurpose" id="txtPurpose" class="inputboxstyle1">
  116.         <option value="" selected="selected">Please Select</option>
  117.         <option value="Consolidation"         >Consolidation</option>
  118.         <option value="Home Improvements"     >Home Improvements</option>
  119.         <option value="Holiday"             >Holiday</option>
  120.       </select><span class="asterisk"> * </span>
  121.       <br />
  122.       <select name="txtResidentialStatus" id="txtResidentialStatus" class="inputboxstyle1" onChange="selectChange()">
  123.         <option value="" selected="selected">Please Select</option>
  124.         <option value="Home Owner"             >Home Owner</option>
  125.         <option value="Private Tenant"         >Private Tenant</option>
  126.         <option value="Housing Association" >Housing Association</option>
  127.       </select><span class="asterisk"> * </span>
  128.     </form>
  129.   </div>
  130.   <!-- Closed inputbox1 div -->
  131.   <div id="personaldetails">
  132.     <p class="contentstyle1">Personal Details</p>
  133.     <span class="contentstyle2">Title</span><br />
  134.     <span class="contentstyle2">First name</span><br />
  135.     <span class="contentstyle2">Surname</span><br />
  136.     <span class="contentstyle2">Daytime contact number</span><br />
  137.     <span class="contentstyle2">Evening contact number</span><br />
  138.     <span class="contentstyle2">Email address</span><br /><br />
  139.     <span class="contentstyle3">Would you be interested in saving up to </span>
  140.     <span class="contentstyle4">&pound;360 </span> <span class="contentstyle3">per year by switching energy suppliers?</span><br />
  141.   </div>
  142.   <!-- Closed personaldetails div -->
  143.   <div id="inputbox2">
  144.   <form name="contact_form2" method="post" action="submit.asp" onSubmit="return validate_form ( );">
  145.     <select name="txtTitle" class="inputboxstyle1" style="width:90px;">
  146.       <option value="">Select...</option>
  147.       <option value="Mr"   >Mr</option>
  148.       <option value="Mrs"  >Mrs</option>
  149.       <option value="Ms"   >Ms</option>
  150.     </select><span class="asterisk"> * </span>
  151.     <input name="txtFirstName" id="txtFirstName"  maxlength="30" class="inputboxstyle2" type="text" value="" />
  152.     <span class="asterisk"> * </span> 
  153.     <input name="txtSurname" id="txtSurname" maxlength="30" class="inputboxstyle2" type="text" value="" />
  154.     <span class="asterisk"> * </span>
  155.     <input name="txtContactNumber" id="txtContactNumber" maxlength="15"class="inputboxstyle2" type="text" value="" />
  156.     <span class="asterisk"> * </span>
  157.     <input name="txtEveningNumber"id="txtEveningNumber" maxlength="15" class="inputboxstyle2" type="text" value="" />
  158.     <span class="asterisk"> * </span>
  159.     <input name="txtEmailAddress" id="txtEmailAddress"  maxlength="50" class="inputboxstyle2" type="text" value="" />
  160.     <span class="asterisk"> * </span>
  161.     <input type="radio" style="margin-top:30px; width:15px;" name="change_supplier" class="inputboxstyle2" value="1"  />
  162.     <span class="contentstyle4">No</span>
  163.     <input  type="radio" style="margin-top:30px; width:15px;" name="change_supplier" value="0" />
  164.     <span class="contentstyle4">Yes</span>
  165.     </div>
  166.     <!-- Closed inputbox2 div -->
  167.     <div id="terms">
  168.     <input type="checkbox" name="termsconditions" style="margin-left:20px; margin-top:13px" value="yes"  />
  169.     <span class="termsstyle1">Tick here to agree to our <a href="javascript:MM_openBrWindow('pop_terms.asp');"> terms & conditions.</a> By ticking this box you agree to be contacted by a loan specialist.</span><br />
  170.     <span class="termsstyle3">Please check your details are correct before you proceed.</span><br /><br />
  171.     <input style="CURSOR: pointer"  type="image" src="http://bytes.com/images/submit.jpg" value="Submit" class="termsstyle4" name="Submit Button" title="Submit Your Application">
  172.   </form>
  173. </div> <!-- Closed terms div -->
  174. </div> <!-- Closed container div -->
  175. </body>
  176. </html>
  177.  
Jan 2 '09 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.