How to get the specific id from foreach using codeigniter - javascript

Just want to ask on how to get the ID in a specific foreach
My Controller
public function validate_subtopic(){
$data = array('success' => false, 'messages' => array());
$this->form_validation->set_rules("subtopicname", "SubTopicName", "trim|required");
$this->form_validation->set_rules("subtopicdescription", "SubTopicDescription", "trim|required");
$this->form_validation->set_error_delimiters('<p class="text-danger">', '</p>');
if($this->form_validation->run()){
$data['success'] = true;
$subtopic_data = array(
'subtopicname' => $this->input->post('subtopicname'),
'subtopicdescript' => $this->input->post('subtopicdescription'),
'subjectID' => $this->input->post('subjectID'),
'topicID' => $this->input->post('topicID'),
);
$this->addtopic_model->insert_subtopic($subtopic_data);
}
else{
foreach ($_POST as $key => $value) {
$data['messages'][$key] = form_error($key);
}
}
echo json_encode($data);
}
My Model
public function insert_subtopic($subtopic_data){
$this->db->insert('subtopics', $subtopic_data);
}
My view from bootstrap modal
<div class="modal inmodal fade" id="addSubTopic" tabindex="-1" role="dialog" aria-hidden="true">
<?php
$att = array(
'method' => 'POST',
'id' => "form-user_sub");
echo form_open("topicAdd_Controller/validate_subtopic", $att);
?>
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h5 class="modal-title">Please Input SubTopic</h5>
</div>
<div id="the-message"></div>
<div class="modal-body">
<form role="form">
<div class="form-group">
<label>Sub Topic Name</label>
<input class="form-control" name="subtopicname" id="subtopicname" type="text">
</div>
<div class="form-group">
<label>Sub Topic Description</label>
<textarea name="subtopicdescription" id="subtopicdescription" class="form-control">
</textarea>
</div>
<?php foreach($sample as $row){
?>
<?php $index = current($sample); ?>
<input type="text" value="<?php echo $row['topicID']; ?> name="topicID">
<?php } ?>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save</button>
</div>
</div>
</div>
<?php form_close();?>
</div>
This is the output of $sample:
The problem is I can't get the ID from the specific foreach loop I choose. how can I solve this?
Please help

You can use while(){} method, so your script will be like this
$i = 0;
$res = array();
while($data = $_POST){
$res[$i] = $data;
$i++;
}
echo json_encode($res);

Related

cannot insert data from Database to Modal PHP

I tried to make a Details-Modal, which gets information from the database "products" when the user clicks on the Details-button. However, there are problems with the code, which I couldn't figure out.
when I run on a localhost server, I get this:
Notice: Undefined index: id in
D:\xampp\htdocs\web01\includes\details.php on line 3
Index
<?php
include 'includes/connect_database.php';
$sql ="SELECT * FROM products WHERE category=1";
$category2 = $db->query($sql);
?>
<?php while ($sanpham =mysqli_fetch_assoc($category2)):?>
<div class="col-md-4 col-sm-6 col-xs-12 single_featured_area">
<div class="single_featured wow fadeIn" data-wow-duration=".5s">
<?php echo "<img src='../images/menu/".$product['image']."'>";?>
<div class="featured_overlay">
<div class="overlay_content">
<h3 style="color: white;"> <?= $product['name'];?></h3>
**<button type="button" class="btn-lg" data-toggle="modal" onclick="detailsmodal(<?= $product['id'];?>)">Bestellen</button>**
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php
include 'includes/details.php';
include 'includes/footer.php'; ?>
and footer.php :
<?php
define('BASEURL','/web02/');
?>
<script>
function detailsmodal(id){
var data = {"id":id};
jQuery.ajax({
url: <?=BASEURL;?>+'menu/includes/details.php',
method: "post",
data : data,
success : function(data){
jQuery('body').append(data);
jQuery('#detail-pd').modal('toggle');
},
error : function(){
alert("CAnnot connect");
}
});
}
</script>
and details.php :
<?php
include 'connect_database.php';
**$id = $_POST['id'];
$id = (int)$id;**
$sql = "SELECT * FROM products WHERE id='$id'";
$result = $db->query($sql);
$detailsmd = mysqli_fetch_assoc($result);
?>
<?php ob_start(); ?>
<div class="modal fade sushi01" id="detail-pd" tabindex="-1" role="dialog" aria-labelledby="detail-pd" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button class="close" type="button" onclick="closeModal()" aria-label="close">
<span aria-hidden="true" >×</span>
</button>
<h4 class="modal-title text-center"><?= $detailsmd['name'];?></h4>
</div>
<div class="modal-body">
<div class="container-fluid">
<div class="row">
<div class="col-sm-6">
<div class="center-block">
<img src="<?= $detailsmd['image'];?>" alt="<?= $detailsmd['name'];?>" class="imgbestellen img-responsive">
</div>
</div>
<div class="col-sm-6">
<h4>Description</h4>
<p><?= $detailsmd['text'];?></p>
<hr>
<p>Price: <?= $detailsmd['preis'];?></p>
<form action="add-cart.php" method="post">
<div class="form-group">
<label for="quantity">Quantity :</label>
<input type="text" class="form-control" id="quantity" name="quantity">
</div>
<div class="form-group">
<label for="size"></label>
<select name="size" id="size" class="form-control">
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
</select>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-warning" type="submit"><span class="glyphicon glyphicon-shopping-cart"></span> Bestellen</button>
<button class="btn btn-dedault" onclick="closeModal()">Cancle</button>
</div>
</div>
</div>
</div>
<script>
function closeModal(){
jQuery('#detail-pd').modal('hide');
setTimeout(function(){
jQuery('#detail-pd').remove();
},500);
}
</script>
<?php echo ob_get_clean(); ?>

