PHP form question script functionformone () {varnamejQuery (# name ). val (); varurljQuery (# url ). val (); varteljQuery (# tel ). val (); vartelreg ^ (d {11}) | ^ (d {7, 8}) | (d {4} | d {3 }) -(d {7, 8}) | (d {4} | d {3})-(d {7, 8 }) -(d {4} | d {3} | d {2} | d {1}) | (d
PHP form question script functionformone () {varname = jQuery ("# name "). val (); varurl = jQuery ("# url "). val (); vartel = jQuery ("# tel "). val (); vartelreg =/^ (\ d {11}) | ^ (\ d {7, 8}) | (\ d {4} | \ d {3 }) -(\ d {7, 8}) | (\ d {4} | \ d {3})-(\ d {7, 8 }) -(\ d {4} | \ d {3} | \ d {2} | \ d {1}) | (\ d
PHP form Problems
Script
Function formone (){
Var name = jQuery ("# name"). val ();
Var url = jQuery ("# url"). val ();
Var tel = jQuery ("# tel"). val ();
Var telreg =/^ (\ d {11}) | ^ (\ d {7, 8}) | (\ d {4} | \ d {3 }) -(\ d {7, 8}) | (\ d {4} | \ d {3})-(\ d {7, 8 }) -(\ d {4} | \ d {3} | \ d {2} | \ d {1}) | (\ d {7, 8 }) -(\ d {4} | \ d {3} | \ d {2} | \ d {1}) $ /;
Var zw =/^ [\ u4e00-\ u9fa5]/;
Var ask = jQuery ("# ask"). val ();
Var des = jQuery ("# des"). val ();
If (name = "") {alert ("enter your name! "); JQuery (" # name "). focus (); return false;} else if (! Zw. test (name) {alert ("enter the correct name! "); JQuery (" # name "). focus (); return false ;}
Else if (tel = "") {alert ("Enter your contact number! "); JQuery (" # tel "). focus (); return false;} else if (! Telreg. test (tel) {alert ("enter the correct contact number! "); JQuery (" # tel "). focus (); return false ;}
Else if (ask = "") {alert ("Please input your question! "); JQuery (" # ask "). focus (); return false;} else if (! Zw. test (ask) {alert ("enter the correct question! "); JQuery (" # ask "). focus (); return false ;}
Else if (des = "") {alert ("Please enter your problem description! "); JQuery (" # des "). focus (); return false;} else if (! Zw. test (des) {alert ("enter the correct Problem description! "); JQuery (" # des "). focus (); return false ;}
Else {
JQuery. ajax ({
Url: 'submit. php ',
Data: {name: jQuery ("# name "). val (), tel: jQuery ("# tel "). val (), ask: jQuery ("# ask "). val (), des: jQuery ("# des "). val (), url: jQuery ("# url "). val ()},
Type: 'post ',
DataType: 'text ',
Success: function (msg ){
If (parseInt (msg )! = 0 ){
Alert ("Your problem is submitted successfully and is under review ...");
JQuery ("# name"). val ("");
JQuery ("# tel"). val ("");
JQuery ("# ask"). val ("");
JQuery ("# des"). val ("");
} Else {
Alert ("your problem failed to be submitted. Please contact us online or call the official phone number 400-600-4936! ");
}
}
})
}
}
PHP code
/**
* @ Process form submission data
*/
Define ('include _ check', 1 );
Require_once ('connect. php ');
$ Name = stripslashes ($ _ POST ['name']);
$ Tel = stripslashes ($ _ POST ['tel']);
$ Ask = stripslashes ($ _ POST ['Ask ']);
$ Des = stripslashes ($ _ POST ['des ']);
$ Time = date ('y, m, D, H, I minute, s second ', time ());
$ Url = stripslashes ($ _ POST ['url']);
If (isset ($ _ POST ['name']) &! Empty ($ _ POST ['name']) {
$ Query = mysql_query ("insert into say (name, tel, ask, des, time, url) values ('$ name',' $ tel ',' $ ask ', '$ de',' $ time', '$ url ')");
}
?>
How can I write script verification into PHP to verify fields?
------ Solution ----------------------
$ Name = stripslashes ($ _ POST [this article comes from the Internet (http://www.68idc.cn)] ['name']);
$ Tel = stripslashes ($ _ POST ['tel']);
$ Ask = stripslashes ($ _ POST ['Ask ']);
$ Des = stripslashes ($ _ POST ['des ']);
$ Time = date ('y, m, D, H, I minute, s second ', time ());
$ Url = stripslashes ($ _ POST ['url']);
$ Telreg = '/^ (\ d {11 })
------ Solution ----------------------
^ (\ D {7, 8 })
------ Solution ----------------------
(\ D {4}
------ Solution ----------------------
\ D {3})-(\ d {7, 8 })
------ Solution ----------------------
(\ D {4}
------ Solution ----------------------
\ D {3})-(\ d {7, 8})-(\ d {4}
------ Solution ----------------------
\ D {3}
------ Solution ----------------------
\ D {2}
------ Solution ----------------------
\ D {1 })
------ Solution ----------------------
(\ D {7, 8})-(\ d {4}
------ Solution ----------------------
\ D {3}
------ Solution ----------------------
\ D {2}
------ Solution ----------------------
\ D {1}) $ /';
$ Zw = '/^ [\ u4e00-\ u9fa5]/';
If ($ _ POST ){
If (empty ($ name )){
Echo 1;
} Elseif (! Preg_match ($ zw, $ name )){
Echo 2;
} Elseif (empty ($ tel )){
Echo 3;
} Elseif (! Preg_match ($ telreg, $ tel )){
Echo 4;
} Elseif (empty ($ ask )){
Echo 5;
} Elseif (! Preg_match ($ zw, $ ask )){
Echo 6;
} Elseif (empty ($ des )){
Echo 7;
} Elseif (! Preg_match ($ zw, $ des )){
Echo 8;
} Else {
Echo 9;
}
} Else {
Echo 0;
}
Success: function (msg ){
Switch (msg ){
Case 1:
Alert ('enter your name! '); Break;
Case 2:
Alert ('Enter the correct name! '); Break;
Case 3:
Alert ('enter your phone number'); break;
Case 4:
Alert ('Enter the correct contact number! '); Break;
Case 5:
Alert ('enter your question! '); Break;
Case 6:
Alert ('Enter the correct question! '); Break;
Case 7:
Alert ('enter your problem description'); break;
Case 8:
Alert ('Enter the correct Problem description! '); Break;
Case 9:
Alert ('your problem has been submitted successfully and is under review... '); break;
Case 0:
Alert ('Your question submission failed. Please contact us online or call the official phone number 400-600-4936! ');
}
}