HTML CODE:
<li class="llogin">
<a class="mlogin" data-target="#loginmodal" data-toggle="modal"><span class="glyphicon glyphicon-chevron-down pull-right"></span>Login</a>
<div class="modal" id="loginmodal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<div class="form-group">
<input type="text" name=username id="username" placeholder="username" value="" class="form-control" />
</div>
<div class="form-group">
<input type="password" name=password id="password" placeholder="password" value="" class="form-control" />
</div>
<div class="form-group">
<div class="row">
<div class="text-center" class="col-md-6">
<input type="submit" name="loginsubmit" id="loginsubmit" class="form-control btn btn-info" value="LogIn" style="width:20%">
</div>
</div>
</div>
<div id="loginresult" class="alert-success"></div>
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal">Close</button>
<button class="btn btn-primary">Login</button>
</div>
</div>
</div>
</div>
</li>
AJAX CODE:
$("#loginsubmit").click(function(){
var username = $("#username").val();
var password = $("#password").val();
$.ajax({
type:'POST',
data: {username:username,password:password},
url:'login.php',
success:function(logged)
{
$("#loginresult").html(logged);
$('#loginmodal').modal("show");
},
})
})
I am building web store using PHP.i want to show message in bootstrap
modal but do not know what's going wrong in above code.
Please suggest me what changes should i do to achieve the desired behavior.
I am getting message without modal but i want to show message in modal.
<?php
require_once("config.php");
if(isset($_REQUEST['username']))
{
$username= $_REQUEST['username'];
$password= $_REQUEST['password'];
//echo $username;
$con = mysqli_connect(DB_HOST,DB_USERNAME,DB_PASSWORD,DB_NAME);
if($con)
{
$sql = "SELECT `username`,`password` FROM `register` WHERE `username`=? AND `password`=?";
$obj = mysqli_prepare($con,$sql);
if(is_object($obj))
{
mysqli_stmt_bind_param($obj,"ss",$username,$password);
mysqli_stmt_bind_result($obj,$myuser_name, $mypassword);
mysqli_stmt_execute($obj);
mysqli_stmt_store_result($obj);
mysqli_stmt_fetch($obj);
if($myuser_name == $username && $mypassword == $password)
{
echo "Successfully Logged In";
}else{
echo "Logged In failed";
}
}else{
echo "Not Object";
}
}else{
echo "db problem";
}
}else{
echo "value not set";
}
?>
here is PHP Code.
I cant find div with id 'loginmodal' ind your html. Maybe that is missing?