It originated from sorting out the address book. I used file surveys. now I have learned php and I will try it myself. The program is short and concise and suitable for learning. There are two files. bj.html is used to display and collect form information. bj. php is used to process data and feedback results. The highlight is that you can upload and view your avatar. In fact, there is another test. php for debugging and intermediate processing. let's take a look at it from here. The comment is very detailed. if the tag or function does not, right-click to search. Because there are many web directories, put them in the./1/folder, and set a bookmark on Firefox for easy access Change bj.html to index. php during deployment.
I used to build an ipv6 free Internet application platform (now I know it is the oauth open platform), and I started to learn php, which is the simplest, you can also learn the first program in a year, so be careful!
-
-
- 2014 address book
Name
Nickname
Gender
Birthday
Phone Number
Qq
Email
Home
Schools
Grade
Professional
Company
Title
Address
Weibo homepage
Renren homepage
QQ space Homepage
Avatar
Introduction
-
// Save the image file
@ Header ('content-type: text/html; charset = UTF-8 ');
// Upload an image
$ Filepath = $ _ FILES ["photo"] ["tmp_name"];
$ Filename = explode ('.', $ _ FILES ['photo'] ['name']);
$ Filename [0] =$ _ POST ['name'];
$ Name = implode ('.', $ filename );
$ Uploaded = "./photos/". $ name;
If (file_exists ($ filepath )){
Move_uploaded_file ($ filepath, $ uploaded );
// Insert the image link to the database for easy clicking and downloading. it is unnecessary to upload the image to the database and decode it,
$ _ POST ['photo'] = "http: // localhost/1/c/photos/". $ name;
Echo" Hello, ". $ _ POST [" name "]."!
"; // Return the success message, which is your profile picture.
}
-
$ Arr1 = "name, nickname, gender, birthday, phone, qq, email, home, college, grade, major, company, position, address, weibolink, renrenlink, qqzonelink, photo, profile ";
// Use pdo_prepare if you have no idea how to prevent SQL injection.
$ Db = new PDO ("mysql: host = localhost; dbname = test", "root", "") or die (print_r ($ db-> errorInfo (), true ));
// Below is the code to be tried. because mysql is garbled, I tried this and eventually it won't work. I had to change mariadb and the whole world would be clean. I can delete it for reference.
Mysqli_query ("set names 'utf8 '");
Mysqli_query ("set character_set_client = utf8 ");
Mysqli_query ("set character_set_results = utf8 ");
// This is the only automatic processing script. it was originally intended to put all the operations here. In fact, this variable is static and can't be put up after local processing, because it is simple and implemented, locally place '? '.'?, You can paste the result of '* 18.
$ S = "? ";
For ($ j = 0; $ j <18; $ j ++ ){
$ S. = ",? ";
}
$ Add = "insert into bj ({$ arr1}) values ({$ s })";
$ Q = $ stmt = $ db-> prepare ($ add );
// This is where the local bar text is processed and then put up. it looks very difficult to input, and there are many errors in the middle,
$ Array = array ($ _ POST ["name"], $ _ POST ["nickname"], $ _ POST ["gender"], $ _ POST ["birthday"], $ _ POST ["phone"], $ _ POST ["qq"], $ _ POST ["email"], $ _ POST ["home"], $ _ POST ["college"], $ _ POST ["grade"], $ _ POST ["major"], $ _ POST ["company"], $ _ POST ["position"], $ _ POST ["address"], $ _ POST ["weibolink"], $ _ POST ["renrenlink"], $ _ POST ["qqzonelink"], $ _ POST ["photo"], $ _ POST ["profile"]);
$ Stmt-> execute ($ array );
?>
-
-
$ Arr1 = "name, nickname, gender, birthday, phone, qq, email, home, college, grade, major, company, position, address, weibolink, renrenlink, qqzonelink, profile ";
$ Arr2 = explode (",", $ arr1 );
Echo" ". '$ Arr2 '." ";
For ($ I = 0; $ I
$ Arr3 [$ I] = '"$ _ POST [\'. $ arr2 [$ I]. '\']" ';
}
Echo" ". '$ Arr3 '." ";
Echo $ arr3;
$ Arr4 = implode (",", $ arr3 );
// '$ _ POST ['name']', '$ _ POST ['nickname']', '$ _ POST ['gender']', '$ _ POST ['birthday']', '$ _ POST ['phone']', '$ _ POST ['QQ']', '$ _ POST ['email'] ',' $ _ POST ['home'] ',...
Echo" ". '$ Arr4 '." ";
Echo $ arr4;
$ Arr5 = "'". $ arr4 ."'";
Echo" ". '$ Arr5 '." ";
Echo $ arr5;
$ Db = new PDO ("mysql: host = localhost; dbname = test", "root ","");
// $ R1 = $ db-> exec ("insert into bj (name, nickname, gender, birthday, phone, qq, email, home, college, grade, major, company, position, address, weibolink, renrenlink, qqzonelink, profile) values ($ arr3 )");
Echo '$ db :';
$ Insert = "insert into bj ({$ arr1}) values ({$ arr4 })";
Echo" ". '$ Insert :'." ";
$ S = "? ";
For ($ j = 0; $ j <18; $ j ++ ){
$ S. = ",? ";
}
$ Add = "insert into bj ({$ arr1}) values ($ s )";
$ Stmt = $ db-> prepare ($ add );
$ Stmt-> execute (array ($ arr4 ));
?>
$ SQL = "insert into 'tbl' values ('". $ _ POST ['name']. "','". $ _ POST ['title']. "')";
$ SQL = "insert into 'tbl' values ('{$ _ POST ['name']}', '{$ _ POST ['title']}')"
'Insert INTO '. $ table.' ('. $ cols.') VALUES ('. $ vals .')');
$ Stmt = $ dbh-> prepare ("SELECT * from registry where name =? ");
If ($ stmt-> execute (array ($ _ GET ['name']) {
While ($ row = $ stmt-> fetch ()){
Print_r ($ row );
}
}
$ Array = ("{$ _ POST ['name']}", "{$ _ POST ['nickname']}", "{$ _ POST ['gender']}", "{$ _ POST ['birthday']}", "{$ _ POST ['phone']}", "{$ _ POST ['QQ']}", "{$ _ POST ['email ']}", "{$ _ POST ['home']}", "{$ _ POST ['mount']}", "{$ _ POST ['Grad']}", "{$ _ POST ['major']}", "{$ _ POST ['Company']}", "{$ _ POST ['position']}", "{$ _ POST ['address']}", "{$ _ POST ['weibolink']}", "{$ _ POST ['renrenlink']}", "{$ _ POST ['qqzonelink ']}", "{$ _ POST ['Profile ']}");
"$ _ POST ['name']", "$ _ POST ['nickname']", "$ _ POST ['gender']", "$ _ POST ['birthday']", "$ _ POST ['phone']", "$ _ POST ['QQ']", "$ _ POST ['email ']", "$ _ POST ['home']", "$ _ POST ['mount']", "$ _ POST ['grade ']", "$ _ POST ['major']", "$ _ POST ['Company']", "$ _ POST ['position']", "$ _ POST ['address']", "$ _ POST ['weibolink']", "$ _ POST ['renrenlink']", "$ _ POST ['qqzonelink ']", "$ _ POST ['Profile']"
$ Arr5
'"$ _ POST ['name']", "$ _ POST ['nickname']", "$ _ POST ['gender']", "$ _ POST ['birthday']", "$ _ POST ['phone']", "$ _ POST ['QQ']", "$ _ POST ['email ']", "$ _ POST ['home']", "$ _ POST ['mount']", "$ _ POST ['grade ']", "$ _ POST ['major']", "$ _ POST ['Company']", "$ _ POST ['position']", "$ _ POST ['address']", "$ _ POST ['weibolink']", "$ _ POST ['renrenlink']", "$ _ POST ['qqzonelink ']", "$ _ POST ['Profile']" '$ db:
$ Insert:
-
|