Source: Aesop
Desktop Center (2) database writing
Author: elong
1. The following is the html program written into the database. You can add the password function. Make the password into a variable and send it to the written php program below. In this way, password protection is implemented:
<Html>
<Head>
<Title> database </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Style type = "text/css">
<! --
. P9 {font-size: 9pt}
-->
</Style>
</Head>
<Body bgcolor = "# FFFFFF">
<Div align = "center">
<P class = "p9"> Database Management Program
<A href = "mysql. php"> View database information </a> </p>
<P class = "p9"> <a href = "ww. php"> modify data </a>
</P>
<Form method = "post" action = "wsql. php">
<P align = "left"> <span class = "p9"> image url
<Input type = "text" name = "url" size = "100">
Image thumbnail
<Input type = "text" name = "mess" size = "100">
Description
<Input type = "text" name = "fromx" size = "100">
</Span> </p>
<P align = "left"> <span class = "p9"> image url 1
<Input type = "text" name = "url1" size = "100">
Image thumbnail 1
<Input type = "text" name = "mess1" size = "100">
Description 1
<Input type = "text" name = "fromx1" size = "100">
</Span> </p>
<P align = "left"> <span class = "p9"> image url 2
<Input type = "text" name = "url2" size = "100">
Image thumbnail 2
<Input type = "text" name = "mess2" size = "100">
Description 2
<Input type = "text" name = "fromx2" size = "100">
</Span> </p>
<P align = "left" class = "p9"> <span class = "p9"> image url 3
<Input type = "text" name = "url3" size = "100">
Image thumbnail 3
<Input type = "text" name = "mess3" size = "100">
Description 3
<Input type = "text" name = "fromx3" size = "100">
</Span>
Landscape color watercolor
<Input type = "radio" name = "jpg" value = "jpg" checked>
Star photo
<Input type = "radio" name = "jpg" value = "jpg1">
Anime tablecloth
<Input type = "radio" name = "jpg" value = "jpg2">
Ad Creativity
<Input type = "radio" name = "jpg" value = "jpg3">
Other classes
<Input type = "radio" name = "jpg" value = "jpg4">
<Input type = "submit" name = "Submit" value = "submit">
</P>
</Form>
</Div>
</Body>
</Html>
2. the php program that handles the submission is as follows:
<Html>
<Head> <title> Search </title>
</Head>
<Body>
<H1> database data <?
Mysql_connect ("localhost", "username", "password") or die ("unable to connect to the database! ");
$ Query = "insert into $ jpg values ('$ id',' $ url', '$ mess', '$ fromx', '$ url1',' $ mess1 ', '$ fromx1', '$ url2', '$ mess2', '$ fromx2', '$ url3', '$ mess3',' $ fromx3 ')";
$ Result = mysql_db_query ("elong", $ query); // execute write
If (mysql_affected_rows () = 1)
{
Echo "the data has been added to the database $ jpg
";
Echo "<table> n
<Tr> n
<Td> ID <td> $ id </tr> n
<Tr> n
<Td> url <td> $ url </tr> n
<Tr> n
<Td> thumbnail <td> $ mess </tr> n
<Tr> n
<Td> description <td> $ fromx </tr> n
<Tr> n
<Td> url 1 <td> $ url1 </tr> n
<Tr> n
<Td> Fig 1 <td> $ mess1 </tr> n
<Tr> n
<Td> description 1 <td> $ fromx1 </tr> n
<Tr> n
<Td> url address 2 <td> $ url2 </tr> n
<Tr> n
<Td> Fig 2 <td> $ mess2 </tr> n
<Tr> n
<Td> Note 2 <td> $ fromx2 </tr> n
<Tr> n
<Td> url 3 <td> $ url3 </tr> n
<Tr> n
<Td> Fig 3 <td> $ mess3 </tr> n
<Tr> n
<Td> Note 3 <td> $ fromx3 </tr> n
</Table> n ";
}
Else echo "An error occurred. Please try again! :(";
Mysql_close ();
?>
<A href='set.htm '> return to the home page </a>
</Body>
</Html>