473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

SQL tables

MSM
Hello, I am using php to create a form. I would like that forms
information to go into a database. When creating tables where the
information that i entered into the form will be stored, where exactly
do i place the code for creating the tables. Do I have to create a new
php file? and how do i link the information from the form to the
tables. Please go easy on me I am brand new to PHP and SQL. here is
the code that i have so far for the form if this helps any. Thank you
for any help that you can provide.
//////

<html>

<title>Service Station</title>
</head>
<!--checks to see if all field are entered-->
<SCRIPT language="JavaScript">
<!--
function validateSelect(){
var errors="";
var form = document.customer;

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.province;
if(province.value==""){
errors+="\nYou must enter a province name.";
}

var phone=form.phone;
if(phone.value==""){
errors+="\nYou must enter the phone number's area code.";
}

var phone2=form.phone2;
if(phone2.value==""){
errors+="\nYou must enter the phone number's next three
digits.";
}

var phone3=form.phone3;
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.model;
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.color;
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.towing;
if(towing.value==""){
errors+="\nYou must enter towing cost.";
}

var subcontract=form.subcontract;
if(subcontract.value==""){
errors+="\nYou must enter subcontract.";
}

var environmental=form.environmental;
if(environmental.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.lname;
if(lname.value==""){
errors+="\nYou must enter the first name of the laborer.";
}

var lname2=form.lname2;
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"+errors+"\n\nPlease make changes and submit the form
again.");
}
document.MM_returnValue = (errors == "");

}

function TotalCost(field){

var c=eval(document.customer.cost.value);
var t=eval(document.customer.towing.value);
var s=eval(document.customer.subcontract.value);
var e=eval(document.customer.environmental.value);

var tax=document.customer.taxes.value=(c+t+s+e)*0.15;
var total=document.customer.total.value=(c+t+s+e)+tax;

document.customer.taxes.value=Math.round(tax*100)/100;
document.customer.total.value=Math.round(total*100 )/100;
}
//-->
</SCRIPT>
<body BGCOLOR=GRAY>
<?
//the current date
print " <b> ".date("F d, Y")." <br>
<br>
";
?>
<?=$errormessage?>
<br>

<!--<form action="?=$_SERVER['PHP_SELF']?>
http://localhost/meaneyPHP/output.php" method="post">
//-->
<!--<form name="customer" "action="?=$_SERVER['PHP_SELF']?>"
method="post" onSubmit="validateSelect();return
document.MM_returnValue">
//-->
<form name="customer" action="CustomerInfo.php" method="post"
onSubmit="validateSelect();return document.MM_returnValue">
<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="<?$province=$_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="<?$phone2=$_POST['phone2']?>">
<input type="integer" name="phone3" size=4 maxlength=4
value="<?$phone3=$_POST['phone3']?>"></td></tr>

<tr><td>Vehicle Make:</td><td><input type="text" name="make"
value="<?$make=$_POST['make']?>"></td></tr>
<tr><td>Vehicle Model:</td><td><input type="text" name="model"
value="<?$model=$_POST['model']?>"></td></tr>
<tr><td>Vehicle Year:</td><td><input type="text" name="year"
value="<?$year=$_POST['year']?>"></td></tr>
<tr><td>Vehicle 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="TotalCost(this);" value="<?$cost=$_POST['cost']?>">
<tr><td>Towing:</td><td><input type="text" name="towing" size=10
value="0" onBlur="TotalCost(this);"
value="<?$towing=$_POST['towing']?>">
<tr><td>Subcontract:</td><td><input type="text" name="subcontract"
size=10 value="0" onBlur="TotalCost(this);"
value="<?$subcontract=$_POST['subcontract']?>">
<tr><td>Environmental:</td><td><input type="text" name="environmental"
size=10 value="0" onBlur="TotalCost(this);"
value="<?$enviromental=$_POST['environmental']?>">
<tr><td>Taxes:</td><td><input type="text" name="taxes" size=10
value="0" onBlur="TotalCost(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>Labour by:&nbsp<i>first</i></td><td><input type="text"
name="lname" value="<?$lname =$_POST['lname']?>">
<i>last</i><input type="text" name="lname2"
value="<?$lname2=$_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=$_POST['effort'];

?>
<tr><td>Payment by:</tr></td>
<tr><td><input type=radio name='effort' value=Cash checked<?php
if($p_effort==Cash) echo "checked"; ?>>Cash</tr></td>
<tr><td><input type=radio name='effort' value=Visa <?php
if($p_effort==Visa) echo "checked"; ?>>Visa
<tr><td><input type=radio name='effort' value=MasterCard<?php
if($p_effort==MasterCard) echo "checked"; ?>>Master Card</tr></td>
<tr><td><input type=radio name='effort' value=AMEX<?php
if($p_effort==AMEX) 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>
Jul 17 '05 #1
2 2111
MSM wrote:
where exactly
do i place the code for creating the tables.


You should go into your database directly, and create the table there.
Use the PHP code to INSERT ot UPDATE data into the table.

The form's ACTION should point to a .php page that executes the following:

1) Reads the data from the form. Either $_POST or $_GET.
2) Opens a connection to your database.
3) Constructs a SQL statement to INSERT or UPDATE a table.
4) Queries the database.

Google "PHP SQL tutorials".

--
Sugapablo
------------------------------------
http://www.sugapablo.com <--music
http://www.sugapablo.net <--personal

Jul 17 '05 #2
m_******@yahoo.com (MSM) wrote in message news:<5e**************************@posting.google. com>...
Hello, I am using php to create a form. I would like that forms
information to go into a database. When creating tables where the
information that i entered into the form will be stored, where exactly
do i place the code for creating the tables


This is the greatest tool for managing databases since sliced bread was invented:
http://www.exxatools.com/SQLion.html

Regards
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
by: Mariusz Jedrzejewski | last post by:
Hi, I'll be very grateful if somebody can explain me why my Opera 7.23 (runing under linux) doesn't show me inner tables. Using below code I can see only "inner table 1". There is no problem with...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
2
by: Jill Elaine | last post by:
I am building an Access 2002 frontend with linked tables to an encrypted Paradox 7 database. When I first create these linked tables, I'm asked for the password to the encrypted Paradox database,...
1
by: Shelby | last post by:
Problem: My company generates its own data export from a propietary database. These (free) tables can be read in C#.NET using a Visual FoxPro driver (vfpoledb). I can read each of the six tables...
59
by: phil-news-nospam | last post by:
In followups by Brian O'Connor (ironcorona) to other posts, he repeats the idea that using tables in CSS is not something that should be done because IE doesn't support it. Of course I'm not happy...
5
by: rdemyan via AccessMonster.com | last post by:
I have a need to add another field to all of my tables (over 150). Not data, but an actual field. Can I code this somehow. So the code presumabley would loop through all the tables, open each...
4
by: db2admin | last post by:
Hello, I want to plan rearranging tables in our database according to business areas. say all tables in business area A will be in seperate tablespace or tablespaces. I am planning to monitor...
25
by: bubbles | last post by:
Using Access 2003 front-end, with SQL Server 2005 backend. I need to make the front-end application automatically refresh the linked SQL Server tables. New tables will be added dynamically in...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.