Solved

I am trying to submit a form to the database the form is written in html

Posted on 2012-04-05
5
267 Views
Last Modified: 2012-04-17
I am trying to submit a form to the database the form is written in HTML. I have a submit button, a new button and exit button.

1. How do I validate the column in the form using CSS

2. What do I code in html or css when the user hit the new button it reset the page

3. what do I code when the user hit exit the form closes

4. What is the best method to use if I am trying to submit the data to Microsoft Sql server
what should I be using asp.net , php or java script

what is the best method

and please show me how that code looks that show be in one of those files that submit the data to the database.

Thank you
I am new to this

I am using Dream Weaver cs5
0
Comment
Question by:1030071002
  • 3
5 Comments
 
LVL 25

Assisted Solution

by:Lee Savidge
Lee Savidge earned 167 total points
ID: 37812027
1. You don't validate the form with CSS. You need to have serverside code to process the form.

2. You need a reset button:
<form>
   <input type="reset" value="clear the form" />
</form>

3. I don't know what you mean by this.

4. ASP.NET will be used to create a web page. Codebehind pages written in VB.NET or C# or any other .net language are used to catch the data from the form and process it to push into the database. Javascript is generally a client side scripting language to interact with the page and as such cannot be used to process forms to push data into a database. If you wish to use php you can. There is no reason not to use this language. What languages do you know?

As for showing you the code, well you've asked a rather far reaching question that requires lots of code to explain how to do this. Personally I would start reading some books on it and going through Microsofts endless amounts of information and walkthroughs: http://msdn.microsoft.com/en-us/library/3h7eexxe.aspx

I think you're biting off more than you can chew at the moment, so I would start just by building a static webpage in a .NET language if you wish to go that route or php if you wish to go that route. Then try building a web page with a form so you can try posting the data and catching it serverside. Then I would start looking at how you bind to a datasource like a SQL database and start by trying to read data out. Once you can read data out, try combining the form post with inserting the data into a database.

Good luck.
0
 

Author Comment

by:1030071002
ID: 37812424
come on guy how hard can this be I have already created the form and I have been programming for over 20 years i am just bit knew to the web technology I have attach my form so you can see it
I thought I would create a .php file that would take all my data from the form and save them in a veriable and then save them in a database I am using microsoft sql server 2000. My webserver is windows 2008 rs. I have already install the php software on the webserver to support my form. I just need some example what to code in the php file
to submit my data in the database

registration2.html
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 333 total points
ID: 37812611
If you have a good understanding of the principles of computer science, this tutorial will get you up to speed on the basics of PHP really fast.  See especially the part about "Dealing with Forms."
http://php.net/tut.php
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 333 total points
ID: 37812634
Here is the PHP example, using your form.  Install it and run it to see if it makes sense, then post back with any questions.
<?php // RAY_temp_10300.php
error_reporting(E_ALL);

// THIS IS THE ACTION SCRIPT.  
// NOTE THE RELATIONSHIP BETWEEN THE FORM INPUT NAME ATTRIBUTES
// AND THE ARRAY KEYS in $_POST

// IF THE FORM HAS BEEN SUBMITTED
if (!empty($_POST))
{
    // SHOW THE INFORMATION FROM THE FORM
    echo "<pre>";
    var_dump($_POST);
    echo "</pre>";
    echo PHP_EOL;
}


// THIS IS THE FORM SCRIPT CREATED USING HEREDOC NOTATION
$html = <<<HTML
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>GMG Transportation Registration Form</title>
<meta name="keywords" content="GMG, Trucking, Transportation, GMG Registration, LTL">
<meta name="description" content="One of the premier freight management companies in North America, GMG works with a distinguished network of quality carriers to provide our customers with superior transportation choices. By leveraging the combined freight of all our clients, each client benefits from the volume pricing power of GMG.">

