Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default SQL tables

    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>
    MSM Guest

  2. Similar Questions and Discussions

    1. Tables - do we really need them?
      Are tables and using them just for beginners and newbies? Everything i have built in HTML works just fine using tables but i do find it a little...
    2. SQL tables help
      I have a CF calendar application that I want to replicate, so it involves copying one SQL database to another. There are 10 SQL databases that I...
    3. one or two tables
      Hello, I'd like to hear what you think about the following - We have an application (database plus software) that is used as a central...
    4. XML and Tables
      Is it possible to put formatting in the XML-file then? So I can generate the format from my program which makes the XML-file... Or can I solve...
    5. Look up Tables
      Do you relate look-up table in sql server 2000? Example: MEMBER TABLE STATE TABLE MemberID StateID State ...
  3. #2

    Default Re: SQL tables

    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
    ------------------------------------
    [url]http://www.sugapablo.com[/url] <--music
    [url]http://www.sugapablo.net[/url] <--personal

    Sugapablo Guest

  4. #3

    Default Re: SQL tables

    [email]m_meaney@yahoo.com[/email] (MSM) wrote in message news:<5e83541e.0309180900.6f0a11f4@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:
    [url]http://www.exxatools.com/SQLion.html[/url]

    Regards
    george Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139