php mysql basic step by step tutorial – part 9: In order to make this input data is ‘user friendly’, you can make a HTML form for input data.example:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Form Input Data</title> </head> <body> <table border="1"> <tr> <td align="center">Form Input Employees Data</td> </tr> <tr> <td> <table> <form method="post" action="input.php"> <tr> <td>Name</td> <td><input type="text" name="name" size="20"> </td> </tr> <tr> <td>Address</td> <td><input type="text" name="address" size="40"> </td> </tr> <tr> <td></td> <td align="right"><input type="submit" name="submit" value="Sent"></td> </tr> </table> </td> </tr> </table> </body> </html>The result:This HTML form will send two variable, $name and $address variable, into input.php file as describe in the ACTION parameter of FORM HTML<?php //the example of inserting data with variable from HTML form //input.php mysql_connect("localhost","root","admin");//database connection mysql_select_db("employees"); //inserting data order $order = "INSERT INTO data_employees (name, address) VALUES ('$name', '$address')"; //declare in the order variable $result = mysql_query($order); //order executes if($result){ echo("<br>Input data is succeed"); } else{ echo("<br>Input data is fail"); } ?>After you have already made input.php, fill the input data and then click the sent button such as:For the result:
As for the exercises, put some of data’s into employees database.
Related Posts
Get the client IP address using PHP
The simplest way to get the visitor’s/client’s IP address is using the $_SERVER['RE[...]
How to use PHP & Multiple Input Text Field/Textbox
Example 1 php_multiple_textbox1.php <html> <head> <title>ShotDev.Com Tutoria[...]
string to url slug convert in php
Function: <?php function create_slug($string, $ext='.html'){ $replace = '-'; &[...]
php Pagination with mysql
To start with you’ll see that we have our database connection file which we’re including into the[...]
Create Secure Registration Form in PHP/MySQL
By secured we mean that we need to sanitize the data that is passed to our script in order to [...]
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.