how to create link to dropdowns and check box
PHP,
5.00 (1 votes)

i have done a program

my need is to

In a login page User name , password , gender , terms and condition to be fixed and to stored in data base

where gender will be in a sort of drop down

and age will be as a radio button

i have created table and login page ,

But dont know how to give link to buttons , and how to make stored all values in database

 

Ex : login : Ram

Password: yyydyy

Age : In drop box

Gender: In radio button format

Terms and condition  in check box

 

where all fields should be filled and that should be stored in database

it is my question



08-02-2017 18:08:37
 Attachment(s)
11_1_loginss


Answers

Solution #1

0.00 (0 votes)

Try out this example by putting this code into yourform.php, this will take input using HTML Form and then it will create records into database.

<html>
   
   <head>
      <title>Insert New Record in MySQL Database</title>
   </head>
   
   <body>
      <?php
         if(isset($_POST['add'])) {
            $dbhost = 'localhost:3006';
            $dbuser = 'root';
            $dbpass = 'password';
            $conn = mysql_connect($dbhost, $dbuser, $dbpass);
            
            if(! $conn ) {
               die('Could not connect: ' . mysql_error());
            }
            

            $emp_name = $_POST['emp_name'];
            $emp_address = $_POST['emp_address'];
            $emp_salary = $_POST['emp_salary'];
            
            $sql = "INSERT INTO employee ". "(emp_name,emp_address, emp_salary, 
               join_date) ". "VALUES('$emp_name','$emp_address',$emp_salary, NOW())";
               
            mysql_select_db('test_db');
            $retval = mysql_query( $sql, $conn );
            
            if(! $retval ) {
               die('Could not enter data: ' . mysql_error());
            }
            
            echo "Entered data successfully\n";
            
            mysql_close($conn);
         }else {
            ?>
            
               <form method = "post" action = "<?php $_PHP_SELF ?>">
                  <table width = "400" border = "0" cellspacing = "1" 
                     cellpadding = "2">
                  
                     <tr>
                        <td width = "100">Employee Name</td>
                        <td><input name = "emp_name" type = "text" 
                           id = "emp_name"></td>
                     </tr>
                  
                     <tr>
                        <td width = "100">Employee Address</td>
                        <td><input name = "emp_address" type = "text" 
                           id = "emp_address"></td>
                     </tr>
                  
                     <tr>
                        <td width = "100">Employee Salary</td>
                        <td><input name = "emp_salary" type = "text" 
                           id = "emp_salary"></td>
                     </tr>
                  
                     <tr>
                        <td width = "100"> </td>
                        <td> </td>
                     </tr>
                  
                     <tr>
                        <td width = "100"> </td>
                        <td>
                           <input name = "add" type = "submit" id = "add" 
                              value = "Add Employee">
                        </td>
                     </tr>
                  
                  </table>
               </form>
            
            <?php
         }
      ?>
   
   </body>
</html>

Hope this helps.



Pallav Kumar
09-02-2017 09:48:11


Search