PHP connects to access and inserts data into an Access database

Source: Internet
Author: User
Keywords Web Programming PHP Tutorials
Tags access connections content data email example microsoft name

One of the simplest PHP connections to an Access database and an example of inserting data into a database

<?php
$connstr = "Driver=microsoft Access DRIVER (*.mdb);D bq=". Realpath ("Db1.mdb");
$connid =odbc_connect ($connstr, "", "", SQL_CUR_USE_ODBC);
$ct 01=$_post[ct01];
$ct 02=$_post[ct02];
$ct 03=$_post[ct03];
$ct 04=$_post[ct04];
$ct 05=$_post[ct05];
$ct 06=$_post[ct06];

$name =$_post[name];
$danwei =$_post[danwei];
$email =$_post[email];
$tele =$_post[tele];
$QQ =$_POST[QQ];
$yb =$_post[yb];
$content =$_post[content];
$sql = "INSERT into TB_TJ (ct01,ct02,ct03,ct04,ct05,ct06,name,danwei,email,qq,yb,content)
VALUES (' $ct ', ' $ct ', ' $ct ', ' $ct ', ' $ct ', ' $ct ', ' $name ', ' $danwei ', ' $email ', ' $qq ', ' $yb ', ' $content ');
if (Odbc_do ($connid, $sql))
{
echo "<script>alert" Congratulations! Submit successfully! '); location= ' index.php ';</script> ';
}
Else
{
echo "<script>alert" (' Sorry! Commit failed! '); location= ' index.php ';</script> ';
}


?>

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.