Two ways to connect MySQL via PHP (2)

Source: Internet
Author: User
Tags connect mysql query
The MySQL example shows my article in "Program and Code" in this website and the following routines:

Foreground HTML

< form enctype= "Multipart/form-data" action= "hb_ggzd.php" method= "POST" >
< tr >
< TD width= "251" >< small > You can take some time to fill in the form, or you can use electricity
Sub-mail contact,< a href= "mailto:likai333@21cn.com" >likai333@21cn.com</a >. </small ></td >
</tr >
< tr >
< TD valign= "top" width= "251" height= "to" >< small > Your name:</small ></td >
< TD width= "462" height= ">< small >< input name=" name "size=" "> </small ></td >
</tr >
< tr >
< TD valign= "top" width= "251" height= ">< small > your email:</small ></td >
< TD width= "462" height= ">< small >< input name=" Usermail "size=" Notoginseng "></small ></td >
</tr >
< tr >
< TD valign= "top" width= "251" height= ">< small > you want to advertise Web address:</small ></td >
< TD width= "462" height= "a" >< small >< small >< input name= "Userurl" size= "Notoginseng" value= "http://" > </small ></small ></td >
</tr >
< tr >
< TD valign= "top" width= "251" height= ">< small > you want to advertise website name:</small ></td >
< TD width= "462" height= ">< small >< input name=" sitename "size=" "></small ></td >
</tr >
< tr >
< TD valign= "top" width= "251" height= ">< small > Your company name:</small ></td >
< TD width= "462" height= ">< small >< input name=" Company "size=" Notoginseng "></small ></td >
</tr >
< tr >
< TD valign= "top" width= "251" height= ">< Small > Your tel:</small ></td >
< TD width= "462" height= ">< small >< input name=" phone "size=" "></small ></td >
</tr >
< tr >
Background php

< PHP
$DBH = mysql_connect (' localhost:3306 ', ' root ', ');
mysql_select_db (' Hbweb ');
$query = "INSERT into usemsg (Name,usermail,userurl,sitename, Company,phone) VALUES (' $name ', ' $usermail ', ' $userurl ', ' $ SiteName ', ' $company ', ' $phone ', ' $C 1 ', ' $C 2 ', ' $C 3 ', ' $C 4 ', ' $C 5 ');
$res = mysql_query ($query, $DBH);
$err = Mysql_error ();
if ($err) {
echo "Error occurred, please notify < a href=mailto:likai333@21cn.com > I </a >";
echo "$err";
}
Else
{echo "successfully warehousing";}

? >

Table structure:

CREATE TABLE usemsg (
Name varchar (255) NOT NULL default "Notname",
Usermail varchar (255) NOT NULL default "Notusermail",
Userurl varchar (255) NOT NULL default "Notuserurl",
SiteName varchar (255) NOT NULL default "Notsitename",
Company varchar (255) is not null default "Notcompany",
Phone varchar (255) NOT NULL default "Notphone",
);



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.