How can I prevent the ordermodal.php from closing when I click a button even it refresh?
What I want to happen is when I click a button it will refresh the modal, BUT it will not CLOSE the modal either.
It is event handler? Im not sure tho.
This is my code for ordermodal.php
<?php
include_once 'ordermodal2.php';
/** *ordermodal.php **/
$id = "";
$order_date = "";
$order_time = "";
$order_id = "";
$order_deliverCharge = "";
$order_status = "";
$order_totalAmount= "";
$coordinates = "";
$driver_number = "";
$address = "";
$food_name="";
$special_request="";
$quantity="";
$amount="";
$orders="";
?>
<!-- MODALS --> <!-- DETAILS -->
<div id="myModal" class="modal fade" role="dialog" style="z-index: 1400;">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<form action="" method="post" class="form-horizontal">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><center>×</button>
<h4 class="modal-title" id="titleModal">Order Information</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label for="order_id" class="col-sm-2 control-label">Order ID</label>
<div class="col-lg-3">
<input type="text" input style="width:500px" class="form-control" name="ORDER_ID" id="ORDER_ID" placeholder="" value="" required="required" readonly>
</div>
</div>
<div class="form-group">
<label for="id" class="col-sm-2 control-label">User ID</label>
<div class="col-lg-3">
<input type="text" input style="width:500px" class="form-control" name="user_id" id="user_id" placeholder="" value="" required="required" readonly>
</div>
</div>
<div class="form-group">
<label for="order_date" class="col-sm-2 control-label">Order Date</label>
<div class="col-lg-3">
<input type="text" input style="width:500px" class="form-control" name="order_date" id="order_date" placeholder="" value="" required="required" readonly>
</div>
</div>
<div class="form-group">
<label for="order_time" class="col-sm-2 control-label">Order Time</label>
<div class="col-lg-3">
<input type="text" input style="width:500px" class="form-control" name="order_time" id="order_time" placeholder="" value="" required="required" readonly>
</div>
</div>
<div class="form-group">
<label for="order_deliverCharge" class="col-sm-2 control-label">Delivery Charge</label>
<div class="col-lg-3">
<input type="text" input style="width:500px" class="form-control" name="order_deliveryCharge" id="order_deliveryCharge" placeholder="" value="" required="required" readonly>
</div>
</div>
<div class="form-group">
<label for="order_totalAmount" class="col-sm-2 control-label">Total Amount</label>
<div class="col-lg-3">
<input type="text" input style="width:500px" class="form-control" name="order_totalAmount" id="order_totalAmount" placeholder="" value="" required="required" readonly>
</div>
</div>
<div class="form-group">
<label for="address" class="col-sm-2 control-label">Address</label>
<div class="col-lg-3">
<input type="text" input style="width:500px" class="form-control" name="address" id="address" placeholder="" value="" required="required" readonly>
</div>
</div>
<div class="form-group">
<label for="coordinates" class="col-sm-2 control-label">Coordinates</label>
<div class="col-lg-3">
<input type="text" input style="width:500px" class="form-control" name="coordinates" id="coordinates" placeholder="" value="" required="required" maxlength="11" readonly>
</div>
</div>
<div class="form-group">
<label for="driver_number" class="col-sm-2 control-label">Driver Number</label>
<div class="col-lg-3">
<input type="text" input style="width:500px" class="form-control" name="drivers_number" id="drivers_number" placeholder="" value="" required="required" readonly>
</div>
</div>
<div class="form-group">
<label for="order_status" class="col-sm-2 control-label">Order Status</label>
<div class="col-lg-3">
<input type="text" input style="width:500px" class="form-control" name="order_status" id="order_status" placeholder="" value="" required="required" readonly>
</div>
</div>
<?php
$order_id = trim(addslashes($_POST['ORDER_ID']));
$sql = "SELECT food_name, special_request, quantity, amount
FROM cart_tbl
WHERE order_id=$order_id";
$result = mysqli_query(connection2(), $sql);
?>
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>Food</th>
<th>Special Request</th>
<th>Quantity</th>
<th>Amount</th>
</tr>
</thead>
<?php
if(mysqli_num_rows($result)>0)
{
while($row = mysqli_fetch_array($result))
{
?>
<tr>
<td><?php echo $row["food_name"];?></td>
<td><?php echo $row["special_request"];?></td>
<td><?php echo $row["quantity"];?></td>
<td><?php echo $row["amount"];?></td>
</tr>
<?php
}
}
?>
</table>
</div>
<div class="modal-footer"> //This are the buttons
<button type="submit" input style="background-color:#00000;color:white;float:left" name="showfood" id="showFood" class="btn btn-primary " onclick="if(!confirm('Are you sure you want to see food order?')){return false;}"> Show Food </button>
<button type="submit" input style="background-color:#4CAF50;color:white" name="submitDelivered" id="submitDelivered" class="btn btn-primary " onclick="if(!confirm('Are you sure you want to deliver order?')){return false;}" > Delivered </button>
<button type="submit" input style="background-color:#0000FF;color:white" name="submitAccept" id="submitAccept" class="btn btn-primary" onclick="if(!confirm('Are you sure you want to accept order?')){return false;}" > Accept </button>
<button type="button" style="background-color:#FFFF00;color:black" class="btn btn-success" data-toggle="modal" data-target="#myDropdown" onclick="send('<?= $_POST['order_id'] ?>')"> Send </button>
<button type="submit" input style="background-color:#f44336;color:white" name="submitCancel" class="btn btn-danger" onclick="if(!confirm('Are you sure you want to cancel order?')){return false;}">Cancel</button>
<?php
if(isset($_POST['submitDelivered'])){
$order_id = trim(addslashes($_POST['ORDER_ID']));
$query = "UPDATE order_tbl SET `order_status`='Delivered' WHERE `order_id` = $order_id";
if (mysqli_query(connection2(), $query)) {
mysqli_query(connection2(), "COMMIT");
$_SESSION['message'] = "Order Delivered";
} else {
$_SESSION['message'] = mysqli_error(connection2());
mysqli_query(connection2(), "ROLLBACK");
}
}
if(isset($_POST['submitAccept'])){
$order_id = trim(addslashes($_POST['ORDER_ID']));
$query = "UPDATE order_tbl SET `order_status`='Accepted' WHERE `order_id` = $order_id";
if (mysqli_query(connection2(), $query)) {
mysqli_query(connection2(), "COMMIT");
$_SESSION['message'] = "Order Accepted";
} else {
$_SESSION['message'] = mysqli_error(connection2());
mysqli_query(connection2(), "ROLLBACK");
}
}
if(isset($_POST['submitCancel'])){
$order_id = trim(addslashes($_POST['ORDER_ID']));
$query = "UPDATE order_tbl SET `order_status`='Cancelled' WHERE `order_id` = $order_id";
if (mysqli_query(connection2(), $query)) {
mysqli_query(connection2(), "COMMIT");
$_SESSION['message'] = "Order Cancelled";
} else {
$_SESSION['message'] = mysqli_error(connection2());
mysqli_query(connection2(), "ROLLBACK");
}
}
?>
</div>
</form>
</div>
</div>
</div>
<script>
function send(order_id) {
document.getElementById("titleModal2").innerHTML = "Choose Driver";
document.getElementsByName("ORDER_ID_MODAL_2")[0].setAttribute("value", order_id);
document.getElementsByName("send")[0].setAttribute("name", "send");
}
</script>
Related
I want to add a class when a select has event select, this is my code:
$("form").find("input,select").on('focus',function(){
$(this).addClass("focus");
});
$("form").find("input,select").on('blur',function(){
$(this).removeClass("focus");
});
This is my HTML:
<form id="formEdit" method="post" action="<?=current_url();?>" enctype="multipart/form-data">
<div class="form-pad">
<div class="row">
<!--<div class="col s12 m8 push-m4">-->
<div class="col s12">
<div class="input-field">
<input id="nombre" name="nombre" type="text" class="validate" onkeypress="return valid_text(event)" maxlength="20" value="<?=$nombre;?>" required>
<input name="userID" type="hidden" value="<?=$userID;?>">
<input name="status" type="hidden" value="<?=$status;?>">
<label for="nombre" class="active">Nombres</label>
</div>
<div class="input-field">
<input name="apellidos" type="text" class="validate" onkeypress="return valid_text(event)" maxlength="30" value="<?=$apellidos;?>" required>
<label for="apellidos" class="active">Apellidos</label>
</div>
<div class="input-field">
<input name="email" type="email" class="validate" maxlength="49" value="<?=$correo;?>" required>
<label for="email" class="active">Correo Electrónico</label>
</div>
<div class="input-field">
<select id="select_privilegios" name="FK_id_rol" required>
<?=($id_rol=='') ? '<option value="" disabled selected>Seleccionar</option>': ''?>
<?php
foreach ($roles as $role) {
echo '<option value="'.$role->roleId.'" '.(($id_rol == (int)$role->roleId) ? 'selected': '').'>'.$role->role.'</option>';
}
?>
</select>
<label>Privilegios</label>
</div>
<div id="div_empresas" class="input-field">
<select name="id_empresa[]" id="select_empresas" multiple required>
<?php
$ids = array_map(function($e) {
return is_object($e) ? $e->id_empresa : $e['id_empresa'];
}, $id_empresa);
foreach ($empresas as $empresa) {
echo '<option value="'.$empresa->id_empresa.'" '.(in_array($empresa->id_empresa, $ids) ? 'selected': '').'>'.$empresa->nombre .'</option>';
}
?>
</select>
<label>Empresas</label>
</div>
</div>
</div>
<!-- Save Cancelar -->
<div class="row">
<div class="col s12 m12 l12 buttons" style="padding: 0">
<div id="botones">
<button class="waves-effect waves-light btn" type="submit" name="action1"><i class="material-icons right">done</i>Guardar</button>
<?php if($userID>0): ?>
<span href="#warningModal" class="modal-trigger waves-effect waves-light btn <?=($status)? "red lighten-1" : "blue darken-4";?>"><i class="material-icons right"><?=($status)? "delete" : "lock_open";?></i><?=($status)? "Eliminar" : "Habilitar";?></span>
<button type="submit" name="action2" class="hide"></button>
<?php endif; ?>
<i class="material-icons right">clear</i>Cancelar
</div>
</div>
</div>
</div>
</form>
This code work very well in input text or other types of input but, in select elements don´t detect the focus event. If someone could help me,
I would appreciate it very much.
Hi, guys:
For some resaon the event.preventDefault() function not working on safari browser, but working fine on Google Chrome and Firefox. What I want to do is prevent the user to submit the form, unless they finish the google reCAPTCHA(Version 2). Please let me know how can I fix this issue. Appreciate you help.
Here is the code:
<div class="row">
<h4>
<center></center>
</h4>
<form action="http://g/r59jr" method="POST" id="form">
<div class="col-md-8 col-md-offset-2">
<div class="form-group">
<label for="firstname">First Name<small><i class="glyphicon glyphicon-asterisk" title="Required" alt="Required"></i></small></label>
<input type="text" class="form-control" name="First" placeholder="First Name" value="<?php echo set_value('First'); ?>" autocomplete="given-name" required>
</div>
<div class="form-group">
<label for="firstname"> Last Name<small><i class="glyphicon glyphicon-asterisk" title="Required" alt="Required"></i></small></label>
<input type="text" class="form-control" name="Last" placeholder="Last Name" value="<?php echo set_value('Last'); ?>" autocomplete="given-name" required>
</div>
<div class="form-group">
<label style="font-weight:bold;" for="email">Email<small><i class="glyphicon glyphicon-asterisk" title="Required" alt="Required"></i></small></label>
<input type="email" class="form-control" id="email" placeholder="Enter Email" name="email" autocomplete="email" value="<?php echo set_value('email'); ?>" required>
</div>
<div class="form-group">
<label style="font-weight:bold;" for="phone">Phone Number</label>
<input type="text" class="form-control" id="phone" placeholder="Phone Number" name="Phone" autocomplete="cellphone" value="<?php echo set_value('Phone'); ?>">
<span><small></small></span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="row top30 ">
<div class="col-sm-12">
<label for="agreeTOS">
<input type="checkbox" id="agreeTOS" name="agreeTOS" value='1' <?php echo set_checkbox('agreeTOS','1'); ?> required> I agree to the Privacy Policy<small><i class="glyphicon glyphicon-asterisk" title="Required" alt="Required"></i></small>
</label>
</div>
</div>
<div class="row top30 ">
<div class="col-sm-12">
<!--change-->
<div class="g-recaptcha" data-sitekey="6example.........."></div><br>
<button type="submit" value="<?php echo set_value('Submit'); ?>" class="btn btn-success btn-primary btn-lg signup submit_information_request btn-block" name="submitBtn" id="submitBtn">Sign-Up</button>
</form>
<!--change-->
<script src='https://www.google.com/recaptcha/api.js'></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(function() {
$('#form').submit(function(event) {
var verified = grecaptcha.getResponse();
if (verified.length === 0) {
event.preventDefault();
}
});
});
</script>
</div>
</div>
</div>
</div>
Good day! I'm trying to create modal for edit purposes. That means that it must be filled with retrieved data by specific ID. The problem is that it doesn't work.
Link used to call PHP edit function:
<span class="glyphicon glyphicon-edit"></span>
PHP edit function:
if (isset($_GET['edit'])) {
$edit = httpGet(ROOT . "/API.php?getId=" . $_GET['edit']);
?><script type="text/javascript">
$('#editId').modal('show');</script>
<?php
}
"editId" modal:
<div id="editId" class="modal fade" tabindex="1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="text-center">Edit Transaction</h1>
</div>
<div class="modal-body">
<form class="form col-md-12 center-block" action="API.php" method="post">
<div class="form-group">
<input type="text" id="id" name="id" class="form-control input-lg" placeholder="ID" value="<?php echo $edit[0]['id']; ?>">
</div>
<div class="form-group"> <select class="form-control" id="type" name="type" placeholder="Transaction type" value="<?php echo $edit[0]['type']; ?>">
<option value="withdaw">Withdraw</option>
<option value="deposit">Deposit</option>
</select></div>
<div class="form-group">
<input type="text" id="sum" name="sum" class="form-control input-lg" placeholder="Sum" value="<?php echo $edit[0]['sum']; ?>">
</div>
<div class="form-group">
<select class="form-control" id="currency" name="currency" placeholder="Currency" value="<?php echo $edit[0]['currency']; ?>">
<option value="ILS">ILS</option>
<option value="USD">USD</option>
</select></div>
<div class="form-group">
<input type="text" id="transaction" name="transaction" class="form-control input-lg" placeholder="Transaction ID" value="<?php echo $edit[0]['transaction']; ?>">
</div>
<div class="form-group">
<input type="text" id="buyer" name="buyer" class="form-control input-lg" placeholder="Buyer" value="<?php echo $edit[0]['buyer']; ?>">
</div>
<div class="form-group">
<input type="text" id="email" name="email" class="form-control input-lg" placeholder="Email" value="<?php echo $edit[0]['email']; ?>">
</div>
<div class="form-group">
<input type="text" id="invoice" name="invoice" class="form-control input-lg" placeholder="Invoice" value="<?php echo $edit[0]['invoice']; ?>">
</div>
<div class="form-group">
<input type="text" id="date" name="date" class="form-control input-lg" placeholder="Date" value="<?php echo $edit[0]['date']; ?>">
</div>
<div class="form-group">
<button class="btn btn-primary btn-lg btn-block" type="submit" value="updateId" name="updateId">Update Payment</button>
</div>
</form>
</div>
<div class="modal-footer">
<div class="col-md-12">
<button type="button" class="btn btn-default btn-lg btn-block" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
As suggested by Shukla you have to use $(document).ready(function{}); ie:
<script type="text/javascript">
$(document).ready(function{
$('#editId').modal('show');
});
</script>
Model is not appearing because function is called before html element loaded on the page. Either use ajax or use document.ready function.
I have some contact records in a database, I have queried the database and added the contacts in the database to the sidebar of the page. Now I want to see the full details of the contact on the main page in a form when I click on the profile button. I'm finding difficulty using jQuery to get the values from this contact list to the form on the main page.
What I have done is to create some hidden fields to store the values for each records, then use jQuery to add those values to the main form.
<div class="navbar-default sidebar" role="navigation">
<div class="sidebar-nav navbar-collapse">
<ul class="nav" id="side-menu">
<li class="sidebar-search">
<div class="input-group custom-search-form">
<input type="text" class="form-control" placeholder="Search...">
<span class="input-group-btn">
<button class="btn btn-default" type="button">
<i class="fa fa-search"></i>
</button>
</span>
</div>
<!-- /input-group -->
</li>
<?php
mysql_select_db('****webdb', mysql_connect('*******','****_is***','****'))or die(mysql_error());
$query=mysql_query("SELECT * FROM `w******`");
while( $row=mysql_fetch_array($query))
{
$id=$row['id'];
$name= $row['first_name'].' '.$row['last_name'];
?>
<input type="hidden" name="uname1" id="uname1" value="<?php echo $row['username']; ?>" />
<input type="hidden" name="password1" id="password1" value="<?php echo $row['password']; ?>" />
<input type="hidden" name="fname1" id="fname1" value="<?php echo $row['first_name']; ?>" />
<input type="hidden" name="lname1" id="lname1" value="<?php echo $row['last_name']; ?>" />
<input type="hidden" name="str1" id="str1" value="<?php echo $row['street']; ?>" />
<input type="hidden" name="city1" id="city1" value="<?php echo $row['city']; ?>" />
<input type="hidden" name="pcode1" id="pcode1" value="<?php echo $row['post_code']; ?>" />
<input type="hidden" name="country1" id="country1" value="<?php echo $row['country']; ?>" />
<input type="hidden" name="tel1" id="tel1" value="<?php echo $row['telephone']; ?>" />
<input type="hidden" name="email1" id="email1" value="<?php echo $row['email']; ?>" />
<input type="hidden" name="gsm1" id="gsm1" value="<?php echo $row['gsm']; ?>" />
<input type="hidden" name="jtitle1" id="jtitle1" value="<?php echo $row['job_title']; ?>" />
<input type="hidden" name="company1" id="company1" value="<?php echo $row['company']; ?>" />
<input type="hidden" name="url1" id="url1" value="<?php echo $row['url']; ?>" />
<input type="hidden" name="msn1" id="msn1" value="<?php echo $row['msn']; ?>" />
<input type="hidden" name="skype1" id="skype1" value="<?php echo $row['skype']; ?>" /
<li class="user<?php echo $id ?>">
<a><i class="fa fa-user fa-fw"></i><?php echo $name; ?> <button class="btn btn-info" id="checkClick" onclick="myFunction()">Profile</button></a>
</li>
<?php } ?>
</ul>
</div>
<!-- /.sidebar-collapse -->
</div>
<!-- /.navbar-static-side -->
</nav>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Dashboard</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
<form id="signUp" class="form-horizontal cmxform" name="signUp" action="">
<div class="form-group"><label class="col-sm-2 control-label" for="username">Username<b style="color:red;font-family: serif;">*</b></label>
<div class="col-sm-10"><input id="username" class="form-control" name="uname" type="text" /></div>
</div>
<div class="form-group"><label class="col-sm-2 control-label" for="password">Password<b style="color:red;font-family: serif;">*</b></label>
<div class="col-sm-10"><input id="password" class="form-control" name="password" type="password" /></div>
</div>
<div class="form-group"><label class="col-sm-2 control-label" for="firstname">First Name<b style="color:red;font-family: serif;">*</b></label>
<div class="col-sm-10"><input id="fname" class="form-control" name="fname" type="text" /></div>
</div>
<div class="form-group"><label class="col-sm-2 control-label" for="lastname">Last Name<b style="color:red;font-family: serif;">*</b></label>
<div class="col-sm-10"><input id="lname" class="form-control" name="lname" type="text" /></div>
</div>
<div class="form-group"><label class="col-sm-2 control-label" for="street">Street</label>
<div class="col-sm-10"><input id="str" class="form-control" name="str" type="text" /></div>
</div>
<div class="form-group"><label class="col-sm-2 control-label" for="city">City</label>
<div class="col-sm-10"><input id="city" class="form-control" name="city" type="text" /></div>
</div>
<div class="form-group"><label class="col-sm-2 control-label" for="postcode">Post Code</label>
<div class="col-sm-10"><input id="postcode" class="form-control" name="pcode" type="text" /></div>
</div>
<div class="form-group"><label class="col-sm-2 control-label" for="country">Country<b style="color:red;font-family: serif;">*</b></label>
<div class="col-sm-10"><select class="form-control" name="country">
<option selected="selected" id="country" ></option>
</select></div>
</div>
<div class="form-group"><label class="col-sm-2 control-label" for="telephone">Telephone<b style="color:red;font-family: serif;">*</b></label>
<div class="col-sm-10"><input id="tel" class="form-control" name="tel" type="tel" /></div>
</div>
<div class="form-group"><label class="col-sm-2 control-label" for="email">Email<b style="color:red;font-family: serif;">*</b></label>
<div class="col-sm-10"><input id="email" class="form-control" name="email" type="email" /></div>
</div>
<div class="form-group"><label class="col-sm-2 control-label" for="gsm">GSM</label>
<div class="col-sm-10"><input id="gsm" class="form-control" name="gsm" type="tel" /></div>
</div>
<div class="form-group"><label class="col-sm-2 control-label" for="jobtitle">Job Title</label>
<div class="col-sm-10"><input id="jobtitle" class="form-control" name="jtitle" type="text" /></div>
</div>
<div class="form-group"><label class="col-sm-2 control-label" for="company">Company</label>
<div class="col-sm-10"><input id="company" class="form-control" name="company" type="text" /></div>
</div>
<div class="form-group"><label class="col-sm-2 control-label" for="url">URL</label>
<div class="col-sm-10"><input id="url" class="form-control" name="url" type="url" /></div>
</div>
<div class="form-group"><label class="col-sm-2 control-label" for="msnmessenger">MSN Messenger</label>
<div class="col-sm-10"><input id="msnmessenger" class="form-control" name="msn" type="text" /></div>
</div>
<div class="form-group"><label class="col-sm-2 control-label" for="skype">Skype</label>
<div class="col-sm-10"><input id="skype" class="form-control" name="skype" type="text" /></div>
</div>
</form>
</div>
<!-- /.row -->
</div>
<!-- /#page-wrapper -->
</div>
<!-- /#wrapper -->
<!-- jQuery -->
<script src="../bower_components/jquery/dist/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="../bower_components/metisMenu/dist/metisMenu.min.js"></script>
<!-- Morris Charts JavaScript -->
<script src="../bower_components/raphael/raphael-min.js"></script>
<script src="../bower_components/morrisjs/morris.min.js"></script>
<script src="../js/morris-data.js"></script>
<!-- Custom Theme JavaScript -->
<script src="../dist/js/sb-admin-2.js"></script>
<script>
function myFunction() {
var username = ("#uname1").val();
$("#uname").val(username);
var lname = ("#lname1").val();
$("#lname").val(lname);
var str = ("#str1").val();
$("#str").val(str);
var city = ("#city1").val();
$("#city").val(city);
var pcode = ("#pcode1").val();
$("#pcode").val(pcode);
var country = ("#country1").val();
$("#country").val(country);
var tel = ("#tel1").val();
$("#tel").val(tel);
var email = ("#email1").val();
$("#email").val(email);
var gsm = ("#gsm1").val();
$("#gsm").val(gsm);
var jtitle = ("#jtitle1").val();
$("#jtitle").val(jtitle);
var company = ("#company1").val();
$("#company").val(company);
var url = ("#url").val();
$("#url").val(url);
var msn = ("#msn1").val();
$("#msn").val(msn);
var skype = ("#skype1").val();
$("#skype").val(skype);
}
</script>
There's a couple possible solutions you can do here.
First, you need to switch over to mysqli or PDO instead of mysql.
Since you are already using mysql, mysqli is VERY similar and won't take much effort to make the change.
Second, without knowing the full scope of this project it's hard to determine your best needs.
But, some solutions are as follows.
You could use a $_SESSION variable and hold your results in array
with PHP. Then you could loop over the array's index to produce the
desired "detailed" info on the main page.
You could query the database again when a name is clicked to gather
the more detailed information.
You could use ajax to query the database again and pull the data
asynchronously. Similar to the previous suggestion.
First point of concern is that you have hidden inputs containing sensitive information which is never good. I would populate your sidebar with the information from your initial call like you are doing. After that once the user clicks on that contact on the sidebar do an ajax call to your database to pull all of the contact information.
Hi im using jqBootstrapValidation to validate a form and all works well except for the password.
For example if I try to submit the form without filling in the fields it wont let me nor will it let me submit the form if email isn't in form example#site.com but even though I added data-validation-match-match tag to my second password input, the form still submit if the passwords don't match.
my code is:
<?php
$error = "";
include ('dblink.php');
session_start();
if(!empty($_SESSION['s_logged_n'])){
header("Location: index.php");
}
if($_SERVER['REQUEST_METHOD'] === 'POST')
{
if($_POST['form'] === 'login')
{
$username = mysqli_escape_string($con, trim($_POST['user']));
$password = md5(trim($_POST['password']));
$query = mysqli_query($con,"SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error());
$row = mysqli_fetch_array($query);
// now we check if they are activated
if(mysqli_num_rows($query) > 0)
{
if($row['Activated'] > 0)
{
$_SESSION['s_logged_n'] = 'true';
$_SESSION['s_username'] = $username;
$_SESSION['s_name'] = $row['Name'];
header("Location: index.php");
}else
{
$error = "<Br><div class=\"alert alert-warning\">Your account hasnt yet been activated.</div>";
}
}
else
{
$error = "<Br><div class=\"alert alert-danger\">Your username/password do not match.</div>";
}
}
if($_POST['form'] === 'register')
{
$first = addslashes(trim($_POST['fname']));
$surname = addslashes(trim($_POST['lname']));
$abr = mb_substr($surname, 0, 3);
$username = $first . $abr;
$email = addslashes(trim($_POST['email']));
$poste = addslashes(trim($_POST['poste']));
$pass = addslashes(trim($_POST['pass']));
$salary = addslashes(trim($_POST['salary']));
$conf = addslashes(trim($_POST['cpass']));
$ip = $_SERVER['REMOTE_ADDR'];
$date = date("d, m y");
$password = md5($pass);
}
}
?>
<DOCTYPE html>
<html>
<head>
<link href="css/bootstrap-theme.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap-theme.min.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link type="text/css" href="http://eonasdan.github.io/bootstrap-datetimepicker/styles/bootstrap-datetimepicker.min.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jqBootstrapValidation.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="http://eonasdan.github.io/bootstrap-datetimepicker/scripts/moment.js"></script>
<script type="text/javascript" src="http://eonasdan.github.io/bootstrap-datetimepicker/scripts/bootstrap-datetimepicker.js"></script>
<script>
$(function () { $("input,select,textarea").not("[type=submit]").jqBootstrapValidation(); } );
</script>
<body >
<div style="background-color:#CC0000; height: 100%" >
</br>
</br>
</br>
<div class="container">
<div class="panel panel-default" >
<div class="panel-body">
<div class="page-header">
<h1>Login</small></h1>
</div>
<form class="form-horizontal" role="form" action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span>
</span>
<input name="user" type="text" class="form-control" placeholder="Username">
</div></br>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span>
</span>
<input name="password" type="password" class="form-control" placeholder="Password">
</div>
<?php echo $error;?>
<div class="form-group">
<div class="col-sm-10">
<div class="checkbox">
<label>
<input type="checkbox"> Remember me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<input type="hidden" name="form" value="login" />
<button type="submit" id="login" name="login" class="btn btn-default">Sign in</button><button type="button" data-toggle="modal" data-target="#register" class="btn btn-warning btn-xs">Register</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="register" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Registration</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form" action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
<div class="form-group">
<label for="fname" class="col-sm-3 control-label">First Name</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="fname" name="fname" placeholder="Your first name." required>
</div>
</div>
<div class="form-group">
<label for="lname" class="col-sm-3 control-label">Last Name</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="lname" name="id="lname"" placeholder="Your last name." required>
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-3 control-label">Email</label>
<div class="col-sm-9">
<input type="email" class="form-control" id="email" name="email" placeholder="Your email." required>
</div>
</div>
<div class="form-group">
<label for="poste" class="col-sm-3 control-label">Poste</label>
<div class="col-sm-9">
<select class="form-control" id="poste" name="poste">
<option value="Surface de Vente">Surface de Vente</option>
<option value="Caisse">Caisse</option>
<option value="Protection des biens">Protection des biens</option>
<option value="Circulation des marchandises">Circulation des marchandises</option>
<option value="Préposé à la marque">Préposé à la marque</option>
<option value="Réserve">Réserve</option>
<option value="Électronique">Électronique</option>
<option value="Biens Modes">Biens Modes</option>
<option value="Starbucks">Starbucks</option>
<option value="Ressources humaines">Ressources humaines</option>
</select>
</div>
</div>
<div class="form-group">
<label for="salary" class="col-sm-3 control-label">Salary</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="salary" name="salary" placeholder="Your salary." required>
</div>
</div>
<div class="form-group">
<label for="pass" class="col-sm-3 control-label">Password</label >
<div class="col-sm-9">
<input type="password" minlength="6" class="form-control" id="pass" name="pass" required>
</div>
</div>
<div class="form-group">
<label for="cpass" class="col-sm-3 control-label">Confirm</label>
<div class="col-sm-9">
<input type="password" minlength="6" class="form-control" id="cpass" name="cpass" data-validation-match-match="pass" required>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<input type="hidden" name="form" value="register" />
<button type="submit" class="btn btn-danger">Register <span class="glyphicon glyphicon-ok"></span></button>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</body>
</html>
the form, which is in there is:
<form class="form-horizontal" role="form" action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
<div class="form-group">
<label for="fname" class="col-sm-3 control-label">First Name</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="fname" name="fname" placeholder="Your first name." required>
</div>
</div>
<div class="form-group">
<label for="lname" class="col-sm-3 control-label">Last Name</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="lname" name="id="lname"" placeholder="Your last name." required>
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-3 control-label">Email</label>
<div class="col-sm-9">
<input type="email" class="form-control" id="email" name="email" placeholder="Your email." required>
</div>
</div>
<div class="form-group">
<label for="poste" class="col-sm-3 control-label">Poste</label>
<div class="col-sm-9">
<select class="form-control" id="poste" name="poste">
<option value="Surface de Vente">Surface de Vente</option>
<option value="Caisse">Caisse</option>
<option value="Protection des biens">Protection des biens</option>
<option value="Circulation des marchandises">Circulation des marchandises</option>
<option value="Préposé à la marque">Préposé à la marque</option>
<option value="Réserve">Réserve</option>
<option value="Électronique">Électronique</option>
<option value="Biens Modes">Biens Modes</option>
<option value="Starbucks">Starbucks</option>
<option value="Ressources humaines">Ressources humaines</option>
</select>
</div>
</div>
<div class="form-group">
<label for="salary" class="col-sm-3 control-label">Salary</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="salary" name="salary" placeholder="Your salary." required>
</div>
</div>
<div class="form-group">
<label for="pass" class="col-sm-3 control-label">Password</label >
<div class="col-sm-9">
<input type="password" minlength="6" class="form-control" id="pass" name="pass" required>
</div>
</div>
<div class="form-group">
<label for="cpass" class="col-sm-3 control-label">Confirm</label>
<div class="col-sm-9">
<input type="password" minlength="6" class="form-control" id="cpass" name="cpass" data-validation-match-match="pass" required>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<input type="hidden" name="form" value="register" />
<button type="submit" class="btn btn-danger">Register <span class="glyphicon glyphicon-ok"></span></button>
</form>
and the javascript is:
<script>
$(function () { $("input,select,textarea").not("[type=submit]").jqBootstrapValidation(); } );
</script>
I get no error in my js console and I dont see what the error could be, anyone is familiar with this?
Also its ignoring the min character.