Showing posts with label insert data into table. Show all posts
Showing posts with label insert data into table. Show all posts

Sunday, December 4, 2011

Simple Registration form

Code Example


Registration.html

<html>
    <head>
        <title>Registration</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <form action="Registration.php">
            <table border="0" cellspacing="14">
                <tr>
                    <th colspan="2">Registration form</th>
                </tr>
                    <tr>
                        <td>First Name</td>
                        <td><input type="text" name="fname" value="" /></td>
                    </tr>
                    <tr>
                        <td>Last Name</td>
                        <td><input type="text" name="lname" value="" /></td>
                    </tr>
                    <tr>
                        <td>Email ID</td>
                        <td><input type="text" name="email" value="" /></td>
                    </tr>
                    <tr>
                        <td>Date Of Birth</td>
                        <td><input type="text" name="dob" value="" /></td>
                    </tr>
                    <tr>
                        <td>Phone no: </td>
                        <td><input type="text" name="phone" value="" /></td>
                    </tr>
                    <tr>
                        <td>Address</td>
                        <td><input type="text" name="address" value="" /></td>
                    </tr>
                     <tr>
                        <td>Gender</td>
                        <td><input type="radio" name="gender" value="male" />Male<input type="radio" name="gender" value="female" />Female</td>
                    </tr>
                    <tr>
                        <td colspan="2" align="center"><input type="submit" value="   Submit  " /></td>
                    
                    </tr>
                
            </table>

        </form>
    </body>
</html>

Registration.php

<?php
    //accessing data from form 

    $fname=$_GET['fname'];
    $lname=$_GET['lname'];
    $email=$_GET['email'];
    $dob=$_GET['dob'];
    $phone=$_GET['phone'];
    $address=$_GET['address'];
    $gender=$_GET['gender'];
    
    // creating connection

    $conection = mysqli_connect('localhost','root','','php_training') or die();
    $query = "INSERT INTO registrationch03 VALUES(0,'$fname','$lname','$email','$dob','$phone','$address','$gender')";
    $data=  mysqli_query($conection,$query);
    
    echo 'registration successfull.';
  
    mysqli_close($conection);
      
?>