PHP Multi-table Write, update request guidance

Source: Internet
Author: User
How do you write data in PHP with the same fields in multiple MySQL tables?


Reply to discussion (solution)

The same fields in multiple tables are written at the same time
It's obviously not a reasonable design.
Although the relational database will have some redundancy, it's not like you

can execute multiple SQL


$username = $_post[' username ');
$password = $_post[' psd '];
$sex = $_post[' sex '];
$grade = $_post[' grade ');
$age = $_post[' age '];
$height =$_post[' height '];
$weight =$_post[' weight '];

Check form data
if (!preg_match ('/^[\w\x80-\xff]{3,15}$/', $username)) {
Exit (' ERROR: User name does not meet requirements!back ');
}
if (strlen ($password) < 6) {
Exit (' ERROR: Password length does not meet requirements!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 (' Register successfully! Click here to log in ');
Else
Echo ' Sorry, registration Error!: ', mysql_error (), '
';
Echo ' Click here to return to retry ';

?>

How does this change?

Your knot rate is too low.

What is the same and what is the concept can you say more details?

I have succeeded, thank you guys, PS I am not a low knot rate, but in a period of time to write too many new posts, weighted average after .... You see the scene, so I think in fact, the forum of the knot paste method and algorithm needs 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.