Two methods for connecting to MYSQL through PHP (2)

Source: Internet
Author: User
Two methods for connecting to MYSQL through PHP (2) examples show my articles in the & quot; program and code & quot; on this website and the following routines: <br/> front-end HTML <br/> <br examples show my articles in "programs and code" on 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 enter a table in the interval or use the power
Sub-Mail, <a href = "mailto: likai333@21cn.com"> likai333@21cn.com </a>. </Small> </td>
</Tr>
<Tr>
<Td vAlign = "top" width = "251" height = "31"> <small> Your name: </small> </td>
<Td width = "462" height = "31"> <small> <input name = "name" size = "20"> </small> </td>
</Tr>
<Tr>
<Td vAlign = "top" width = "251" height = "30"> <small> Your Email: </small> </td>
<Td width = "462" height = "30"> <small> <input name = "usermail" size = "37"> </small> </td>
</Tr>
<Tr>
<Td vAlign = "top" width = "251" height = "25"> <small> the website address you want to advertise: </small> </td>
<Td width = "462" height = "25"> <small> <input name = "userurl" size = "37" value = "http: // "> </small> </td>
</Tr>
<Tr>
<Td vAlign = "top" width = "251" height = "25"> <small> website name to be advertised: </small> </td>
<Td width = "462" height = "25"> <small> <input name = "sitename" size = "20"> </small> </td>
</Tr>
<Tr>
<Td vAlign = "top" width = "251" height = "30"> <small> Your Company name: </small> </td>
<Td width = "462" height = "30"> <small> <input name = "company" size = "37"> </small> </td>
</Tr>
<Tr>
<Td vAlign = "top" width = "251" height = "25"> <small> Contact number: </small> </td>
<Td width = "462" height = "25"> <small> <input name = "phone" size = "20"> </small> </td>
</Tr>
<Tr>
Backend PHP

<? Php
$ Dbh = mysql_connect ('localhost: 100', 'root ','');
Mysql_select_db ('hbweb ');
$ Query = "insert into usemsg (name, usermail, userurl, sitename, company, phone) values ('$ name',' $ usermail', '$ userurl ', '$ sitename', '$ company', '$ phone', '$ C1', '$ C2', '$ C3',' $ c1', '$ C1 ') ";
$ Res = mysql_query ($ query, $ dbh );
$ Err = mysql_error ();
If ($ err ){
Echo "an error occurred, please notify <a href = mailto: likai333@21cn.com> me </a> ";
Echo "$ err ";
}
Else
{Echo "successful warehouse receiving ";}

? >

Table structure:

Create table usemsg (
Name varchar (255) not null default "notname ",
Usermail varchar (255) not null default "notusermail ",
User URL varchar (255) not null default "notuserurl ",
Sitename varchar (255) not null default "notsitename ",
Company varchar (255) 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.