Click here to Skip to main content
15,888,010 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my design
..................

XML
<table width="426" height="176" border="1">
       <caption>
         CUSTOMER REGISTRATION
       </caption>
       <tr>
         <td width="110">Customer ID</td>
         <td width="300"><form id="form5" name="form5" method="post" action="">
             <label for="cust_id"></label>
             <input type="text" name="cust_id" id="cust_id" />
         </form></td>
       </tr>
       <tr>
         <td>Customer Name</td>
         <td><form id="form6" name="form6" method="post" action="">
             <label for="cust_name"></label>
             <input type="text" name="cust_name" id="cust_name" />
         </form></td>
       </tr>
       <tr>
         <td>User name</td>
         <td><form id="form12" name="form12" method="post" action="">
           <input type="text" name="u" id="u" />
         </form>         </td>
       </tr>
       <tr>
         <td>Password</td>
         <td><form id="form13" name="form13" method="post" action="">
           <input type="text" name="p" id="p" />
         </form>         </td>
       </tr>
       <tr>
         <td>Customer Department</td>
         <td><form id="form7" name="form7" method="post" action="">
             <label for="cust_dep"></label>
             <input type="text" name="cust_dep" id="cust_dep" />
         </form></td>
       </tr>
       <tr>
         <td>Customer type</td>
         <td><form id="form8" name="form8" method="post" action="">
             <input type="radio" name="radio" id="staff" value="staff" />
             <label for="staff">Staff</label>
             <input type="radio" name="radio" id="Trainee" value="Trainee" />
             <label for="Trainee">Trainee</label>
             <input type="radio" name="radio" id="others" value="others" />
             <label for="others">Others</label>
         </form></td>
       </tr>
       <tr>
         <td>Customer Adress</td>
         <td><form id="form10" name="form10" method="post" action="">
             <label for="cust_add"></label>
             <textarea name="cust_add" id="cust_add" cols="45" rows="5"></textarea>
         </form></td>
       </tr>
       <tr>
         <td>Customer E-mail</td>
         <td><form id="form11" name="form11" method="post" action="">
             <label for="cust_email"></label>
             <input type="text" name="cust_email" id="cust_email" />
         </form></td>
       </tr>
       <tr>
         <td>Customer Phone number</td>
         <td><form id="form9" name="form9" method="post" action="">
             <label for="cust_phone"></label>
             <input type="text" name="cust_phone" id="cust_phone" />
         </form></td>
       </tr>
     </table>



my connection
..............................

PHP
<?php
$con = mysql_connect("localhost","root","");
mysql_select_db("project", $con);
$id =$_POST['cust_id'];
$name =$_POST['cust_name'];
$user =$_POST['u'];
$pass =$_POST['p'];
$dep =$_POST['cust_dep'];
$type =$_POST['radio'];
$add =$_POST['cust_add'];
$email =$_POST['cust_email'];
$phn =$_POST['cust_phone'];

if(@$_POST['submit'])
{
echo $s="insert into employee(cust_id,cust_name,username,password,cust_dep,customertype,address,email,phone) values('$id','$name','$user','$pass','$dep','$type','$add','$email','$phn')";
echo "Your Data Inserted";
mysql_query($s);
}
else
echo "error";
?>
Posted

1 solution

I can see a few problems here:

1. You are using multiple forms - only the inputs that are inside a single form tag will be sent to the server. Use a single form around all of your inputs. You cannot nest forms either.

2. Your form action="" is empty - this should contain the URL of the page that processes your form.

3. I don't see a submit button in the code that you supplied, but that must go inside the form too.

4. You are not checking to see if the MySQL connection worked before selecting the database and inserting data.

5. You are not cleaning the input before building a SQL query with it. Search for "SQL injection" to find out why this is bad.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900