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>
Related
i'm trying to update my records which are stored in the database, but unfortunately i'm getting errors like (given below) this please can any one help me in this it would be help full for me
A PHP Error was encountered
Severity: Notice
Message: Undefined property: stdClass::$id
Filename: views/display_about_us1.php
Line Number: 44
Backtrace:
File: C:\xampp\htdocs\CodeIgniter_try\application\views\display_about_us1.php
Line: 44
Function: _error_handler
File: C:\xampp\htdocs\CodeIgniter_try\application\controllers\Home.php
Line: 107
Function: view
File: C:\xampp\htdocs\CodeIgniter_try\index.php
Line: 315
Function: require_once
Controller
public function updatedata()
{
$id=$this->input->get('id');
$result['data']=$this->Contact_model->displayrecordsById($id);
$this->load->view('update_about_us1',$result);
if($this->input->post('update'))
{
// Basic validation
$this->form_validation->set_rules('first_content', 'First content', 'required');
$this->form_validation->set_rules('second_content', 'Second content', 'required');
$this->form_validation->set_rules('third_content', 'Third content', 'required');
$this->form_validation->set_rules('fourth_content', 'Fourth content', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('update_about_us1');
}
else
{
$id = $this->input->post('id');
$data = array();
$data['first_content']=$this->input->post('first_content');
$data['second_content']=$this->input->post('second_content');
$data['third_content']=$this->input->post('third_content');
$data['fourth_content']=$this->input->post('fourth_content');
$this->Contact_model->updaterecords($id, $data);
redirect("Home/About_us_display");
}
}
}
Model
function displayrecordsById($id)
{
$query=$this->db->query("select * from about_us1 where id='".$id."'");
return $query->result();
}
function updaterecords($id,$data)
{
$this->db->where('id', $id);
$this->db->update('about_us1', $data);
}
View
<!DOCTYPE html>
<html>
<head>
<title>About_us1 page</title>
</head>
<body>
<?php
$i=1;
foreach($data as $row)
{
?>
<form action="Home/updatedata" method="get">
<table width="600" border="1" cellspacing="5" cellpadding="5">
<tr>
<td width="230">First content </td>
<td width="329"><textarea rows="4" cols="50" name="first_content" value="<?php echo $row->first_content; ?>"/></textarea></td>
<span><?php echo form_error("first_content");?></span>
</tr>
<tr>
<td>Second content </td>
<td><textarea rows="4" cols="50" name="second_content" value="<?php echo $row->second_content; ?>"/></textarea></td>
<span><?php echo form_error("second_content");?></span>
</tr>
<tr>
<td>Third content </td>
<td><textarea rows="4" cols="50" name="third_content" value="<?php echo $row->third_content; ?>"/></textarea></td>
<span><?php echo form_error("third_content");?></span>
</tr>
<tr>
<td>Fourth content </td>
<td><textarea rows="4" cols="50" name="fourth_content" value="<?php echo $row->fourth_content; ?>"/></textarea></td>
<span><?php echo form_error("fourth_content");?></span>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="update" value="Update Records"/></td>
</tr>
</table>
</form>
<?php } ?>
</body>
</html>
// display record view page
<!DOCTYPE html>
<html lang="en">
<head>
<title>display</title>
<meta charset="utf-8">
<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.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<br><br>
<div class="container">
<div class="panel panel-primary">
<div class="panel-heading text-center">Contact Us Details</div>
</div>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>First Content</th>
<th>Second Content</th>
<th>Third Content</th>
<th>Fourth Content</th>
<th>Update Content</th>
</tr>
</thead>
<tbody>
<tr>
<?php
$i=1;
foreach($data as $row)
{
echo "<tr>";
echo "<td>".$i."</td>";
echo "<td>".$row->first_content."</td>";
echo "<td>".$row->second_content."</td>";
echo "<td>".$row->third_content."</td>";
echo "<td>".$row->fourth_content."</td>";
echo "<td><a href='updatedata?id=".$row->id."'>Update</a></td>";
echo "</tr>";
$i++;
}
?>
</tr>
</tbody>
</table>
</div><br><br>
<button type="button" class="btn btn-success">Back</button>
</div>
</body>
</html>
Hope this will help you :
Arguments mismatch with updaterecords method in controller with model
Should be like this :
Call updaterecords method in your controller like this :
$this->Contact_model->updaterecords($id, $data);
Your model method should be like this :
function updaterecords($id,$data,)
{
$this->db->where('id', $id);
$this->db->update('about_us1', $data);
}
UPDATE :
your controller code should be like this :
if($this->input->post('update'))
{
$data = array();
$id = $this->input->post('id');
$data['first_content']=$this->input->post('first_content');
$data['second_content']=$this->input->post('second_content');
$data['third_content']=$this->input->post('third_content');
$data['fourth_content']=$this->input->post('fourth_content');
$this->Contact_model->updaterecords($id, $data);
redirect("Home/About_us_display");
}
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.
I have the following view to List all products, and in that you can delete or edit a particular product, onclick of delete or edit it will call the controller,
<?php
$this->load->helper('url');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>diluks eCommerce - Home</title>
<link href="<?php
echo base_url();
?>Public/scripts/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form action="<?php echo base_url();?>index.php/productlist_controller" method="post">
<div class="container">
<?php
include 'header-adminpanel.php';
?>
<div class="level3 clearfix">
<?php
include 'product-sidebar.php';
?>
<div class="body-content">
<div class="items">
<h2>Product List</h2>
<table class="CSSTable" cellspacing="0px" cellpadding="0px">
<tr>
<td>Item Code</td><td>Item Name</td><td>Item Price</td><td>Edit</td><td>Delete</td>
</tr>
<?php foreach($products as $row): ?>
<form method="POST" action="<?php echo base_url();?>index.php/productlist_controller">
<tr>
<td><?php echo $row->itemcode; ?></td><td><?php echo $row->itemname; ?></td><td>$<?php echo $row->itemprice; ?></td><td><center><button name="btn_edit" class="link-button" value="<?php echo $row->itemcode; ?>" type="submit">Edit</button></center></td><td><center><button name="btn_delete" class="link-button" value="<?php echo $row->itemcode; ?>" type="submit">Delete</button></center></td>
</tr>
</form>
<?php endforeach ?>
</table>
</div>
</div>
</div>
<div style="clear:both"></div>
<div class="level4">
<div class="footer-area">
<div class="lined-space"></div>
<div class="site-map" align="left">
<table>
<tr>
<td class="footer-text">About Us</td>
<td class="footer-text">Facebook</td>
</tr>
<tr>
<td class="footer-text">Contact Us</td>
<td class="footer-text">Twitter</td>
</tr>
<tr>
<td class="footer-text">FAQs</td>
<td class="footer-text">Terms & Conditions</td>
</tr>
<tr>
<td class="footer-text">Help</td>
</tr>
</table>
</div>
<div class="developer-info">
<a class="developers-text">Designed & Developed By Diluks Software Solutions.</a>
</div>
</div>
</div>
</div>
</form>
</body>
</html>
So the controller to the above view look like belo
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Productlist_controller extends CI_Controller {
function __construct(){
parent::__construct();
}
public function index()
{
if(isset($_POST["btn_delete"])){
$pid = $_POST["btn_delete"];
$this->load->model('product_model');
$result = $this->product_model->deleteProduct($pid);
if($result==true){
$data = array();
$this->load->model('product_model');
$data['products'] = $this->product_model->availableProductList();
$this->load->view('admin_product_list_view',$data);
}
else{
echo "Oops! Error occured..!";
}
}
else if(isset($_POST["btn_edit"])){
$pid = $_POST["btn_edit"];
$data = array();
$this->load->model('product_model');
$data['product'] = $this->product_model->readProduct($pid);
//$this->load->model('category_model');
//$data['categories'] = $this->category_model->getCategories();
$this->load->view('admin_product_edit_view', $data);
}
}
}
"admin_product_edit_view" which the user will be redirected onclick of edit for an particular item is as follows,
<?php
$this->load->helper('url');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>diluks eCommerce - Home</title>
<link href="<?php
echo base_url();
?>Public/scripts/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form enctype="multipart/form-data" action="<?php
echo base_url();
?>index.php/addproduct_controller" method="post">
<div class="container">
<?php
include 'header-adminpanel.php';
?>
<div class="level3 clearfix">
<?php
include 'product-sidebar.php';
?>
<div class="body-content">
<div class="items">
<h2>Edit Product</h2>
<?php foreach($product as $row){ ?>
<table>
<tr>
<td class="captions">Product Code</td>
<td><input name="txt_pcode" type="text" readonly="true" value="<?php echo $row->itemcode; ?>"/></td>
</tr>
<tr>
<td class="captions">Product Name</td>
<td><input name="txt_pname" type="text" size="40" value="<?php echo $row->itemname; ?>" /></td>
</tr>
<tr>
<td class="captions">Product Price</td>
<td><input name="txt_pprice" type="text" value="<?php echo $row->itemprice; ?>" /></td>
</tr>
<tr>
<td class="captions">Product Category</td>
<td><select name="txt_pcategory">
<?php
foreach($categories as $row)
{
echo '<option value="'.$row->catname.'">'.$row->catname.'</option>';
}
?>
</select></td>
</tr>
<tr>
<td class="captions">Product Description</td>
<td><textarea name="txt_pdesc" style="width:300px;height:100px;"><?php echo $row->itemdesc; ?></textarea></td>
</tr>
<tr>
<td class="captions">Product Image</td>
<td><input type="file" name="userfile" size="20" /></td>
</tr>
<tr>
<td class="captions">Product Options</td>
<td><input name="txt_poptions" size="40" type="text" /><a class="hint"> (Separate by a "," comma)</a></td>
</tr>
<tr><td><input name="btn_add" class="grey-button" type="submit" value="Update" /></td></tr>
</table>
<?php } ?>
<br />
</div>
</div>
</div>
<div style="clear:both"></div>
<div class="level4">
<div class="footer-area">
<div class="lined-space"></div>
<div class="site-map" align="left">
<table>
<tr>
<td class="footer-text">About Us</td>
<td class="footer-text">Facebook</td>
</tr>
<tr>
<td class="footer-text">Contact Us</td>
<td class="footer-text">Twitter</td>
</tr>
<tr>
<td class="footer-text">FAQs</td>
<td class="footer-text">Terms & Conditions</td>
</tr>
<tr>
<td class="footer-text">Help</td>
</tr>
</table>
</div>
<div class="developer-info">
<a class="developers-text">Designed & Developed By Diluks Software Solutions.</a>
</div>
</div>
</div>
</div>
</form>
</body>
</html>
Now the problem is in the controller i need to load up categories (which I have commented) in order to show them in the edit view, but when I un-commented it, categories are loading, but Gives an Error in Item Description textarea saying
Message: Undefined property: stdClass::$itemdesc
With the category model loading line commented, it works fine except no categories will load up in the dropdownlist,Please someone suggest me a way to get rid of this.
Please use this in your view
if(isset($row->itemdesc)) echo $row->itemdesc;
I think this will solve your problem
I saw that you got an answer but i have a few suggestions for your code:
1. in your controller you load the model 3 times: you should load it once; you could do something like this:
if(!empty($_POST)){
$this->load->model('product_model');
if(isset($_POST["btn_delete"])){
//some code
}elseif(isset($_POST["btn_edit"])){
//some other code
}
}
2. in your views you load a helper: this should be loaded into the controller, right after the first verification from point 1.
3. in views you should check your variable for content, especially the ones that you are going to use in a loop, like $products
Hi I have the following code and the browser is commenting out the php. The file is saved .php however nothing helps. I've searched this forum and nothing works.
<html>
<head>
<!--<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>-->
<title>
Golden Acres
</title>
<link href="css/mystyle.css" rel="stylesheet" type="text/css"/>
</head>
<body class="center">
<table class="main_tables">
<tr>
<td rowspan="2" >
<img class="main_logo" src="images/logo2.gif" alt="logo"/>
</td>
<td id="main_nav_menu" valign="bottom">
<table cellspacing="2" >
<tr>
<td id="slogan_home" colspan="6" valign="middle">
"delivering fresh close to your home"
</td>
</tr>
<tr id="extra_row"><td></td></tr>
<tr>
<td class="main_nav_menu" align="center">
<a class="main_nav_menu_links" href="index.html">home</a>
</td>
<td class="main_nav_menu">
<a class="main_nav_menu_links" href="about_us.html">about us</a>
</td>
<td class="main_nav_menu" >
<a class="main_nav_menu_links" href="boxes.html">boxes</a>
</td>
<td class="main_nav_menu">
<a class="main_nav_menu_links" href="shop.html">Shop</a>
</td>
<td class="main_nav_menu">
<a class="main_nav_menu_links" href="events.html">events</a>
</td>
<td class="main_nav_menu">
<a class="main_nav_menu_links" href="contact.html">Contact Us</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
if(isset($_POST['submit'])){
$submit = $_POST['submit'];
if(isset($_POST['register_fname'])&&($_POST['register_lname'])&&($_POST['register_uname'])&&($_POST['register_password'])){
$firstname = $_POST['register_fname'];
$lastname = $_POST['register_lname'];
$username = $_POST['register_uname'];
$password = $_POST['register_password'];
if(isset($firstname)&&isset($lastname)&&isset($username)&&isset($password)){
echo 'Isset is ok';
}
else
{
echo 'Isset is not ok';
}
}
}
?>
<form action="register.php" method="POST">
<input type="submit" name="submit">
</form>
</body>
</html>
The when I inspect element in the browser it's displayed as : <!-- php .... ?-->
Help would be appreciated.
add at the begins of the page before Html and even DOCTYPE declaration tag :
<?php include "register.php"; ?>
<!DOCTYPE html>
<html lang="en">
and move your code to this file < register.php >
then use the form like this:
<form id="" name="" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>" role="form">
<input type="submit" name="submit" value="Send" >
</form>
i hope this will help
Sorry this was a silly mistake of mine.
i have a table named as item_request and it has twofields named as projectmanager and createddate which has the Timestamp format as 2012-09-11 17:46:25.
Now i want to call these two fields in another form which count the user entry between 2 different dates.and the date field is fetched from the timestamp.with this form i m sending the value through datetime picker having the format 10-12-2012 but the value in databse is in different format and the value i m sending is in diffferent format.how is it possible plzzz help me guys.
Here is the code for my form:
<?php
include("config.php");
ob_start();
error_reporting(0);
if(!isset($_SESSION[username]))
header("location: index.php");
if(isset($_POST[submit]))
{
$projectmanager=mysql_real_escape_string($_POST['projectmanager']);
$date=mysql_real_escape_string($_POST['date']);
$dateexp = explode("-",$date);
$date = mysql_real_escape_string($dateexp[0]."/".$dateexp[1]."/".$dateexp[2]);
$date1=mysql_real_escape_string($_POST['date1']);
$dateexp1 = explode("-",$date1);
$date1 = mysql_real_escape_string($dateexp1[0]."/".$dateexp1[1]."/".$dateexp1[2]);
echo $queryuser= "select * from item_request where projectmanager=$projectmanager AND (requireddate>=$date AND requireddate<=$date1)";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Project Managers Registrarion</title>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<script language="javascript" type="text/javascript" src="js/datetimepicker.js">
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
//For this script, visit http://www.javascriptkit.com
</script>
</head>
<body>
<div class="container">
<div class="header"><img src="images/cherry-new.jpg" width="79" height="93" />
<!-- end .header --></div>
<?php include("rightMenu.php");?>
<div class="content">
<h1>PR Count</h1>
<div style="padding:10px 0px; text-align:center; color:#990000;">
</div>
<form action="" method="post" name="loginform">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td>Project Managers</td>
<td><select name="projectmanager" style="width:145px;" id="projectmanager" onChange="showUser(this.options[this.selectedIndex].id)">
<option value="">Select</option>
<?php $queryuser= "select * from projectmanagers";
$fetuser1user = mysql_query($queryuser);
while($fetuser = mysql_fetch_array($fetuser1user)){
?>
<option id="<?php echo $fetuser['id']?>" value="<?php echo $fetuser['id']?>"><?php echo $fetuser['projectmanager']?></option>
<?php }
?>
</select></td>
</tr>
<tr>
<td>Date From</td>
<td>
<input id="date" type="text" size="20" name="date" /><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></td>
</tr>
<tr>
<td>Date To</td>
<td>
<input id="date1" type="text" size="20" name="date1"><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="submit" id="submit" value="Submit" onClick="return formvalidate();"/>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
<table width="100%" border="1"><tr>
<td width="18%" valign="middle" class="tableheading">PI.No.</td>
<td width="18%" valign="middle" class="tableheading">Project Manager</td>
<td width="18%" valign="middle" class="tableheading">Date Created</td>
<td width="15%" valign="middle" class="tableheading">Action</td>
</tr>
<?php
// to print the records
$select = "select * from item_request";
$query1 = mysql_query($select);
while($value = mysql_fetch_array($query1)){ ?>
<tr>
<td class="tabletext"><?php echo $value[id];?></td>
<td class="tabletext"><?php echo $value[projectmanager];?></td>
<td class="tabletext"><?php echo $value[datefrom];?></td>
<td class="tabletext"><img src="images/edit.png" width="25" height="25" border="0" title="Edit" />
<img src="images/deleteBtn.png" width="25" height="25" border="0" title="Edit" /></td>
</tr><?php }?>
</table>
</form>
<!-- end .content --></div>
<?php include("footer.php");?>
<!-- end .container --></div>
</body>
</html>
Replace this function call...
javascript:NewCal('date','ddmmyyyy');
with this one...
javascript:NewCal('date','ddmmyyyy',true,24);
Hope it helps.