私は1つのテーブルに2つのフォームを登録して、別のページに含まれる各PHPの1つのモーダルを対象にする必要があります。下の2つを含めてみると、clientsignupはsurveyesignupの挿入コードと重複しますが、1つだけ含めると完全に機能します。私はすでに1つのフォルダからそれらを分離しようとしました。2つのphpファイルを1つのファイルに入れておきます。
<body id="page-top">
<nav id="mainNav" class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span> Menu <i class="fa fa-bars"></i>
</button>
<a class="navbar-brand page-scroll" href="#page-top">Home</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
<div class="dropdown">
<a href="#" class="btn btn-simple dropdown-toggle" data-toggle="dropdown" style="line-height:2.828571;"><font color="#d3d3d3">Sign Up</font><b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#surveyeesignup" data-target="#surveyeesignup" data-toggle="modal">As User</a></li>
<li><a href="#clientsignup" data-target="#clientsignup" data-toggle="modal">As Client</a></li>
</ul>
</div>
</li>
<li>
<a href="#">Login</a>
</li>
<li>
<a class="page-scroll" href="#services">Services</a>
</li>
<li>
<a class="page-scroll" href="#portfolio">Portfolio</a>
</li>
<li>
<a class="page-scroll" href="#contact">Contact</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<div id class="container">
<?php include("./formstwo/ClientSignup.php"); ?>
<?php include("./forms/SurveyeeSignup.php"); ?>
</div>
クライアントのサインアップ
<?php
if(isset($_POST['submit'])){
include("./forms/connection.php");
$username = $_POST['username'];
$fullname = $_POST['fullname'];
$email = $_POST['email'];
$companyname = $_POST['companyname'];
$website = $_POST['website'];
$password = $_POST['password'];
$confirmpassword = $_POST['confirmpassword'];
$user = mysqli_query($con, "SELECT username from user WHERE username = '".$username."'");
$count = mysqli_num_rows($user);
if($password != $confirmpassword){
echo '<script language="javascript">';
echo 'alert("Password does not match!")';
echo '</script>';
}
else{
if($count != 0){
echo '<script language="javascript">';
echo 'alert("Username already exists!")';
echo '</script>';
}
else{
$insert = mysqli_query($con, "INSERT INTO `user` (`username`,`fullname`,`email`,`companyname`,`website`,`age`,`password`,`gender`,`occupation`,`usertype`) VALUES ('$username','$fullname','$email','$companyname','$website','','$password','','','Client')");
if(!$insert){
echo mysqli_errno();
}
else{
echo '<script language="javascript">';
echo 'alert("Registration Success!")';
echo '</script>';
}
}
}
}
?>
<div id="clientsignup" class="modal" tabindex="1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" id="close" class="close" data-dismiss="modal">×</button>
<h3 class="modal-title">Sign Up</h3>
</div>
<div class="modal-body">
<div class="row">
<form action="#" method="POST">
<div class="row form-group">
<div class="col-sm-12">
<input type="text" name="username" id="username" class="form-control" placeholder="Username">
</div>
</div>
<div class="row form-group">
<div class="col-sm-12">
<input type="text" name="fullname" id="fullname" class="form-control" placeholder="Fullname">
</div>
</div>
<div class="row form-group">
<div class="col-sm-12">
<input type="email" name="email" id="email" class="form-control" placeholder="Email">
</div>
</div>
<div class="row form-group">
<div class="col-sm-12">
<input type="text" name="companyname" id="companyname" class="form-control" placeholder="Company Name">
</div>
</div>
<div class="row form-group">
<div class="col-sm-12">
<input type="text" name="website" id="website" class="form-control" placeholder="Website (OPTIONAL)">
</div>
</div>
<div class="row form-group">
<div class="col-sm-12">
<input type="password" name="password" id="password" class="form-control" placeholder="Password">
</div>
</div>
<div class="row form-group">
<div class="col-sm-12">
<input type="password" name="confirmpassword" id="confirmpassword" class="form-control" placeholder="Confirm Password">
</div>
</div>
<div class="row form-group">
<div class="col-sm-12">
<input type="submit" name="submit" id="sign_up" class="form-control btn btn-primary" value="Sign Up">
</div>
</div>
</form>
</div>
</div>
<div class="modal-footer">
<p class="text-center">Already have an account? <a href="">Login</a></p>
</div>
</div>
</div>
</div>
Surveyeeサインアップ
<?php
if(isset($_POST['submit'])){
include("connection.php");
$username = $_POST['username'];
$fullname = $_POST['fullname'];
$email = $_POST['email'];
$age = $_POST['age'];
$password = $_POST['password'];
$confirmpassword = $_POST['confirmpassword'];
$gender = $_POST['gender'];
$occupation = $_POST['occupation'];
$user = mysqli_query($con, "SELECT username from user WHERE username = '".$username."'");
$count = mysqli_num_rows($user);
if($password != $confirmpassword){
echo '<script language="javascript">';
echo 'alert("Password does not match!")';
echo '</script>';
}
else{
if($count != 0){
echo '<script language="javascript">';
echo 'alert("Username already exists!")';
echo '</script>';
}
else{
$insert = mysqli_query($con, "INSERT INTO `user` (`username`,`fullname`,`email`,`companyname`,`age`,`password`,`gender`,`occupation`,`usertype`) VALUES ('$username','$fullname','$email','','$age','$password','$gender','$occupation','Surveyee')");
if(!$insert){
echo mysqli_errno();
}
else{
echo '<script language="javascript">';
echo 'alert("Registration Success!")';
echo '</script>';
}
}
}
}
?>
<div id="surveyeesignup" class="modal" tabindex="1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" id="close" class="close" data-dismiss="modal">×</button>
<h3 class="modal-title">Sign Up</h3>
</div>
<div class="modal-body">
<div class="row">
<form action="#" method="POST">
<div class="row form-group">
<div class="col-sm-12">
<input type="text" name="username" id="username" class="form-control" placeholder="Username">
</div>
</div>
<div class="row form-group">
<div class="col-sm-12">
<input type="text" name="fullname" id="fullname" class="form-control" placeholder="Fullname">
</div>
</div>
<div class="row form-group">
<div class="col-sm-12">
<input type="email" name="email" id="email" class="form-control" placeholder="Email">
</div>
</div>
<div class="row form-group">
<div class="col-sm-12">
<input type="text" name="age" id="age" class="form-control" placeholder="Age" pattern="[0-9]+">
</div>
</div>
<div class="row form-group">
<div class="col-sm-12">
<input type="password" name="password" id="password" class="form-control" placeholder="Password">
</div>
</div>
<div class="row form-group">
<div class="col-sm-12">
<input type="password" name="confirmpassword" id="confirmpassword" class="form-control" placeholder="Confirm Password">
</div>
</div>
<div class="row form-group">
<div class="col-sm-12">
<input type="radio" class="" name="gender" value="male" placeholder="">
<label>Male</label>
<input type="radio" class="" name="gender" value="female" placeholder="">
<label>Female</label>
</div>
</div>
<div class="row form-group">
<p style="float: right; margin-right: 180px;"><b>Select Occupation:</b> <select name="occupation"></p>
<option>Student</option>
<option>Employed</option>
<option>Unemployed</option>
</select>
</div>
<div class="row form-group">
<div class="col-sm-12">
<input type="submit" name="submit" id="sign_up" class="form-control btn btn-primary" value="Sign Up">
</div>
</div>
</form>
</div>
</div>
<div class="modal-footer">
<p class="text-center">Already have an account? <a href="">Login</a></p>
</div>
</div>
</div>
</div>
可能な場合はClientSignup.phpとSurveyeeSignup.phpサンプルコードを投稿してくださいます。 – webDev
done sir @SSingh – ranger
モーダルを使用しないでください。ダイアログまたはポップアップウィンドウ用のモーダルおよびモーダルクラスを使用しています。なぜあなたはお互いに重なり合う2つのモーダルを使用しました。 – webDev