Require instructions to fill in the same fields into multiple tables

Source: Internet
Author: User
Fill in records with the same fields in multiple tables for guidance
Why is this wrong?

$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 ';

?>
------Solution--------------------
Oh, I just noticed you.
$sql. = ' INSERT into Module1 (username) VALUES (' $username '); '
$sql. = ' INSERT into Module2 (username) VALUES (' $username '); '
$sql. = ' INSERT into Module3 (username) VALUES (' $username '); '
$sql. = ' INSERT into module4 (username) VALUES (' $username '); '
$sql. = ' INSERT into module5 (username) VALUES (' $username '); '
Then use Mysqli::multi_query () to support multi-statement execution MySQL can only be a single statement execution, so you plug 5 times to perform 5 times mysql_query
  • 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.