Can't show an image before uploading

This is my problem when im trying to change the image to my 2nd data it's not changing but when i tried the first data it's changing i don't know the reason why it's not working on the second data. Can someone help me with this?
Here is my form where the image and file is in.
Update
here is the picture the news with id 42 when i change the image of that the image is not changing but with the news with id 40 it's changing.
Here is my whole code.
$stmt = mysqli_prepare($con, "SELECT * FROM news ORDER BY news_id");
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while($row = mysqli_fetch_array($result)){
?>
<tr>
<td><?php echo $row['news_id']; ?></td>
<td><?php echo $row['news_title']; ?></td>
<td><?php echo $row['news_date']; ?></td>
<td><?php echo $row['news_content']; ?></td>
<td><img style="height:150px; width:200px;" src="<?php echo $row['news_image']; ?>" ></td>
<td>
<button class="btn btn-info" data-toggle="modal" data-target="#newsedit<?php echo $row['news_id'];?>"><span class="glyphicon glyphicon-edit"></span> Edit</button>
<a class='btn btn-danger delete-object' data-toggle="modal" data-target="#newsdelete<?php echo $row['news_id'];?>"><span class="glyphicon glyphicon-remove"></span> Delete</a>
<div class="modal fade" id="newsdelete<?php echo $row['news_id'];?>" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
Are you sure you want to delete this?
</div>
<div class="modal-footer">
<a class='btn btn-danger left-margin' href="delete.php?newsid=<?php echo $row['news_id'];?>" >Yes</a>
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
</div>
</div>
</div>
</div>
<div id="newsedit<?php echo $row['news_id'];?>" class="modal fade" 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">Edit events</h4>
</div>
<div class="modal-body edit-content">
<form method="POST" enctype="multipart/form-data" action ="edit2.php?newsid=<?=$row['news_id']?>">
<div class="form-group">
<label for="title">News Title</label>
<input type="text" name="titles" class="form-control title" id="title" placeholder="News Title" value="<?php echo $row['news_title']; ?>">
</div>
<div class="form-group">
<label for="date">Date</label>
<input type="text" name="dates" class="form-control date" id="date" placeholder="Date" value="<?php echo $row['news_date']; ?>"s>
</div>
<div class="form-group">
<label for="content">News Content</label>
<textarea class="form-control content" name="contents" rows="5" id="content"><?php echo $row['news_content']; ?></textarea>
</div>
<img id="blah" name="newsimages" src="<?php echo $row['news_image']; ?>" width="200px" height="140px"/>
<input id="image" name="image" class="fileupload" type="file" accept="image/*"/>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class='btn btn-info left-margin'>Yes</a>
</form>
</div>
</div>
</div>
</div>
</td>
</tr>
<?php
}
?>
here is the js for showing the image before uploading.
<script type="text/javascript">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#image").change(function(){
readURL(this);
});
</script>
Use something like this:
function readURL(input) {
if (input.files && input.files[0]) {
var url = URL.createObjectURL(input.files[0]);
$(input).siblings('img').attr('src', url);
}
}
$(".fileupload").change(function() {
readURL(this);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img name="newsimages" width="200px" height="140px"/>
<input name="image" class="fileupload" type="file" accept="image/*" />
Don't use duplicate ids in a document! This causes undefined behavior, and generally results in things not happening as expected. Easiest solution is to remove any ids in the HTML inside your PHP while loop.

PHP Login not working

I have been working on a ban management system for a little bit but I encountered a error with the login system where it does not work
Live example:
http://lotus.pe.hu/lbans/index.php/
username: admin
pass: anmol123
Their is no error or anything with the code from where I can tell if you need the code I will post it
index.php
<html>
<head>
<link rel="stylesheet" href="css/bootstrap.min.css"/>
<title>LotusBans [BETA] [V 1.0] ~ Home</title>
</head>
<body>
<?php
require("api/api.php");
require("header.php");
?>
<div class="jumbotron">
<div class="container">
<h2>LotusBans [BETA] [v1.0]</h2>
<p>View the players banned on the LotusNetwork Here</p>
</div>
</div>
<?php if (isset($_SESSION["username"])) { ?>
<div class="container">
<input type="button" value="+" data-toggle="modal" data-target="#modal" class="btn btn-primary pull-right"/>
<br/><br/>
</div>
<?php } ?>
<div class="container">
<table class="table table-bordered">
<tr>
<th>ID</th>
<th>UUID</th>
<th>Date</th>
<th>Reason</th>
</tr>
<?php
$bans = get_bans();
while ($ban = $bans->fetch_assoc()) {
?>
<tr>
<td><?php echo $ban["id"] ?></td>
<td><?php echo $ban["uuid"] ?></td>
<td><?php echo $ban["date"] ?></td>
<td><?php echo $ban["reason"] ?></td>
</tr>
<?php } ?>
</table>
</div>
<div class="modal fade" id="modal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Add Ban</h4>
</div>
<form id="form">
<div class="modal-body">
<div class="form-group">
<input type="text" id="uuid" name="uuid" placeholder="UUID" class="form-control"/>
</div>
<div class="form-group">
<input type="text" id="reason" name="reason" placeholder="Reason" class="form-control"/>
</div>
</div>
<div class="modal-footer">
<input type="submit" class="btn btn-primary"/>
</div>
</form>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
$(document).ready(function() {
$("#form").submit(function(e) {
e.preventDefault();
var uuid = $("#uuid").val();
var reason = $("#reason").val();
$.post("api/add.php", { uuid: uuid, reason: reason }, function(data) {
location.href = "ban.php?id=" + data;
});
});
});
</script>
</body>
header.php
<nav class="navbar navbar-default">
<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>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">LotusBans</a>
</div>
<?php session_start(); if (!isset($_SESSION["username"])) { ?>
<form method="post" action="login.php" class="navbar-form navbar-right">
<div class="form-group">
<input type="text" name="username" placeholder="Username" class="form-control">
<input type="password" name="password" placeholder="Password" class="form-control">
</div>
<button type="submit" class="btn btn-primary">Log In</button>
</form>
<?php } else { ?>
<div class="navbar-right">
<p class="navbar-text">Welcome, <?php echo $_SESSION["username"]; ?></p>
</div>
<?php } ?>
</div><!-- /.container-fluid -->
api.php
<?php
define("key", file_get_contents("http://lotus.pe.hu/lbans/can'tenterthis as this is a key"));
function get_mysql() {
$mysql = new mysqli("", "", "", "");
if ($mysql->connect_error) {
die($mysql->connect_error);
}
return $mysql;
}
function add($uuid, $reason) {
$date = date("Y-m-d H:i:s");
get_mysql()->query("insert into bans (uuid, date, reason) values ('$uuid', '$date', '$reason')");
return get_mysql()->query("select id from bans where uuid = '$uuid' and date = '$date' and reason = '$reason'")->fetch_assoc()["id"];
}
function update($id, $uuid, $reason) {
get_mysql()->query("update bans set uuid = '$uuid', reason = '$reason' where id = $id");
}
function remove($uuid) {
get_mysql()->query("delete from bans where uuid = '$uuid'");
}
function remove_by_id($id) {
get_mysql()->query("delete from bans where id = $id");
}
function get($uuid) {
return get_mysql()->query("select * from bans where uuid = '$uuid'")->fetch_assoc();
}
function get_by_id($id) {
return get_mysql()->query("select * from bans where id = $id")->fetch_assoc();
}
function get_bans() {
return get_mysql()->query("select * from bans");
}
function login($username, $password) {
$password = hash("sha256", $password);
return get_mysql()->query("select count(*) from users where username = '$username' and password = '$password'")->fetch_assoc()["count(*)"] > 0;
}
function register($username, $password) {
$password = hash("sha256", $password);
get_mysql()->query("insert into users (username, password) values ('$username', '$password')");
}
?>
Try to add this to this..
<?php
session_start(); //Transfer the session_start() here ..
require("api/api.php");
if( isset($_POST['username']) )
{
if( login( $_POST['username'], $_POST['password'] ) )
{
$_SESSION['username'] = $_POST['username'];
}
else
{
echo 'Invalid username/password';
}
}
require("header.php");
?>

I want to pop a modal when fname already exist in DB

Form:
<form class="form-horizontal" data-toggle="validator" method="post" role="form" id="enquiryForm">
<div class="form-group">
<label class="col-lg-2 control-label">Full Name :</label>
<div class="col-lg-8">
<input type="text" name="fname" class="form-control" id="inputFirstName" data-error="Please fill out this field." placeholder="Full Name" required>
<div class="help-block with-errors"></div>
</div>
<button type="button" class="btn btn-info" id="existName">Next</button>
</div>
</form>
AJAX:
$('#existName').click(function(){
var fname = $('#inputFirstName').val();
var datas = "fname="+fname;
console.log(datas);
$.ajax({
url : "exist.php",
data : datas,
method : "POST"
}).done(function(exist){
console.log(exist);
$('#existNameModal').html(exist);
})
})
PHP:
<?php
session_start();
$companydata = $_SESSION['company'];
$idCompany = $companydata['id'];
$fnameCompany = $companydata['fname'];
$lnameCompany = $companydata['lname'];
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Latest compiled and minified CSS -->
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<?php
$dbhost = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "gym";
$conn = mysqli_connect($dbhost, $dbusername, $dbpassword, $dbname) or die ("could not connect");
if($_POST){
$existName = $_POST['fname'];
$sql = "SELECT count(fname) from enquiry where fname = '$existName' AND cmpId = '$idCompany'";
$result = mysqli_query($conn, $sql);
$row = mysqli_num_rows($result);
print_r($row);
/*exit;*/
if(($row)>0) {
$modal = '
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>';
echo $modal;
}
}
?>
</body>
</html>
Modal HTML
<!-- Name exist Modal -->
<div id="existNameModal" class="modal fade" role="dialog">
</div>
I am trying to get this Modal display when count(fname) in DB is more than 0. I tried everything but nothing worked.
From with Modal (form and modal both will be on same page)
<form class="form-horizontal" data-toggle="validator" method="post" role="form" id="enquiryForm">
<div class="form-group">
<label class="col-lg-2 control-label">Full Name :</label>
<div class="col-lg-8">
<input type="text" name="fname" class="form-control" id="inputFirstName" data-error="Please fill out this field." placeholder="Full Name" required>
<div class="help-block with-errors"></div>
</div>
<button type="button" class="btn btn-info" id="existName">Next</button>
</div>
</form>
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<div id="existNameModal"></div> //this is where message will show
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
In Ajax, you are using click function, better do it with change function on input and check the record if exist like
$('#inputFirstName').change(function(){
var fname = $(this).val();
//rest of code
});
The Ajax with click function
$('#existName').click(function(){
var fname = $('#inputFirstName').val();
var datas = "fname="+fname;
console.log(datas);
$.ajax({
url : "exist.php",
data : datas,
method : "POST"
})
});
Now to show modal and message if record exist
.done(function(exist){
console.log(exist);
if(exist.status=='error') {
$('#myModal').modal('show');
$('#existNameModal').html(exist.message);
}
});
The php exist.php
<?php
header('Content-Type: application/json');
$dbhost = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "gym";
$conn = mysqli_connect($dbhost, $dbusername, $dbpassword, $dbname) or die ("could not connect");
if($_POST['fname']){
$existName = $_POST['fname']; //escape the string
$sql = "SELECT count(fname) from enquiry where fname = '$existName' AND cmpId = '$idCompany'";
$result = mysqli_query($conn, $sql);
$row = mysqli_num_rows($result);
//print_r($row);
if(($row)>0) {
$response['status'] = "error";
$response['message'] = "<div class='alert alert-danger'>Record Already Exist</div>";
}
echo json_encode($response);
}
?>

How can i make Enter Key submit this to database?

<div class="modal-header">
<a class="modal-close-med" data-dismiss="modal" aria-hidden="true"><img src="<?php echo base_url(); ?>img/close.png"></a>
<h3 class="modal-title no-margin margin-bottom-5p-min">Change Password</h3>
</div>
<div class="modal-body">
<?php if(isset($message))echo '<span class="text-success txt-upper" style="margin-left:2rem;">'. $message .'</span>';?>
<?php echo form_open('',array('class'=>'ajaxForm')); ?>
<fieldset class="table ">
<div class="form-group">
<?php $class = form_error('newpassword')?"input-error":"" ?>
<div class="col-md-12" style="margin: 10px 0"><?php echo form_password('newpassword','','class="form-control margin-both-0 '. $class.'" id="newpassword" placeholder="New Password" autocomplete="off"'); ?><?php echo form_error('newpassword'); ?></div>
</div>
<div class="form-group">
<?php $class = form_error('conpassword')?"input-error":"" ?>
<div class="col-md-12 " style="margin: 10px 0"><?php echo form_password('conpassword','','class="form-control margin-both-0 '. $class.'" id="conpassword" placeholder="Confirm Password" autocomplete="off"'); ?><?php echo form_error('conpassword'); ?></div>
</div>
</div>
<div class="modal-footer">
<form method="post" action="" id="myform">
<?php echo form_submit('submit_btn', 'Change Password', 'class="submit btn btn-success margin-left-4p pad-1-rem margin-bottom-10"'); ?>
</form>
</fieldset>
<?php echo form_close();?>
</div>
The Controller:
public function change_password ()
{
if($this->input->post('submit_btn')){
$this->session->set_flashdata('success','Password Changed Successfully');
redirect('dashboard');
}
// Set up the form
$rules = array(
'newpassword' => array(
'field' => 'newpassword',
'label' => 'New Password',
'rules' => 'trim|required|min_length[6]|xss_clean|check_pass'
),
'conpassword' => array(
'field' => 'conpassword',
'label' => 'Confirm Password',
'rules' => 'trim|required|min_length[6]|matches[newpassword]|xss_clean|check_pass'
),
);
$this->form_validation->set_rules($rules);
$this->form_validation->set_message('required', 'this field is required');
// Process the form
if ($this->form_validation->run() == TRUE) {
$password = $this->input->post("newpassword");
$userid = $this->session->userdata("id");
if($this->user_m->change_password($password, $userid)){
$this->data['message'] = 'password changed successfully';
//$this->data['subview'] = 'home/index';
//$this->load->view('_layout_main_1', $this->data);
}else{
$this->data['message'] = 'password must have at least one uppercase letter and a number';
}
$this->data['refresh'] = true;
}
// Load view
$this->load->view('home/change_password', $this->data);
}
This currently works when i click on change password button, however i want to make it work with the enter key. This is using Codeigniter and have tried to change it using standard html input type. but it did not work. Any help would be much appreciated
Wrap around with a form and the browser will handle this. Also use a submit button type:
<?php echo form_open('',array('class'=>'ajaxForm')); ?>
<div class="modal-header">
<a class="modal-close-med" data-dismiss="modal" aria-hidden="true"><img src="<?php echo base_url(); ?>img/close.png"></a>
<h3 class="modal-title no-margin margin-bottom-5p-min">Change Password</h3>
</div>
<div class="modal-body">
<?php if(isset($message))echo '<span class="text-success txt-upper" style="margin-left:2rem;">'. $message .'</span>';?>
<fieldset class="table ">
<div class="form-group">
<?php $class = form_error('newpassword')?"input-error":"" ?>
<div class="col-md-12" style="margin: 10px 0"><?php echo form_password('newpassword','','class="form-control margin-both-0 '. $class.'" id="newpassword" placeholder="New Password" autocomplete="off"'); ?><?php echo form_error('newpassword'); ?></div>
</div>
<div class="form-group">
<?php $class = form_error('conpassword')?"input-error":"" ?>
<div class="col-md-12 " style="margin: 10px 0"><?php echo form_password('conpassword','','class="form-control margin-both-0 '. $class.'" id="conpassword" placeholder="Confirm Password" autocomplete="off"'); ?><?php echo form_error('conpassword'); ?></div>
</div>
</fieldset>
</div>
<div class="modal-footer">
<?php echo form_submit('submit_btn', 'Change Password', 'class="submit btn btn-success margin-left-4p pad-1-rem margin-bottom-10"'); ?>
</div>
<?php echo form_close();?>
If you are using this for ajax request, you can disable to send the form itself, but enter still works:
<script>
$(function() {
$('.ajaxForm').on('submit', function(e) {
// ex.: $.post(...
console.log(e);
e.preventDefault();
})
})
</script>

Categories

Resources