Data not being loaded into modal codeigniter - php

I am trying to create a modify item popup. When I click the modify item link it displays the data related to that item in the database my itemID however it does not open up in bootstrap modal. What do I need to add or change in my ajax and controller code for the data to be loaded to my modal rather than a random popup. Thanks for your help.
Controller:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Search extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->helper('url');
$this->load->helper('form');
$this->load->model('searchModel');
$this->load->model('itemModal');
}
public function displayItem(){
$id=$this->uri->segment(3);
$data1['results1'] = $this->itemModal->get_item_by_id($id);
echo json_encode($data1);
}
public function updateItem(){
$id=$this->input->post('rfid');
$data = array(
'masterCode' => $this->input->post('masterCode'),
'itemName' => $this->input->post('itemName'),
'colorName' => $this->input->post('colorName'),
'location' => $this->input->post('location'),
'itemCategory' => $this->input->post('itemCategory'),
'materialDescription' => $this->input->post('materialDescription'),
'supplier' => $this->input->post('supplier'),
'checkoutAllowed' => $this->input->post('checkoutAllowed'),
'itemDescription' => $this->input->post('itemDescription'),
'comments' => $this->input->post('comments'),
'itemCode' => $this->input->post('itemCode'),
'colorCode' => $this->input->post('colorCode'),
'locationMade' => $this->input->post('makelocation')
);
$this->searchModel->form_update($data, $id);
//load the header
$this->load->view('base.php',$data);
//load the page
redirect('execute_search');
}
}
Model:
<?php
class ItemModal extends CI_Model {
function __construct(){
parent::__construct();
}
function get_item_by_id($id){
$this->db->select('*');
$this->db->where('inventoryID =',$id);
// Execute the query.
$query = $this->db->get('inventory');
// Return the results.
return $query->result_array();
}
}
?>
View:
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="<?php echo base_url('assets/jquery/jquery-2.1.4.min.js')?>"></script>
<script src="<?php echo base_url('assets/bootstrap/js/bootstrap.min.js')?>"></script>
<script src="<?php echo base_url('assets/datatables/js/jquery.dataTables.min.js')?>"></script>
<script src="<?php echo base_url('assets/datatables/js/dataTables.bootstrap.js')?>"></script>
<script src="<?php echo base_url('assets/bootstrap-datepicker/js/bootstrap-datepicker.min.js')?>"></script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/results.css">
<title>Results</title>
<style>
table {
width: 100%;
}
th, td {
padding: 15px;
text-align: auto;
height: 50px;
border-bottom: 1px solid #ddd;
}
th {
background-color: lightgrey;
color: black;
}
tr:hover {background-color: #f5f5f5}
</style>
</head>
<body>
<h1><center>Item List</center></h1>
<hr>
<div class="container">
<form method="post" action="<?php echo site_url('itemView/viewItems'); ?>">
<table>
<tr>
<th><center><input type="radio" name="id"></center></th>
<th>Inventory ID</th>
<th>Master Code</th>
<th><center>Item Name</center></th>
<th>Color Name</th>
<th><center>Location</center></th>
<th><center>Checkout Allowed</center></th>
</tr>
<?php foreach($results as $rows):?>
<tr>
<td><a data-toggle="modal" href="<?php echo site_url('Search/displayItem/'.$rows['inventoryID']); ?>" data-target="#modifyItem">Modify Item</a></td>
<td><?php echo $rows['inventoryID'] ?></td>
<td><?php echo $rows['masterCode'] ?></td>
<td><?php echo $rows['itemName'] ?></td>
<td><?php echo $rows['colorName'] ?></td>
<td><?php echo $rows['location'] ?></td>
<td><input type="checkbox" <?php if($rows['checkoutAllowed'] == 'Yes') echo " checked='checked' "; ?>></td>
</tr>
<?php endforeach; ?>
</table>
</form>
<!-- Modify an Item Modal -->
<div id="modifyItem" class="modal fade">
<div class="modal-dialog">
<form action="<?php echo site_url("Search/updateItem"); ?>" method='POST'>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Modify an Item</h4>
</div>
<div class="modal-body">
<table>
<tr>
<td><input type="text" name="rfid" readonly/></td>
<td><input type="text" name="itemCode"/></td>
<td><input type="text" name="masterCode"/></td>
</tr>
<tr>
<td><input type="text" name="itemName"/></td>
<td><input type="text" name="colorCode"/></td>
<td><input type="text" name="colorName"/></td>
</tr>
<tr>
<td><input type="text" name="location"/></td>
<td><input type="text" name="makelocation"/></td>
<td><input type="text" name="itemCategory"/></td>
</tr>
<tr>
<td><input type="text" name="materialDescription"/></td>
<td><input type="text" name="supplier"/></td>
<td><input type="text" name="checkoutAllowed"/></td>
</tr>
</table>
<div class="row personal-info">
<div class="col-sm-4">
<div class="form-group">
<textarea name="itemDescription"></textarea>
<textarea name="Comments"></textarea>
</div>
</div>
</div>
</div>
<div class="modal-footer" style="text-align:center;">
<input type="submit" class="btn btn-primary" name="modifyItem" value="Modify Item">
</div>
</div>
</form>
</div>
</div>
<!-- Modify an Item Modal -->
</div><br><br>
</body>
<script>
function updateItem(){
$.ajax({
url: "<?php echo site_url('Search/displayItem');?>",
type: "POST",
dataType: "JSON",
success: function($data1){
$('[name="rfid"]').val($data1.inventoryID);
$('[name="masterCode"]').val($data1.masterCode);
$('[name="masterCode"]').val($data1.itemCode);
$('[name="itemName"]').val($data1.itemName);
$('[name="colorName"]').val($data1.colorCode);
$('[name="colorName"]').val($data1.colorName);
$('[name="location"]').val($data1.location);
$('[name="itemCategory"]').val($data1.itemCategory);
$('[name="materialDescription"]').val($data1.materialDescription);
$('[name="supplier"]').val($data1.supplier);
$('[name="checkoutAllowed"]').val($data1.checkoutAllowed);
$('[name="itemDescription"]').val($data1.itemDescription);
$('[name="Comments"]').val($data1.comment);
$('#modifyItem').modal('show'); // show bootstrap modal when complete loaded
},
error: function (jqXHR, textStatus, errorThrown){
alert('Error get data from ajax');
}
});
}
</script>
</html>

Best thing I can suggest you that put your modal body in another view file and while retrieving data from database using Ajax generate view and load into your modal body.

Related

how to get post data in ci

i want to print post data in my login function with $this->input->post['username'];
I have a home controller given below :
<?php
class Home extends CI_Controller{
public function index(){
$this->load->view("home/home_view");
}
public function Login(){
echo $this->input->post['username'];
}
}
?>
but its showing me null result but if i write print_r($_POST) instead of $this->input->post['username'] its showing me all data
this is my home view code
<!DOCTYPE html>
<html>
<head>
<title>Home Page</title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/bootstrap.css">
</head>
<body>
<div class="col-lg-2"></div>
<div class="col-lg-8" style="min-height: 500px;box-shadow: 5px 5px 15px #000; margin-top: 50px;">
<form method="post" action="<?php echo base_url(); ?>index.php/Home/Login">
<table class="table table-stripped">
<tr>
<th colspan="2">Login form</th>
</tr>
<tr>
<td>Username</td>
<td><input type="text" class="form-control" name="username"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" class="form-control"></td>
</tr>
<tr>
<th colspan="2"><input type="submit" value="Submit" class="btn btn-primary"></th>
</tr>
</table>
</form>
</div>
<div class="col-lg-2"></div>
</body>
</html>
i had auto loaded form helper and url helper
Hope this will help you :
Use $this->input->post('username'); instead of $this->input->post['username'] :
Your Login function should be like this :
public function Login()
{
/* to print all field name do like this*/
print_r($this->input->post());
/* to print a particular field name do like this*/
echo $this->input->post('username');
echo $this->input->post('password');
}
Use site_url or base_url in form like this ( good practice) :
<form method="post" action="<?php echo site_url('Home/Login'); ?>">
........
</form>
for more : https://www.codeigniter.com/user_guide/libraries/input.html
Convert your HTML from into CI form helper way although i have updated your view file for your reference see form helper [https://www.codeigniter.com/userguide3/helpers/form_helper.html][1]
<!DOCTYPE html>
<html>
<head>
<title>Home Page</title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/bootstrap.css">
</head>
<body>
<div class="col-lg-2"></div>
<div class="col-lg-8" style="min-height: 500px;box-shadow: 5px 5px 15px #000; margin-top: 50px;">
<?php
echo form_open('home/login');
?>
<table class="table table-stripped">
<tr>
<th colspan="2">Login form</th>
</tr>
<tr>
<td>Username</td>
<td>
<?php
$data = array(
'name' => 'username',
'id' => 'username'
);
echo form_input($data);
?>
<input type="text" class="form-control" name="username">
</td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" class="form-control">
<?php
$pwd = array(
'name' => 'password',
'id' => 'password'
);
echo form_password($pwd);
?>
</td>
</tr>
<tr>
<?php echo form_submit('submit', 'Submit'); ?>
</th>
</tr>
</table>
<?php echo form_close();?>
</div>
<div class="col-lg-2"></div>
</body>
</html>

Get class element

I make Jquery to read data from db and when I click the list it shown roe data on detail box.
But.... problem: I make div where I show content. I load page with Jquery to div.
but when I do this the row click dont work. I can not understan why. It is shild element but id i understan right when I use getElementById it should to take current row, but no.
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<?php include './config/init.php'; ?>
<html>
<head>
<meta charset="UTF-8">
<title>Biisilista</title>
<script src="./js/jquery-3.2.1.js"></script>
<link href="css/basic.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>KaraokeBiisit </h1>
<div id="edit" style="display:none">
<div>
<form name="formedit" method="post" action="">
<table id="edittable" border="1" cellspacing="2" cellpadding="1">
<tbody>
<tr>
<td>
<label>Nimi:</label>
</td>
<td>
<input id="nimi" name="nimi" placeholder="Kappaleen nimi" type="text">
</td>
<td>
<label>Levy:</label>
</td>
<td>
<input id="levy" name="levy" placeholder="Levyn tunnus" type="text" width="10px">
</td>
</tr>
<tr>
<td>
<label>Artisti:</label>
</td>
<td>
<input id="artisti" name="artisti" placeholder="Kappaleen esittäjä" type="text">
</td>
<td>
<label>Kieli:</label>
</td>
<td>
<input id="kieli" name="kieli" placeholder="Alkuperäiskieli" type="text" width="20">
</td>
</tr>
<tr>
<td>
<label>Numero:</label>
</td>
<td>
<input id="numero" name="numeron" placeholder="Numero" type="text">
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
<div id="pageContent">
</div>
<script src="./js/jquery-3.2.1.js"></script>
<script src="./js/script.js"></script>
</body>
</html>
jQuery(document).ready(function ($) {
$("#pageContent").click(function () {
$('tr').removeClass('selected');
$(this).addClass('selected');
var selectedRow;
selectedRow = $(rivi);
var td = $(selectedRow).children('td');
$('#nimi').val(td[0].innerText);
$('#artisti').val(td[1].innerText);
$('#levy').val(td[2].innerText);
$('#kieli').val(td[3].innerText);
$('#numero').val(td[4].innerText);
console.log("test");
});
$(".clickable-row").on('click', () => {
$('#edit').show();
});
$('#pageContent').load('container.php');
// $('#pageContent').load('biisit.php');
});
function showBiisit() {
console.log("Näytetään sisältö");
$('#pageContent').load('container.php');
}
<?php include './config/init.php'; ?>
<?php
//luodaan tietokantaobjekti
$db = new DataBase();
// tehdään kysely
$db->query("SELECT * FROM kappaleet");
//query("SELECT `id`,`nimi`,`artisti`,`levy`,`kieli`,`numero` FROM `kappaleet`;");
//yhdistetään hakutulokseen
$kappaleet = $db->resultset();
?>
<table id="dataTable">
<tr>
<th>Nimi</th>
<th>Artisti</th>
<th width="100" align="left">Levy</th>
<th width="100" align="left">Kieli</th>
<th width="100" align="left">Numero</th>
</tr>
<?php foreach ($kappaleet as $biisi): ?>
<tr class='clickable-row' >
<td><?php echo $biisi->nimi ?></td>
<td><?php echo $biisi->artisti ?></td>
<td><?php echo $biisi->levy ?></td>
<td><?php echo $biisi->kieli ?></td>
<td><?php echo $biisi->numero ?></td>
</tr>
<?php endforeach; ?>
</table>
try this
...
$("body").on('click', '.clickable-row', function () { //i change this line
$('tr').removeClass('selected');
$(this).addClass('selected');
var selectedRow = $(this);
//selectedRow = $(rivi); idk what is this
var td = selectedRow.children('td');
$('#nimi').val(td[0].innerText);
$('#artisti').val(td[1].innerText);
$('#levy').val(td[2].innerText);
$('#kieli').val(td[3].innerText);
$('#numero').val(td[4].innerText);
console.log("test");
});
...

Retrieve multiple data from 2 tables with php and jquery

This code is retrieving multiple data from 1 table only.
How can I retrieve multiple data from 2 tables and save them to another table?
Result that I want to achieve:
Here are the tables
request:
prNo branch
pr03 odessa
pr04 kiev
detail_request:
prNo productCode productName qty
pr03 111 soap 1200
pr03 112 tooth paste 1000
I want to save data on detail_request table to purchase table, but only the data that have check mark on the checkbox, and I'm adding price column to be fill manually.
purchase:
prNo productCode productName qty price
- - - - -
Here is the code:
<html>
<head>
<title>Lookup Modal Bootstrap 3</title>
<link rel="stylesheet" href="bootstrap/css/bootstrap.css"/>
<link rel="stylesheet" href="datatables/dataTables.bootstrap.css"/>
<style>
body{
margin: 15px;
}
.pick:hover{
cursor: pointer;
}
</style>
</head>
<body>
<div class="row">
<div class="col-md-5">
<h2> </h2>
</div>
</div>
<form action="action" onsubmit="dummy();
return false">
<div class="form-group">
<label for="varchar">Request Number</label>
<div class="row">
<div class="col-md-4">
<input type="text" class="form-control" name="prNo" id="prNo" placeholder="Request Number" readonly />
<strong>Branch Name</strong><br>
<input type="text" class="form-control" name="branch" id="branch" placeholder="branch " readonly />
</div>
<div class="col-md-2">
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal">. . .</button>
</div>
</div>
</div>
<table width="446" border="1">
<tr>
<th scope="row"> </th>
<th scope="row">Request Number</th>
<td><strong>Product Code</strong></td>
<td><strong>Product Name</strong></td>
<td><strong>QTY</strong></td>
<td><strong>Price</strong></td>
</tr>
<tr>
<th scope="row"><input type="checkbox" name="prNo" id="prNo"></th>
<th scope="row"><label for="Request Number"></label>
<input type="text" name="prNo" id="prNo"></th>
<td><label for="productCode"></label>
<input type="text" name="productCode" id="productCode"></td>
<td><label for="productName"></label>
<input type="text" name="productName" id="productName"></td>
<td><label for="qty"></label>
<input type="text" name="qty" id="qty"></td>
<td><input type="text" name="price" id="price"></td>
</tr>
<tr>
<th scope="row"><input type="checkbox" name="prNo4" id="prNo4"></th>
<th scope="row"><input type="text" name="prNo2" id="prNo2"></th>
<td><input type="text" name="productCode2" id="productCode2"></td>
<td><input type="text" name="productName2" id="productName2"></td>
<td><input type="text" name="qty2" id="qty2"></td>
<td><input type="text" name="price2" id="price2"></td>
</tr>
</table>
<input type="submit" value="Save" class="btn btn-primary" />
</form>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" style="width:800px">
<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" id="myModalLabel">Lookup </h4>
</div>
<div class="modal-body">
<table id="lookup" class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Request Number</th>
<th>Branch Name</th>
</tr>
</thead>
<tbody>
<?php
$con = mysqli_connect('localhost', 'root', '', 'purchase');
$sql = mysqli_query($con,'select * from request ');
while ($r = mysqli_fetch_array($sql)) {
?>
<tr class="pick" no="<?php echo $r['prNo']; ?>", branch="<?php echo $r['branch'] ?>", code="<?php echo $r['productCode'] ?>">
<td><?php echo $r['prNo']; ?></td>
<td><?php echo $r['branch']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script src="js/jquery-1.11.2.min.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
<script src="datatables/jquery.dataTables.js"></script>
<script src="datatables/dataTables.bootstrap.js"></script>
<script type="text/javascript">
$(document).on('click', '.pick', function (e) {
document.getElementById("prNo").value = $(this).attr('no');
document.getElementById("branch").value = $(this).attr('branch');
$('#myModal').modal('hide');
});
$(function () {
$("#lookup").dataTable();
});
</script>
</body>
</html>
<?php
if(isset($_POST['product_submit']))
{
$check=$_POST['check'];
foreach($check as $i)
{
$prno=$_POST['prNo'.$i];
$prcode=$_POST['productCode'.$i];
$prname=$_POST['productName'.$i];
$qty=$_POST['qty'.$i];
$price=$_POST['price'.$i];
$query = mysqli_query($con,"insert into purchase (prNo,productCode,productName,qty,price) value ('$prno', '$prcode', '$prname', '$qty', '$price')");
}
if($query)
{
?>
<script>
alert("success");
</script>
<?php
}
}
?>
<html>
<head>
<title>Lookup Modal Bootstrap 3</title>
</head>
<body>
<div class="row">
<div class="col-md-5">
<h2> </h2>
</div>
</div>
<form method="post" id="my_form">
<div class="form-group">
<label for="varchar">Request Number</label>
<div class="row">
<div class="col-md-4">
<input type="text" class="form-control" name="prNo" id="prNo" placeholder="Request Number" readonly />
<strong>Branch Name</strong><br>
<input type="text" class="form-control" name="branch" id="branch" placeholder="branch " readonly />
</div>
<div class="col-md-2">
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal">. . .</button>
<button type="button" class="btn btn-default" onclick="show_fun()">View</button>
</div>
</div>
</div>
<table width="446" border="1">
<thead>
<tr>
<th scope="row"> </th>
<th scope="row">Request Number</th>
<td><strong>Product Code</strong></td>
<td><strong>Product Name</strong></td>
<td><strong>QTY</strong></td>
<td><strong>Price</strong></td>
<td><strong>Total</strong></td>
</tr>
</thead>
<tbody id="product_table">
</tbody>
</table>
<input type="submit" value="Save" name="product_submit" class="btn btn-primary" />
</form>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" style="width:800px">
<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" id="myModalLabel">Lookup </h4>
</div>
<div class="modal-body">
<table id="lookup" class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Request Number</th>
<th>Branch Name</th>
</tr>
</thead>
<tbody>
<?php
$con = mysqli_connect('localhost', 'root', '', 'purchase');
$sql = mysqli_query($con,'select * from request ');
while ($r = mysqli_fetch_array($sql)) {
?>
<tr class="pick" no="<?php echo $r['prNo']; ?>", branch="<?php echo $r['branch'] ?>", code="<?php echo $r['productCode'] ?>">
<td><?php echo $r['prNo']; ?></td>
<td><?php echo $r['branch']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script src="js/jquery-1.11.2.min.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
<script src="datatables/jquery.dataTables.js"></script>
<script src="datatables/dataTables.bootstrap.js"></script>
<script type="text/javascript">
$(document).on('click', '.pick', function (e) {
document.getElementById("prNo").value = $(this).attr('no');
document.getElementById("branch").value = $(this).attr('branch');
var no=$(this).attr('no');
$.ajax({
type:"post",
data:"&product_id=1&prno="+no,
url:"ajax.php",
success:function(result)
{
$("#product_table").html(result);
}
});
$('#myModal').modal('hide');
});
$(function () {
$("#lookup").dataTable();
});
function calc_fun(i){
var qty=$("#qty"+i).val();
var price=$("#price"+i).val();
var total=Number(qty)*Number(price);
$("#total"+i).val(total);
}
</script>
</body>
</html>
ajax.php
<?php
if(isset($_POST['product_id']))
{
$prno=$_POST['prno'];
$i=1;
$sql = mysqli_query($con,"select * from detail_request where prNo='$prno'");
while ($r = mysqli_fetch_array($sql)) {
echo '<tr>
<th scope="row"><input type="checkbox" name="check[]" id="check'.$i.'" value="'.$i.'"></th>
<th scope="row"><label for="Request Number"></label>
<input type="text" name="prNo'.$i.'" id="prNo'.$i.'" readonly value="'.$r["prNo"].'"></th>
<td><label for="productCode"></label>
<input type="text" name="productCode'.$i.'" id="productCode'.$i.'" readonly value="'.$r["productCode"].'"></td>
<td><label for="productName"></label>
<input type="text" name="productName'.$i.'" id="productName'.$i.'" readonly value="'.$r["productName"].'"></td>
<td><label for="qty"></label>
<input type="text" name="qty'.$i.'" id="qty'.$i.'" onchange="calc_fun('.$i.')" readonly value="'.$r["qty"].'"></td>
<td><input type="text" name="price'.$i.'" onchange="calc_fun('.$i.')" id="price'.$i.'"></td>
<td><input type="text" name="total'.$i.'" id="total'.$i.'"></td>
</tr>';
$i++;
}
}
?>

how to add jquery confirmation popup in codeigniter

im developing a project my own and i use codeigniter as my framework, i'm pretty begginer to php and codeignier. i created a confirm box in jquery ,but it's and html alert. so how to do that? don't laugh at me guys. thanks.
view
<?php
$_instance = get_instance();
$attributes = array('id' => 'main_form');
?>
<?php echo form_open('registration/reset',$attributes);?>
<style>
span{
color: red;
}
#main_tb{
margin-top:100px;
}
</style>
<table cellspacing='10' id>
</table>
<div id='main_form'>
<form id="main_form" name="form">
<table CELLSPACING=2 CELLSPACING=10 id='main_tb' >
<tr>
<td></td>
<td id="error"></td>
</tr>
<tr>
<td>User Name</td>
<td> <select class="cmb" style="width: 200px;" id="cmb_user" name="cmb_user"> </select></td>
</tr>
<tr>
<td></td>
<td><?php echo $this->session->flashdata('reset_error'); ?></td>
</tr>
<tr>
<td></td>
<td> <input type="submit" id="save" value="reset password"/></td>
</tr>
</table>
</form>
</div>
<?php echo form_close();?>
script
$j('#main_form').submit(function() {
// event.preventDefault();
var status = confirm("Are you sure? This cannot be undone");
if(status == false){
return false;
}
else{
return true;
}
});
controller
function reset(){
$password =$_POST['cmb_user'];
echo $username = $this->input->post('cmb_user');
$data_array = array(
'id_user' => $this->input->post('cmb_user'),
);
// // echo 'sdsd';
// echo $_POST['cmb_user'];
//
$this->load->model('registration/registration_model');
$this->registration_model->reset_pass($data_array);
$this->session->set_flashdata('reset_error', ' <br><span style="font-size: 10px;background-color: #FFFFFF;color:#ff0000;border:solid 1px #ff99cc;padding:2px;border-radius: 5px 5px 5px 5px">Reset Successfull</span>');
redirect('/registration/admin_reset');
}
this function works great. but i want to add jquery fancy popup like sweet alert. thank's again..
Add the following code into your view
<script src="https://cdn.rawgit.com/t4t5/sweetalert/master/dist/sweetalert.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/t4t5/sweetalert/master/dist/sweetalert.css">
<script language="javascript">
sweetAlert("Oops...", "Something went wrong!", "error");
</script>

ReCaptcha doesn't show up on Facebox

<?php
session_start();
require_once('recaptcha/recaptchalib.php');
$publickey = "API_KEY"; // you got this from the signup page
?>
<script type="text/javascript" src="javascripts/jquery.form.js"></
script>
<script type="text/javascript">
$(document).ready(function() {
$('#inquiry').ajaxForm({
target: '#error',
success: function() {
$('#error').fadeIn('slow');
}
});
});
var RecaptchaOptions = {
theme : 'clean'
};
</script>
<div class="top_area">Inquiry Form</div>
<div id="search_area">
</div>
<div style="overflow-y: hidden;">
<form name="inquiry" id="inquiry" action="asadadasd.php"
method="post">
<div id="error"></div>
<table align="center">
<tr>
<td valign="top" align="right"></td>
<td>
<?php
echo recaptcha_get_html($publickey);
?>
</td>
</tr>
<tr>
<td valign="top"></td>
<td>
<input type="submit" id="submit" name="submit" value="Submit"
style="height: 30px; background: #ab2220; border: 2px #fff solid;
color: #fff;" />
</td>
</tr>
</table>
</form>
</table>
</form>
</div>
That's the code I have as of now but recaptcha plugin doesn't show up
am I missing something?
Thanks guys,
You are so awesome
You have to use the recaptcha AJAX API on facebox. Include the AJAX script in your page (Not the page facebox will display. Put it in the containing page) Then use the recaptcha api as specified in the docs.
http://code.google.com/apis/recaptcha/docs/display.html#AJAX

Categories