未定义的变量行我PHP

时间:2019-01-22 05:06:28

标签: php mysql

我是PHP新手。我的代码在$useruid=$row['id']行显示错误的未定义变量行 我不明白我在哪里做错了

<?php
include 'header.php';
?>
<?php
    $db = mysqli_connect("localhost", "root", "", "discount");
    $msg = "";

    if (isset($_POST['register'])) {


        $mname = $_POST['mname'];

      $password = $_POST['password'];
            $sql= "INSERT INTO merchantl (mname, password) VALUES ('$mname', '$password')";
            mysqli_query($db,$sql);
  $insert="SELECT * FROM merchantl where mname='$mname'";
    $result=mysqli_query($db,$insert);
    if(mysqli_num_rows($result)>0){
        while($row=mysqli_fetch_assoc($result)){
            $useruid=$row['id'];
            $usern=$row['mname'];
            $sql="INSERT INTO shop (userid,promo) VALUES('$useruid','click here to avail offer')";
            if (mysqli_query($db, $sql)) {
      header('location:merchantlogin.php?registration=success');
    } else {
        echo "error";
    }
        }
    }
        }
?>

0 个答案:

没有答案