Hello, This may be posted twice if so i apologize. I am creating a
form using php where the information entered into the form will go
into a database. When creating the tables in SQL where do I place the
code for creating the tables? How do I link the form's information to
the tables. Any help with this would be greatly appreciated. Below
is the code for the form I hope this can assist you in helping me.
Thank you so much.
//here it is.
<html>
<title>Servic e Station</title>
</head>
<!--checks to see if all field are entered-->
<SCRIPT language="JavaS cript">
<!--
function validateSelect( ){
var errors="";
var form = document.custom er;
var first = form.first;
if(first.value= =""){
errors+="\nYou must enter a first name.";
}
var last = form.last;
if(last.value== ""){
errors+="\nYou must enter a last name.";
}
var add=form.add;
if(add.value==" "){
errors+="\nYou must enter an address.";
}
var city=form.city;
if(city.value== ""){
errors+="\nYou must enter a city name.";
}
var province=form.p rovince;
if(province.val ue==""){
errors+="\nYou must enter a province name.";
}
var phone=form.phon e;
if(phone.value= =""){
errors+="\nYou must enter the phone number's area code.";
}
var phone2=form.pho ne2;
if(phone2.value ==""){
errors+="\nYou must enter the phone number's next three
digits.";
}
var phone3=form.pho ne3;
if(phone3.value ==""){
errors+="\nYou must enter the phone number's last four
digits.";
}
var make=form.make;
if(make.value== ""){
errors+="\nYou must enter the make of the vehicle.";
}
var model=form.mode l;
if(model.value= =""){
errors+="\nYou must enter the model of the vehicle.";
}
var year=form.year;
if(year.value== ""){
errors+="\nYou must enter the year of the vehicle.";
}
var color=form.colo r;
if(color.value= =""){
errors+="\nYou must enter the color of the vehicle.";
}
var cost=form.cost;
if(cost.value== ""){
errors+="\nYou must enter the cost.";
}
var towing=form.tow ing;
if(towing.value ==""){
errors+="\nYou must enter towing cost.";
}
var subcontract=for m.subcontract;
if(subcontract. value==""){
errors+="\nYou must enter subcontract.";
}
var environmental=f orm.environment al;
if(environmenta l.value==""){
errors+="\nYou must enter the environmental." ;
}
var date=form.date;
if(date.value== ""){
errors+="\nYou must enter the date of service.";
}
var time=form.time;
if(time.value== ""){
errors+="\nYou must enter the time of service.";
}
var lname=form.lnam e;
if(lname.value= =""){
errors+="\nYou must enter the first name of the laborer.";
}
var lname2=form.lna me2;
if(lname2.value ==""){
errors+="\nYou must enter the last name of the laborer.";
}
if (errors) {
alert("The form was not submitted due to the following
error(s):\n"+er rors+"\n\nPleas e make changes and submit the form
again.");
}
document.MM_ret urnValue = (errors == "");
}
function TotalCost(field ){
var c=eval(document .customer.cost. value);
var t=eval(document .customer.towin g.value);
var s=eval(document .customer.subco ntract.value);
var e=eval(document .customer.envir onmental.value) ;
var tax=document.cu stomer.taxes.va lue=(c+t+s+e)*0 .15;
var total=document. customer.total. value=(c+t+s+e) +tax;
document.custom er.taxes.value= Math.round(tax* 100)/100;
document.custom er.total.value= Math.round(tota l*100)/100;
}
//-->
</SCRIPT>
<body BGCOLOR=GRAY>
<?
//the current date
print " <b> ".date("F d, Y")." <br>
<br>
";
?>
<?=$errormessag e?>
<br>
<!--<form action="?=$_SER VER['PHP_SELF']?>
http://localhost/meaneyPHP/output.php" method="post">
//-->
<!--<form name="customer" "action="?=$_SE RVER['PHP_SELF']?>"
method="post" onSubmit="valid ateSelect();ret urn
document.MM_ret urnValue">
//-->
<form name="customer" action="Custome rInfo.php" method="post"
onSubmit="valid ateSelect();ret urn document.MM_ret urnValue">
<table border="0" cellpadding="0" cellspacing="0" >
<tr><td>First Name:</td><td><input type="text" name="first"
value="<?$first =$_POST['first']?>">
Last Name:<input type="text" name="last"
value="<?$last= $_POST['last']?>">
</td></tr>
<tr><td>Address :</td><td><input type="text" name="add" size=50
value="<?$add=$ _POST['add']?>"></td></tr>
<tr><td>City: </td><td><input type="text" name="city" size=20
value="<?$city= $_POST['city']?>">
Province:<input type="text" name="province" size=3 maxlength=2
value="<?$provi nce=$_POST['province']?>"></td></tr>
<tr><td>Phone Number:</td><td><input type="integer" name="phone"
size=3 maxlength=3 value="<?$phone =$_POST['phone']?>">
<input type="integer" name="phone2" size=3 maxlength=3
value="<?$phone 2=$_POST['phone2']?>">
<input type="integer" name="phone3" size=4 maxlength=4
value="<?$phone 3=$_POST['phone3']?>"></td></tr>
<tr><td>Vehic le Make:</td><td><input type="text" name="make"
value="<?$make= $_POST['make']?>"></td></tr>
<tr><td>Vehic le Model:</td><td><input type="text" name="model"
value="<?$model =$_POST['model']?>"></td></tr>
<tr><td>Vehic le Year:</td><td><input type="text" name="year"
value="<?$year= $_POST['year']?>"></td></tr>
<tr><td>Vehic le Color:</td><td><input type="text" name="color"
value="<?$color =$_POST['color']?>"></td></tr>
<tr><td>Cost: </td><td><input type="text" name="cost" size=10 value="0"
onBlur="TotalCo st(this);" value="<?$cost= $_POST['cost']?>">
<tr><td>Towing: </td><td><input type="text" name="towing" size=10
value="0" onBlur="TotalCo st(this);"
value="<?$towin g=$_POST['towing']?>">
<tr><td>Subcont ract:</td><td><input type="text" name="subcontra ct"
size=10 value="0" onBlur="TotalCo st(this);"
value="<?$subco ntract=$_POST['subcontract']?>">
<tr><td>Environ mental:</td><td><input type="text" name="environme ntal"
size=10 value="0" onBlur="TotalCo st(this);"
value="<?$envir omental=$_POST['environmental']?>">
<tr><td>Taxes :</td><td><input type="text" name="taxes" size=10
value="0" onBlur="TotalCo st(this);"
value="<?$taxes =$_POST['taxes']?>">
<tr><td>Date Serviced:</td><td><input type="text" name="date"
value="<?$date= $_POST['date']?>">
Time:<input type="text" name="time" size=7
value="<?$time= $_POST['time']?>"></td></tr>
<tr><td>Labou r by: <i>firs t</i></td><td><input type="text"
name="lname" value="<?$lname =$_POST['lname']?>">
<i>last</i><input type="text" name="lname2"
value="<?$lname 2=$_POST['lname2']?>">
</td></tr>
<tr><td>Total Cost:</td><td><input type="text" name="total" size=10
value="<?$total =$_POST['total']?>"><i>Taxes Included</i>
<?php
//Type of payment
$p_effort=$_POS T['effort'];
?>
<tr><td>Payme nt by:</tr></td>
<tr><td><inpu t type=radio name='effort' value=Cash checked<?php
if($p_effort==C ash) echo "checked"; ?>>Cash</tr></td>
<tr><td><inpu t type=radio name='effort' value=Visa <?php
if($p_effort==V isa) echo "checked"; ?>>Visa
<tr><td><inpu t type=radio name='effort' value=MasterCar d<?php
if($p_effort==M asterCard) echo "checked"; ?>>Master Card</tr></td>
<tr><td><inpu t type=radio name='effort' value=AMEX<?php
if($p_effort==A MEX) echo "checked"; ?>>AMEX</tr></td>
<!--Submit the form -->
<tr><td> <input type="SUBMIT" value="Submit"> </B></tr></td>
<br><br>
<?php
if ($_POST['submit']) {
}
?>
<tr><td><a href= "Search.php " >SEARCH</a><br></tr></td>
</body>
</html>
form using php where the information entered into the form will go
into a database. When creating the tables in SQL where do I place the
code for creating the tables? How do I link the form's information to
the tables. Any help with this would be greatly appreciated. Below
is the code for the form I hope this can assist you in helping me.
Thank you so much.
//here it is.
<html>
<title>Servic e Station</title>
</head>
<!--checks to see if all field are entered-->
<SCRIPT language="JavaS cript">
<!--
function validateSelect( ){
var errors="";
var form = document.custom er;
var first = form.first;
if(first.value= =""){
errors+="\nYou must enter a first name.";
}
var last = form.last;
if(last.value== ""){
errors+="\nYou must enter a last name.";
}
var add=form.add;
if(add.value==" "){
errors+="\nYou must enter an address.";
}
var city=form.city;
if(city.value== ""){
errors+="\nYou must enter a city name.";
}
var province=form.p rovince;
if(province.val ue==""){
errors+="\nYou must enter a province name.";
}
var phone=form.phon e;
if(phone.value= =""){
errors+="\nYou must enter the phone number's area code.";
}
var phone2=form.pho ne2;
if(phone2.value ==""){
errors+="\nYou must enter the phone number's next three
digits.";
}
var phone3=form.pho ne3;
if(phone3.value ==""){
errors+="\nYou must enter the phone number's last four
digits.";
}
var make=form.make;
if(make.value== ""){
errors+="\nYou must enter the make of the vehicle.";
}
var model=form.mode l;
if(model.value= =""){
errors+="\nYou must enter the model of the vehicle.";
}
var year=form.year;
if(year.value== ""){
errors+="\nYou must enter the year of the vehicle.";
}
var color=form.colo r;
if(color.value= =""){
errors+="\nYou must enter the color of the vehicle.";
}
var cost=form.cost;
if(cost.value== ""){
errors+="\nYou must enter the cost.";
}
var towing=form.tow ing;
if(towing.value ==""){
errors+="\nYou must enter towing cost.";
}
var subcontract=for m.subcontract;
if(subcontract. value==""){
errors+="\nYou must enter subcontract.";
}
var environmental=f orm.environment al;
if(environmenta l.value==""){
errors+="\nYou must enter the environmental." ;
}
var date=form.date;
if(date.value== ""){
errors+="\nYou must enter the date of service.";
}
var time=form.time;
if(time.value== ""){
errors+="\nYou must enter the time of service.";
}
var lname=form.lnam e;
if(lname.value= =""){
errors+="\nYou must enter the first name of the laborer.";
}
var lname2=form.lna me2;
if(lname2.value ==""){
errors+="\nYou must enter the last name of the laborer.";
}
if (errors) {
alert("The form was not submitted due to the following
error(s):\n"+er rors+"\n\nPleas e make changes and submit the form
again.");
}
document.MM_ret urnValue = (errors == "");
}
function TotalCost(field ){
var c=eval(document .customer.cost. value);
var t=eval(document .customer.towin g.value);
var s=eval(document .customer.subco ntract.value);
var e=eval(document .customer.envir onmental.value) ;
var tax=document.cu stomer.taxes.va lue=(c+t+s+e)*0 .15;
var total=document. customer.total. value=(c+t+s+e) +tax;
document.custom er.taxes.value= Math.round(tax* 100)/100;
document.custom er.total.value= Math.round(tota l*100)/100;
}
//-->
</SCRIPT>
<body BGCOLOR=GRAY>
<?
//the current date
print " <b> ".date("F d, Y")." <br>
<br>
";
?>
<?=$errormessag e?>
<br>
<!--<form action="?=$_SER VER['PHP_SELF']?>
http://localhost/meaneyPHP/output.php" method="post">
//-->
<!--<form name="customer" "action="?=$_SE RVER['PHP_SELF']?>"
method="post" onSubmit="valid ateSelect();ret urn
document.MM_ret urnValue">
//-->
<form name="customer" action="Custome rInfo.php" method="post"
onSubmit="valid ateSelect();ret urn document.MM_ret urnValue">
<table border="0" cellpadding="0" cellspacing="0" >
<tr><td>First Name:</td><td><input type="text" name="first"
value="<?$first =$_POST['first']?>">
Last Name:<input type="text" name="last"
value="<?$last= $_POST['last']?>">
</td></tr>
<tr><td>Address :</td><td><input type="text" name="add" size=50
value="<?$add=$ _POST['add']?>"></td></tr>
<tr><td>City: </td><td><input type="text" name="city" size=20
value="<?$city= $_POST['city']?>">
Province:<input type="text" name="province" size=3 maxlength=2
value="<?$provi nce=$_POST['province']?>"></td></tr>
<tr><td>Phone Number:</td><td><input type="integer" name="phone"
size=3 maxlength=3 value="<?$phone =$_POST['phone']?>">
<input type="integer" name="phone2" size=3 maxlength=3
value="<?$phone 2=$_POST['phone2']?>">
<input type="integer" name="phone3" size=4 maxlength=4
value="<?$phone 3=$_POST['phone3']?>"></td></tr>
<tr><td>Vehic le Make:</td><td><input type="text" name="make"
value="<?$make= $_POST['make']?>"></td></tr>
<tr><td>Vehic le Model:</td><td><input type="text" name="model"
value="<?$model =$_POST['model']?>"></td></tr>
<tr><td>Vehic le Year:</td><td><input type="text" name="year"
value="<?$year= $_POST['year']?>"></td></tr>
<tr><td>Vehic le Color:</td><td><input type="text" name="color"
value="<?$color =$_POST['color']?>"></td></tr>
<tr><td>Cost: </td><td><input type="text" name="cost" size=10 value="0"
onBlur="TotalCo st(this);" value="<?$cost= $_POST['cost']?>">
<tr><td>Towing: </td><td><input type="text" name="towing" size=10
value="0" onBlur="TotalCo st(this);"
value="<?$towin g=$_POST['towing']?>">
<tr><td>Subcont ract:</td><td><input type="text" name="subcontra ct"
size=10 value="0" onBlur="TotalCo st(this);"
value="<?$subco ntract=$_POST['subcontract']?>">
<tr><td>Environ mental:</td><td><input type="text" name="environme ntal"
size=10 value="0" onBlur="TotalCo st(this);"
value="<?$envir omental=$_POST['environmental']?>">
<tr><td>Taxes :</td><td><input type="text" name="taxes" size=10
value="0" onBlur="TotalCo st(this);"
value="<?$taxes =$_POST['taxes']?>">
<tr><td>Date Serviced:</td><td><input type="text" name="date"
value="<?$date= $_POST['date']?>">
Time:<input type="text" name="time" size=7
value="<?$time= $_POST['time']?>"></td></tr>
<tr><td>Labou r by: <i>firs t</i></td><td><input type="text"
name="lname" value="<?$lname =$_POST['lname']?>">
<i>last</i><input type="text" name="lname2"
value="<?$lname 2=$_POST['lname2']?>">
</td></tr>
<tr><td>Total Cost:</td><td><input type="text" name="total" size=10
value="<?$total =$_POST['total']?>"><i>Taxes Included</i>
<?php
//Type of payment
$p_effort=$_POS T['effort'];
?>
<tr><td>Payme nt by:</tr></td>
<tr><td><inpu t type=radio name='effort' value=Cash checked<?php
if($p_effort==C ash) echo "checked"; ?>>Cash</tr></td>
<tr><td><inpu t type=radio name='effort' value=Visa <?php
if($p_effort==V isa) echo "checked"; ?>>Visa
<tr><td><inpu t type=radio name='effort' value=MasterCar d<?php
if($p_effort==M asterCard) echo "checked"; ?>>Master Card</tr></td>
<tr><td><inpu t type=radio name='effort' value=AMEX<?php
if($p_effort==A MEX) echo "checked"; ?>>AMEX</tr></td>
<!--Submit the form -->
<tr><td> <input type="SUBMIT" value="Submit"> </B></tr></td>
<br><br>
<?php
if ($_POST['submit']) {
}
?>
<tr><td><a href= "Search.php " >SEARCH</a><br></tr></td>
</body>
</html>