<style type="text/css" media="all">
form{width:730px;margin:0 auto;}
h1{font-size:35px;clear:both;text-align:center;}
h3{background:#F00;color:#fff;font-size:25px;width:104.5%;clear:both;text-align:center;}

fieldset{clear:both;float:left;width:730px;border:1px solid #ccc;margin:5px;}
fieldset legend{font-weight:bold;}
label{float:left;text-align:right;width:150px;margin:7px 0;clear:left;}
input{margin:3px 0;}

input[type="text"]{float:left;width:76.0%;}
input[type="email"]{float:left;width:76.0%;}
input[type="password"]{float:left;width:76.0%;}

input#usr_phone, input#fax, input#cmp_phone, input#cmp_fax, input#billto_phone, input#billto_fax{width:37.3%;}
input#fax, input#cmp_fax, input#billto_fax{margin-left:4px;}
.req{float:left;display:block;color:#F00;clear:right;}
.shortInput{width:24.2% !important;margin-left: 5px;}
.shipBillSame{width:100% !important;float:left !important;clear:none;}
.shipBillSame label{width:100%;text-align:right;float:right;margin-left:5px;}
.buttons{float:left;width:760px;}
#Submit{float:left;}
#New{float:right;}
#Exit{float:right;}

</style>

</head>
<body>
<form id="Reg_Form" method="post">
<h1>My GMG Registration</h1>
<h3>Account Information</h3>
<fieldset> 
  <legend>User Info</legend>
 <label>User Email : </label>
  <input name="usr_email" type="email" align="left" id="usr_email"><span class="req">*</span>
<label>User Password : </label>
<input name="usr_password" type="password" align="left" id="usr_password"><span class="req">*</span>
<label>Contact :</label>
<input name="usr_contact" type="text" id="usr_contact">
<label>User Phone / Fax : </label>
<input name="usr_phone" type="text" id="usr_phone"><input name="fax" type="text" id="fax">

</fieldset>

<fieldset>
<legend>Company</legend>

<label>Name: </label>
<input name="cmp_name" type="text" id="cmp_name"><span class="req">*</span>
<label>Address : </label>
<input name="cmp_Address" type="text" id="cmd_Address" ><span class="req">*</span>
<label>City/State/Zip : </label>
<input name="cmp_city" type="text" id="cmd_city" class="shortInput">
    <input name="cmp_state" type="text" id="cmd_state" class="shortInput"> 
    <input name="zip" type="text" id="zip" class="shortInput"> 
   <label>Contact : </label>
    <input name="cmp_contact" id ="cmp_contact" type="text">
   <label>Email : </label>
    <input name="cmp_email" id= "cmp_email" type="email"><span class="req">*</span>
   <label>Phone/Fax : </label>
    <input name="cmp_phone" id="cmp_phone" type="text"> 
<input name="cmp_fax" type="text" id="cmp_fax"><span class="req">*</span>
</fieldset>

<fieldset class="shipBillSame">
	<label> IF THE CUSTOMER INFO IS THE SAME AS THE BILL TO CLICK THE BOX :
	<input type="checkbox" name="option1" value="match_cmp_billto">
  </label>
</fieldset>


<fieldset>
  
  <legend>Bill To</legend>
<label>Name : </label><input name="billto_name" id="billto_name" type="text" ><span class="req">*</span>
<label>Address : </label>
<input name="billto_Address" id="billto_address" type="text"><span class="req">*</span>
<label>City/State/Zip : </label>
    <input name="billto_city" id="billto_city" type="text" class="shortInput"  />
    <input name="billto_state" id="billto_state" type="text" class="shortInput"  /> 
    <input name="billto_zip" type="text" id="billto_zip" class="shortInput"  /> 
   <label>Contact : </label>
    <input name="billto_contact" id="billto_contact" type="text"><span class="req">*</span>
    <label>Email : </label>
    <input name="billto_Email" id="billto_email" type="text">
<label>Phone/Fax : </label>
<input name="billto_phone" id="billto_phone" type="text"> 
    <input name="billto_fax" id="billto_fax" type="text"><span class="req">*</span></legend>
    
    
</fieldset>
<div class="buttons">
        <input type="submit" name="Submit" id="Submit" value="Submit" tabindex="0">
    <input type="reset" name="New" id="reset" value="reset" tabindex="1">
    <input type="button" name="Exit" id="Exit" value="Close Window" onClick="self.close()" tabindex="2">
</div>
</form> 
</body>
</html>
HTML;

// WRITE THE FORM TO THE BROWSER
echo $html;

Open in new window

Best regards, ~Ray
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37858705
I'd like an explanation of why you marked the grade down to a B, given the fact that you received a tested and working example in response to your question, and you did not ask for any further clarification - you just gave a bad grade.  

What was wrong with the response?  We cannot write your code for you for free; we just answer questions and try to guide your learning process.
http://www.experts-exchange.com/help/viewHelpPage.jsp?helpPageID=26
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now