阅读背景:

在PHP中使用多个表单时,不会将插入值输入到数据库中

来源:互联网 

signup.php

signup.php

   <?php
  if (isset($_POST['signup'])) {
    $con = mysqli_connect("localhost", "root", "");
    mysqli_query($con, "CREATE DATABASE dream");
    mysqli_select_db($con, "dream");
    $counter = 1;
    $uname = $_POST['uname'];
    $uemail = $_POST['uemail'];
    $upass = $_POST['upass'];
    $gender = $_POST['gender'];
    $uage = $_POST['uage'];
    $ucourse = $_POST['ucourse'];
    $uclass = $_POST['uclass'];
    $ucontact = $_POST['ucontact'];
    $uaddress = $_POST['uaddress'];

    $ct = "CREATE TABLE student(sno INTEGER(3) NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(20), email VARCHAR(30), password VARCHAR(30), gender VARCHAR(30), age INTEGER(3), course VARCHAR(30), class VARCHAR(30), contact INTEGER(3), 
        address VARCHAR(100) )";
    mysqli_query($con, $ct);
    mysqli_query($con, "INSERT INTO student VALUES('$counter', '$uname','$uemail','$upass','$gender',
        '$uage','$ucourse','$uclass','$ucontact','$uaddress')");
    }

    ?>

<html>
<head></head>
<body>
    <form method = "post" action = "signup2.php"> 
    <div class = "container">

        <h2>Sign Up for Dream Media</h2>
        <table width = "550"  bordercolor = "#ffcc99" align = "center" bgcolor = "#cce5ff" cellpadding="12" border-radius = "5">
            <tr>
                <th>Name</th>
                <td><input type = "text" placeholder = "Enter your name" name = "uname" size = "30"></td>
            </tr>
            <tr>
                <th>Email</th>
                <td><input type = "email" placeholder = "Enter your email" name = "uemail"  size = "30"></td>
            </tr>
            <tr>
                <th>Password</th>
                <td><input type = "password" placeholder = "Enter your password" name = "upass"  size = "30"></td>
            </tr>
            <tr>
                <th>Gender</th>
                <td><input type = "radio"  name = "gender" value = "male">Male
                    <input type = "radio"  name = "gender" value = "female">Female</td>
            </tr>
            <tr>
                <th>Age</th>
                <td><input type = "text" placeholder = "Enter your Age" name = "uage"  size = "30"></td>
            </tr>
            <tr>
                <td colspan = "2" class="right"><input type = "submit" Value = "Next"></td>
            </tr>
        </table>
    </div>
    </form>
    <footer>

  <p>Contact information: <a href="/go.html?url=mailto:[email protected]">[email protected]</a>.</p>
</footer>

</body>
</html>
   <?php
  if (isset



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: