PHP Code _php Tutorial for adding records to a database

Source: Internet
Author: User
Tags mysql tutorial php mysql php mysql tutorial
Database add a record of PHP code this is a simple use of PHP MySQL to save the user submitted information to the database instance Oh, copy the file below to your DW can be used OH.

Database tutorial Add a documented PHP tutorial code
This is a simple use of PHP MySQL tutorial to save the user submitted information to the database instance Oh, copy the file below to your DW can be used OH.
*/

if ($_post)
{
$host = ' localhost ';
$user _name = ' root ';
$password = ' admin ';

$name = $_post[' user_name ');
$city = $_post[' city ');

if (Empty ($name) | | trim ($name) = = ")
{
Echo ' Please fill in the user name! Return ';
Exit
}

$conn = mysql_connect ($host, $user _name, $password);
if (! $conn)
{
Die (' Database connection failed: '. mysql_error ());
}
mysql_select_db (' Test ');

$sql = "INSERT into users set Id=7,name= '". $name. "', city= '". $city. "', Created_time=now ()";
mysql_query ($sql) or Die ("
Error: ". Mysql_error ()."
sql: ". $sql);
Mysql_close ($conn);

Echo ' data inserted successfully, open view data ';
}

?>
Submit User Information

http://www.bkjia.com/PHPjc/630824.html www.bkjia.com true http://www.bkjia.com/PHPjc/630824.html techarticle database Add a record of PHP code this is a simple use of PHP MySQL to save the user submitted information to the database instance Oh, copy the file below to your DW can be used OH. The database teaches ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.