これは私の書式設定がちょっと残っているかもしれないので、ここで初めて質問しています。ログインフォームを取得して、新しい登録者のユーザーIDとパスワードが正常に送信されたことを受け入れる方法は?
私のログインフォームは、フォームが正常に送信されたというメッセージが表示されても、送信された新しいユーザー登録を受け付けません。 phpmyadminでデータベースをチェックすると、新しい登録者の記録はありません。私のコードは以下の通りです。
のindex.php
<!-- Modal -->
<a href="#" class="modal" id="modal-one" aria-hidden="true">
</a>
<div class="modal-dialog">
<div class="modal-header">
<a href="#" class="btn-close" aria-hidden="true">×</a>
</div>
<div class="modal-body">
<div id="content">
<ul id="tabs" class="nav nav-tabs" data-tabs="tabs">
<li class="active"><a href="#red" data-toggle="tab">LOGIN </a></li>
<li><label>/</label></li>
<li><a href="#orange" data-toggle="tab">SIGNUP</a></li>
</ul>
<div id="my-tab-content" class="tab-content">
<div class="tab-pane active" id="red">
<form action="main.php" method="post" id="formID1" class="formular">
<span class="err"><?php if(isset($_GET['$message'])){ echo $_GET['$message'];} if(isset($_GET['loginerr'])){ echo $_GET['loginerr'];}if(isset($_GET['herr1'])){ echo $_GET['herr1'];} ?><br></span><br>
<div class="form-group">
<input type="text" placeholder="EMAIL ADDRESSS" name="email" class="validate[required,custom[email]] form-control" id="usr1" >
<span class="email"></span>
</div>
<div class="form-group">
<input type="password" placeholder="PASSWORD" name="password" class="validate[required] form-control" id="pwd1">
<span class="pass"></span>
</div>
<div class="form-group">
<input type="submit" id="submit1" name="login" class="submit1 btn btn-info" value="LOGIN">
</div>
<div class="modal-footer">
<a href="#modal-two">RESET YOUR PASSWORD</a>
</div>
</form> </div>
<div class="tab-pane" id="orange">
<form action="main.php" method="post" id="formID2" class="formular">
<span class="err" id="a_err"><?php if(isset($_GET['$message'])){ echo $_GET['$message'];} ?><br></span><br>
<div class="form-group">
<input type="text" placeholder="EMAIL ADDRESSS" name="s_email" class="validate[required,custom[email]] form-control" id="usr2" >
<span class="email"></span>
</div>
<div class="form-group">
<input type="password" placeholder="PASSWORD" name="s_password" class="validate[required] form-control" id="spwd">
<span class="pass"></span>
</div>
<div class="form-group">
<input type="password" placeholder="CONFIRM PASSWORD" name="confirm_password" class="form-control validate[required,equals[spwd]]" id="cpwd">
<span class="rght"></span>
</div>
<div class="form-group">
<input type="submit" id="submit2" name="s_submit" class="submit2 btn btn-info" value="CREATE YOUR ACCOUNT">
</div>
<div class="modal-footer">
BY CREATING AN ACCOUNT YOU ACKNOWLEDGE THAT YOU
<a href="#">ACCEPT THE TERMS & CONDITIONS</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
SQLファイル
CREATE TABLE IF NOT EXISTS `login` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`email` varchar(55) NOT NULL,
`password` varchar(55) NOT NULL,
`confirm_password` varchar(55) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;
--
-- Dumping data for table `login`
--
INSERT INTO `login` (`id`, `email`, `password`, `confirm_password`)
validation.js
function signup_validation()
{
alert("helloooooooo");
var usr=document.getElementById("usr2").value;
alert($usr);
var pwd=document.getElementById("spwd").value;
var cpwd=document.getElementById("cpwd").value;
var atpos = usr.indexOf("@");
var dotpos = usr.lastIndexOf(".");
if(usr=="" || pwd=="" || cpwd=="" || pwd!=cpwd)
{
document.getElementById("a_err").innerHTML="Please Fill All Fields";
if(usr==""){
document.getElementById("a_err").innerHTML="Please Enter User Name";
}
else if (atpos<1 || dotpos<atpos+2 || dotpos+2>=usr.length) {
document.getElementById("js_error").innerHTML="Not a valid e-mail address";
}
else if(pwd==""){
document.getElementById("a_err").innerHTML="Please Enter Email";
}
else if(cpwd==""){
document.getElementById("a_err").innerHTML="Please Re-Enter password ";
}
else if(pwd!=cpwd){
document.getElementById("a_err").innerHTML="Password Do Not Match";
}
return false;
}
else{
document.getElementById("a_err").innerHTML="";
return true;
}
}
function login_validation()
{
var username=document.getElementById("usr1").value;
//alert(username);
var atpos1 = username.indexOf("@");
var dotpos1 = username.lastIndexOf(".");
var password=document.getElementById("pwd1").value;
if(username=="" || password=="")
{
document.getElementById("js_error1").innerHTML="Please Fill All Fields";
if(username==""){
document.getElementById("js_error1").innerHTML="Please Enter Your Email Id";
}
else if (atpos1<1 || dotpos1<atpos1+2 || dotpos1+2>=username.length) {
document.getElementById("js_error1").innerHTML="Not a valid e-mail address";
}
else if(password==""){
document.getElementById("js_error1").innerHTML="Please Enter Password.";
}
return false;
}
else{
document.getElementById("js_error1").innerHTML="";
return true;
}
}
main.php
<?php
include 'config.php';
session_start();
//echo "hii";
if(isset($_POST['s_submit'])){
$email=$_POST['s_email'];
//echo $email;
$pass=$_POST['s_password'];
$sql=mysqli_query($con,"INSERT INTO personal_info (`email`,`password`,`first_time_login`)VALUES('".$email."','".$pass."','0')");
header('location:index.php?$message="form successfully submitted you can login"');
}
if(isset($_POST['login'])){
$email=$_POST['email'];
$pass=$_POST['password'];
$q=mysqli_query($con,"SELECT * FROM personal_info WHERE email='".$email."' AND password='".$pass."' ");
$row_fetch=mysqli_fetch_assoc($q);
echo $row_fetch['first_name'];
$count=mysqli_num_rows($q);
if($count>0){
$id=$row_fetch['id'];
$_SESSION['id']=$id;
//$id=mysqli_insert_id($conn);
if($row_fetch['first_time_login']=="1")
{
header('location:index.php#');
}
else{
header('location:user.php');
}
}
else{
header('location:index.php?loginerr="invalid user"');
}
}
mysqli_close($con);
?>
データベースレコードの挿入用のPHPコードはどこですか? – Irvin
初めての投稿にはかなり良い書式設定があります(ただし履歴には別途記載されています)。挿入する場所にPHPを追加できますか? – chris85
phpとmysqlでエラーをチェックし、コンソールを見てください。それは完全なコードを見ることなく提供できる最高の "私"です。 –