Use ajax in PHP to log on to the page, verify whether the user name is available, and dynamically call the database.
1. Basic ajax knowledge
Ajax is a comprehensive application technology integrated with jquery, php, and other technologies, not new content. Ajax is also written in the <script> label.
If ajax is used, there must be one processing page. The processing page only operates the database and returns the value. The pages are all processed by ajax.
2. Use ajax as the login page denglu. php
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Login processing page dengluchuli. php
<?php$uid = $_POST["u"];$pwd = $_POST["p"];include("./DBDA.class.php");$db = new DBDA();$sql = "select password from login where username='{$uid}'";$mm = $db->StrQuery($sql,0);if($mm == $pwd && $pwd!=""){ echo "OK";}else{ echo "NO";}
3. Use ajax to verify whether the user name is available in testuid. php
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Processing page uidchuli. php
<?php$uid = $_POST["u"];include("./DBDA.class.php");$db = new DBDA();$sql = "select count(*) from login where username='{$uid}'";echo $db->StrQuery($sql,0);
Effect
4. dynamically call the database. Enter keywords in the search box. keywords in the content are automatically displayed in the input box.
List. php
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Processing page listchuli. php
<?php$name = $_POST["n"];include("./DBDA.class.php");$db = new DBDA();$sql = "select areaname from chinastates where areaname like'%{$name}%'";echo $db->StrQuery($sql,0);
Effect