PHP is used to compile examples of newly registered login programs on the school website. php instance _ PHP Tutorial

Source: Internet
Author: User
Tags function examples
PHP is used to compile examples of newly registered login programs on the school website, such as php instances. PHP compiles examples of new student registration and login programs on the school website. The php instance has three pages: (1) register new student information module (register. php ):! DOCTYPEHTMLPUBLIC-W3 PHP programming school website on the newly registered login program examples, php instances

Three pages are created:

(1) register the new information module (register. php ):

    
   Class Registry        
     
  
   Henan University of Technology sincerely welcomes 2012 new students to study
      
     

New student registration system


(2) Information Query logon module (mysql_stu.php ):

 New login system <? Php // connect to the database; $ link = mysql_connect ('localhost', 'root', 'dongsheng'); if (! $ Link) {echo "failed to connect to the database! "; Die ('could not connect :'. mysql_error ();} $ createdb = "create database if not exists mis_stu"; $ result = mysql_query ($ createdb) or die ("
Database creation failed :". mysql_error (); $ result = mysql_select_db (mis_stu) or die ('failed to select mis_stu database :'. mysql_error (); $ createtable = "create table if not exists stu_reg (stu_name varchar (30) not null, stu_sex char (2), stu_age int, stu_class varchar (30 ), stu_id varchar (18), stu_tele varchar (20), stu_email varchar (30) "; $ result = mysql_query ($ createtable) or die ('
Failed to create data table: '. mysql_error (); // select database mysql_select_db (mis_stu); if (! Empty ($ _ POST ['Reg _ name']) {$ name = $ _ POST ['Reg _ name']; $ sex = $ _ POST ['Reg _ sex ']; $ age = $ _ POST ['Reg _ age']; $ class = $ _ POST ['Reg _ class']; $ id = $ _ POST ['Reg _ id']; $ tele = $ _ POST ['Reg _ tele ']; $ email = $ _ POST ['Reg _ email']; // define the SQL string mysql_query ("set names gb2312") inserted into the stu_reg table; $ SQL = "insert into stu_reg (stu_name, stu_sex, stu_age, stu_class, stu_id, stu_tele, stu_email) values ('$ name',' $ sex ',' $ age', '$ class',' $ ID', '$ tele',' $ email ') "; mysql_query ($ SQL); mysql_query (" COMMIT "); echo" Congratulations! registration successful!
Enter the following content to log on to the system to query registration information.
";}Mysql_close ($ link) ;?> Register before logon

Information Query logon

>

Requirements for new students:

Please complete the registration information at each school first,
Register reports,
At the same time, the electronic file information should be improved as required.

Hope that the majority of students can adapt to the new environment as soon as possible,
Meet new friends and get involved in learning as soon as possible!

Academic Affairs Office Tel: 12345678
Wei Ke Tel: 87654321

(3) query information display module (stu_info.php)

 Basic information <? Php if ($ _ POST ['log _ name'] = '') {echo"
 
  Name cannot be blank! Enter again!
"; Echo" Log on again ";} Else {$ link = mysql_connect ('localhost', 'root', 'dongsheng '); if (! $ Link) {echo "failed to connect to the database! "; Die ('could not connect :'. mysql_error ();} $ result = mysql_select_db (mis_stu) or die ('failed to select mis_stu database :'. mysql_error (); mysql_query ("set names gb2312"); $ slt = mysql_query ("select * from stu_reg"); $ arr = mysql_fetch_assoc ($ slt ); $ flag = 0; while ($ arr) {if ($ _ POST ['log _ name'] = $ arr ['Stu _ name']) {$ flag = 1; if ($ _ POST ['log _ id'] = $ arr ['Stu _ id']) {echo"Login successful. your basic information is:

"; Echo" name: ". $ arr ['Stu _ name']."
"; Echo" gender: ". $ arr ['Stu _ sex']."
"; Echo" age: ". $ arr ['Stu _ age']."
"; Echo" class: ". $ arr ['Stu _ class']."
"; Echo" id card number: ". $ arr ['Stu _ id']."
"; Echo" Contact number: ". $ arr ['Stu _ tele']."
"; Echo" email: ". $ arr ['Stu _ email ']."
"; Break;} else {echo" Incorrect password! Enter again.
"; Break ;}$ arr = mysql_fetch_assoc ($ slt);} if ($ flag = 0) echo" Sorry! The user you queried does not exist. please return to registration first
"; Mysql_close ($ link); echo" Switch User
";}?>

Articles you may be interested in:
  • Php registration and logon system simplified version
  • Complete information on the php user registration page (with source code)
  • Php user registration information validation regular expression
  • PHP user registration system
  • Summary of function examples frequently used for php user registration
  • PHP + jQuery registration module development details
  • PHP + Ajax check whether an instance exists at user name or email registration
  • A complete example of ThinkPHP user registration logon message
  • Verify the php code of the user name before registering the page
  • PHP + AJAX for refreshing registration (real-time detection with user names)

Ghost has three pages: (1), new student information registration module (register. php ):! Doctype html public "-// W3...

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.