Php multi-table writing, update Guide-php Tutorial

Source: Internet
Author: User
Php writes data to multiple tables. how can I use php to write data simultaneously under the same field in multiple mysql tables?


Reply to discussion (solution)

Write the same fields in multiple tables at the same time
Obviously, this design is unreasonable.
Although relational databases have some redundancy, they are not like you.

Multiple SQL statements can be executed.


$ Username = $ _ POST ['username'];
$ Password = $ _ POST ['psd '];
$ Sex = $ _ POST ['Sex '];
$ Grade = $ _ POST ['Grad'];
$ Age = $ _ POST ['age'];
$ Height = $ _ POST ['height'];
$ Weight = $ _ POST ['weight'];

// Check form data
If (! Preg_match ('/^ [\ w \ x80-\ xff] {3, 15} $/', $ username )){
Exit ('error: the user name does not meet the requirements! Back ');
}
If (strlen ($ password) <6 ){
Exit ('error: Invalid password length! Back ');
}


Include ('Conn. php ');


$ SQL = "INSERT INTO user (username, password, sex, grade, age, height, weight) VALUES ('$ username',' $ password', '$ sex ', '$ grade', '$ age',' $ height', '$ weight ')";
Insert into module1 (username) VALUES ('$ username ');
Insert into module2 (username) VALUES ('$ username ');
Insert into module3 (username) VALUES ('$ username ');
Insert into module4 (username) VALUES ('$ username ');
Insert into module5 (username) VALUES ('$ username ');
If (mysql_query ($ SQL, $ conn ))
Exit ('registration successful! Click here to log on ');
Else
Echo 'Sorry, registration error! : ', Mysql_error (),'
';
Echo 'click here to return retry ';

?>

How can this be changed?

Your posting rate is too low

What is the same concept and the same concept at the same time?

I have already succeeded. thank you. I wrote too many new posts within a period of time, after weighted average .... This is what you see, so I think the posting methods and algorithms of the forum need to be improved.

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.