Update Database tables with values input by user in CodeIgniter using PHP - php

I'm trying to update one of my user tables in the Database with values taken from the the user. But for some reason it's not updating anything.
HTML Form
<form class="form-horizontal" method = "post">
<fieldset>
<!-- Form Name -->
<legend>User Details</legend>
<div>
<?php echo $this->session->flashdata('msg'); ?>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="name">Full Name</label>
<div class="col-md-8">
<input id="name" name="name" type="text" placeholder="something" class="form-control input-md">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="dob">Date of Birth</label>
<div class="col-md-4">
<input id="dob" name="dob" type="text" placeholder="" class="form-control input-md">
</div>
</div>
<!-- Multiple Radios -->
<div class="form-group">
<label class="col-md-4 control-label" for="gender">Gender</label>
<div class="col-md-2">
<select id="gender" name="gender" class="form-control">
<option value="1">Male</option>
<option value="2">Female</option>
</select>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="degree">Degree</label>
<div class="col-md-8">
<input id="degree" name="degree" type="text" placeholder="degree" class="form-control input-md">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="specialization">Specialization</label>
<div class="col-md-8">
<input id="specialization" name="specialization" type="text" placeholder="specialization" class="form-control input-md">
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="year">Degree Year</label>
<div class="col-md-2">
<select id="year" name="year" class="form-control">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="semester">Semester</label>
<div class="col-md-2">
<select id="semester" name="semester" class="form-control">
<option value="1">1</option>
<option value="2">2</option>
</select>
</div>
</div>
<!-- File Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="filebutton">Upload Profile Picture</label>
<div class="col-md-4">
<input id="filebutton" name="filebutton" class="input-file" type="file">
</div>
</div>
<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="submit"></label>
<div class="col-md-4">
<a href="<?php echo base_url("/index.php/studentDashboardController/saveUserDetails"); ?>" >
<button id="submit" name="submit" class="btn btn-primary">Save Changes</button>
</a>
</div>
</div>
</fieldset>
studentDashboardController
public function saveUserDetails()
{
$this->load->model('userModel');
if (isset($this->session->userdata['logged_in']))
{
$username = ($this->session->userdata['logged_in']['username']);
}
$user = $this-> userModel-> getUserUid($username); //Gets the uid of the current user
$this->userModel->saveUserDetails($user);
$this->session->set_flashdata('msg', '<div class="alert alert-success text-center">Successfully Inserted Data</div>');
$this->load->view('studentDashboard/common',$data);
redirect(base_url('index.php/studentDashboard/editProfile',$data1));
}
userModel
public function saveUserDetails($uid)
{
$data = array(
'name' => $this->input->post('name')
);
$this->db->where("uid",$uid);
$this->db->update("sysuser",$data);
}
The sysuser has the uid and name fields.I' not sure what I'm doing wrong here. Any help in this regard will be appreciated

You dont send your post data to controller. Change $this->userModel->saveUserDetails($user); as
$this->userModel->saveUserDetails($user,$this->input->post('name'));
Now Model should be like
public function saveUserDetails($uid,$name)
{
$data = array(
'name' => $name
);
$this->db->where("uid",$uid);
$this->db->update("sysuser",$data);
}
and make sure you have set correctly form action like
<form class="form-horizontal" method="post" action="<?php echo site_url('studentDashboardController/saveUserDetails');?>">

Related

Bootstrap 3: How to properly use a form-groups (a form) inside a grid?

For a university assessment I have been tasked with creating a very simple website with the concept of a 'Facebook Lite' that uses basic PHP and SQL functionality.
I am very new to bootstrap and have been attempting to correctly align a form within my register page. I can't quite figure out the correct way to place a form within a 3-6-3 bootstrap grid, the webpage just keeps presenting the form incorrectly to how I would like it.
The page I am working with is a php file (register.php) and so far I have worked out how to successfully create a working bootstrap horizontal form that will collapse to vertical when the window is sized down etc.
However I can't quite get it centered, the form keeps presenting to the right of the viewport, and the input boxes look horrible on a mobile device.
As explained I am extremely new to bootstrap so please forgive me if I am going about this the completely wrong way.
For your convenience I have prepared 2 pages;
Page 1 (register.php) -
What I believe to be the correct way to make a simple bootstrap form, however it is not centered and the input boxes go TINY on a mobile device (I just followed the bootstrap website instructions)
http://titan.csit.rmit.edu.au/~s3605062/register.php
Page 2 (register2.php)
My attempt to place my newly created form INSIDE a bootstrap grid of 3-6-3 (to supposedly center the form). I used the example demo from W3Schools so I could try and understand how it works, but as you can see its not working properly...
http://titan.csit.rmit.edu.au/~s3605062/register2.php
Code of register.php:
<div class="container">
<form class="form-horizontal" method="post" action="/register_new.php">
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="email" placeholder="e.g. jsmith#example.com" name="email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="pwd">Password:</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="pwd" placeholder="Create a password" name="pwd">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="fullname">Full Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="fullname" placeholder="e.g. John Smith" name="fullname">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="screenname">Screen Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="screenname" placeholder="e.g. John S" name="screenname">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="dateofbirth">Date of Birth:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="dateofbirth" placeholder="MM/DD/YYYY" name="dateofbirth"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="gender">Gender:</label>
<div class="col-sm-10">
<select class="form-control" id="gender" name="gender">
<option value="" selected disabled>Please select...</option>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="nonbinary">Non-Binary</option>
<option value="notsharing">Prefer not to answer</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="gender">Status:</label>
<div class="col-sm-10">
<select class="form-control" id="status" name="status">
<option value="" selected disabled>Please select...</option>
<option value="single">Single</option>
<option value="relationship">In a relationship</option>
<option value="complicated">Its complicated</option>
<option value="partnership">In a domestic partnership</option>
<option value="married">Married</option>
<option value="widowed">Widowed</option>
<option value="notsharing">Prefer not to answer</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="location">Location:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="location" placeholder="e.g. Melbourne, Australia" name="location">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="registerbtn" class="btn btn-default">Sign Up</button>
</div>
</div>
</form>
</div>
Code of register2.php:
<div class="container">
<div class="row">
<div class="col-sm-3" style="background-color:lavender;">.col-sm-3</div>
<div class="col-sm-6" style="background-color:lavenderblush;">
<form class="form-horizontal" method="post" action="/register_new.php">
<div class="form-group">
<label class="control-label col-sm-3" for="email">Email:</label>
<div class="col-sm-3">
<input type="email" class="form-control" id="email" placeholder="e.g. jsmith#example.com" name="email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6" for="pwd">Password:</label>
<div class="col-sm-6">
<input type="password" class="form-control" id="pwd" placeholder="Create a password" name="pwd">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6" for="fullname">Full Name:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="fullname" placeholder="e.g. John Smith" name="fullname">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6" for="screenname">Screen Name:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="screenname" placeholder="e.g. John S" name="screenname">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6" for="dateofbirth">Date of Birth:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="dateofbirth" placeholder="MM/DD/YYYY" name="dateofbirth"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6" for="gender">Gender:</label>
<div class="col-sm-6">
<select class="form-control" id="gender" name="gender">
<option value="" selected disabled>Please select...</option>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="nonbinary">Non-Binary</option>
<option value="notsharing">Prefer not to answer</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6" for="gender">Status:</label>
<div class="col-sm-6">
<select class="form-control" id="status" name="status">
<option value="" selected disabled>Please select...</option>
<option value="single">Single</option>
<option value="relationship">In a relationship</option>
<option value="complicated">Its complicated</option>
<option value="partnership">In a domestic partnership</option>
<option value="married">Married</option>
<option value="widowed">Widowed</option>
<option value="notsharing">Prefer not to answer</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6" for="location">Location:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="location" placeholder="e.g. Melbourne, Australia" name="location">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-6 col-sm-6">
<button type="registerbtn" class="btn btn-default">Sign Up</button>
</div>
</div>
</form>
</div>
<div class="col-sm-3" style="background-color:lavender;">.col-sm-3</div>
</div>
</div>
As an end result I would like it to have the form centered like on register2.php, but with the form labels and inputs presenting properly (similar to how they are on register.php). I am not even sure if a bootstrap grid is the correct way to do this!
Any help is extremely appreciated thank you and I do apologise for the lengthy post I just wanted to explain myself clearly.
Thank you.
Ricky
This will be the first code:
Try to always declare row with column inside container. d-flex and justify-content-center will help to centralized the form. It's bootstrap default class.
<div class="container">
<div class="row d-flex justify-content-center">
<div class="col-md-9">
<form class="form-horizontal" method="post" action="/register_new.php">
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="email" placeholder="e.g. jsmith#example.com" name="email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="pwd">Password:</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="pwd" placeholder="Create a password" name="pwd">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="fullname">Full Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="fullname" placeholder="e.g. John Smith" name="fullname">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="screenname">Screen Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="screenname" placeholder="e.g. John S" name="screenname">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="dateofbirth">Date of Birth:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="dateofbirth" placeholder="MM/DD/YYYY" name="dateofbirth"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="gender">Gender:</label>
<div class="col-sm-10">
<select class="form-control" id="gender" name="gender">
<option value="" selected disabled>Please select...</option>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="nonbinary">Non-Binary</option>
<option value="notsharing">Prefer not to answer</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="gender">Status:</label>
<div class="col-sm-10">
<select class="form-control" id="status" name="status">
<option value="" selected disabled>Please select...</option>
<option value="single">Single</option>
<option value="relationship">In a relationship</option>
<option value="complicated">Its complicated</option>
<option value="partnership">In a domestic partnership</option>
<option value="married">Married</option>
<option value="widowed">Widowed</option>
<option value="notsharing">Prefer not to answer</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="location">Location:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="location" placeholder="e.g. Melbourne, Australia" name="location">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="registerbtn" class="btn btn-default">Sign Up</button>
</div>
</div>
</form>
</div>
</div>
</div>
For the second form default.css, you are using padding for form, that's why you got a blank space in left side.
form {
margin-top: 10px;
padding-left: 370px;
}
Thanks.

How to get an array from form data

I am using Metronic Form Repeater in our project.
My form tag doesn't have any encryption or content type.
<form class="m-form" action="<?php echo $action; ?>" method='POST'></form>
When I submit the form, I can see our data like below
Unfortunately, when I print the $_POST, I see an empty array.
Form Code
<div class="form-group m-form__group row" id="m_repeater_1">
<div data-repeater-list="" class="col-lg-12">
<div data-repeater-item class="form-group m-form__group row align-items-center">
<div class="col-md-3">
<div class="m-form__group m-form__group--inline">
<div class="m-form__label">
<label>Column Name</label>
</div>
<div class="m-form__control">
<input type="name" name="col_name" class="form-control m-input" placeholder="Enter full name">
</div>
</div>
<div class="d-md-none m--margin-bottom-10"></div>
</div>
<div class="col-md-4">
<div class="m-form__group m-form__group--inline">
<div class="form-group m-form__group row">
<label class="col-form-label col-lg-3 col-sm-12">Data Type</label>
<div class="col-lg-6 col-md-9 col-sm-6">
<select class="form-control m-select2" id="m_select2_1" name="param">
<option value='TINYINT'>TINYINT</option>
<option value='SMALLINT'>SMALLINT</option>
<option value='MEDIUMINT'>MEDIUMINT</option>
</select>
</div>
</div>
</div>
<div class="d-md-none m--margin-bottom-10"></div>
</div>
<div class="col-md-3">
<div class="m-form__group m-form__group--inline">
<div class="m-form__label">
<label>Length</label>
</div>
<div class="m-form__control">
<input type="number" name="col_long" class="form-control m-input" placeholder="Uzunluk Giriniz">
</div>
</div>
<div class="d-md-none m--margin-bottom-10"></div>
</div>
<div class="form-group m-form__group col-md-3">
<label for="exampleSelect1">Default</label>
<select class="form-control m-input" id="exampleSelect1" name="col_def">
<option value='1'>NoDefault</option>
<option value='2'>NULL</option>
<option value='3'>CURRENT_TIMESTAMP</option>
<option value='4'>ON UPDATE CURRENT_TIMESTAMP</option>
<option value='5'>AUTO_INCREMENT</option>
</select>
</div>
</div>
</div>
</div>

create a shortcode of html form

I am trying to create a short code for html form. because I want to use this multiple time in my word-press page.
I have no idea how to do this . if any help please let help me
<form action="<?php echo get_page_link(2599) ?>" method="POST" >
<input type='hidden' name='page_id' value='2599'>
<div class="row">
<div class="form-group col-sm-3 col-md-2" id="bgform_text2">
<h4>SEARCH</h4>
<p>For Your Favourite Place</p>
</div>
<div class="form-group col-sm-5 col-md-2">
<label>Where to ? </label>
<input type="text" name="names" class="input-text full-width" placeholder="start typing here....">
</div>
<div class="form-group col-sm-5 col-md-4">
<div class="row">
<div class="col-xs-6">
<label>Arrive </label>
<div class="controls">
<input type="text" name="arive_time" id="departing">
</div>
</div>
<div class="col-xs-6">
<label>Departs </label>
<div class="controls">
<input type="text" name="depart_time" id="returning">
</div>
</div>
</div>
</div>
<div class="form-group col-sm-9 col-md-2">
<label>Sleeps </label>
<div class="controls">
<i class="fa fa-sort"></i>
<select name="sleeps">
<option value="" disabled="" selected=""></option>
<option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></option>
</select>
</div>
</div>
<div class="form-group col-sm-3 col-md-2">
<input type="submit" value="submit" name="submit_btn" class="button">
</div>
</div>
</form>
Try this.
<?php
function my_shortcode(){
$pagelink = get_page_link(2599);
return '<form action="'.$pagelink.'" method="POST" >
<input type="hidden" name="page_id" value="2599">
<div class="row">
<div class="form-group col-sm-3 col-md-2" id="bgform_text2">
<h4>SEARCH</h4>
<p>For Your Favourite Place</p>
</div>
<div class="form-group col-sm-5 col-md-2">
<label>Where to ? </label>
<input type="text" name="names" class="input-text full-width" placeholder="start typing here....">
</div>
<div class="form-group col-sm-5 col-md-4">
<div class="row">
<div class="col-xs-6">
<label>Arrive </label>
<div class="controls">
<input type="text" name="arive_time" id="departing">
</div>
</div>
<div class="col-xs-6">
<label>Departs </label>
<div class="controls">
<input type="text" name="depart_time" id="returning">
</div>
</div>
</div>
</div>
<div class="form-group col-sm-9 col-md-2">
<label>Sleeps </label>
<div class="controls">
<i class="fa fa-sort"></i>
<select name="sleeps">
<option value="" disabled="" selected=""></option>
<option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></option>
</select>
</div>
</div>
<div class="form-group col-sm-3 col-md-2">
<input type="submit" value="submit" name="submit_btn" class="button">
</div>
</div>
</form>';
}
add_shortcode('my_shortcode_name','my_shortcode');
?>
you can use this shortcode in your page
<?php echo do_shortcode('[my_shortcode_name]');?>
I think you are saying that you do not want to copy-paste the exact same code on multiple places inside your project, PHP has an include control structure method to take any file and use the contents on run-time.
Your code could eventually look something like this:
# form definition inside the main page that needs the form
<form action="<?php echo get_page_link(2599) ?>" method="POST" >
# include the template
<?php include('template.php') ?>
</form>
# template.php contains the html form
<input type='hidden' name='page_id' value='2599'>

Laravel : How to make a page submit to itself

I'm working on a page for editing user profiles but I want the page am working on to submit to itself when it is submitted and show a message that the profile has been edited successfully. Please how do I do this ?
Here is what am working ?
<div class="row">
<div class="text-center title">Pricing</div>
<div class="text-center desc col-md-8 col-md-push-2">
{{$sitename}}
</div>
<div class="container" style="padding-top: 60px;">
<h1 class="page-header">Edit Profile</h1>
<div class="row">
<!-- left column -->
<form class="form-horizontal" role="form" method="post" action="/profile">
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="text-center">
<img id="ShowImage" src="#"/>
<img src="http://localhost:8234/img/index.png" class="avatar img-circle img-thumbnail" alt="avatar" width="200" height="200">
<h6>Upload a different photo...</h6>
<input type="file" class="text-center center-block well well-sm" name="avatar_path" id="avatar_path" onchange="readURL(this);">
</div>
</div>
<!-- edit form column -->
<div class="col-md-8 col-sm-6 col-xs-12 personal-info">
<div class="alert alert-info alert-dismissable">
<a class="panel-close close" data-dismiss="alert">×</a>
<i class="fa fa-coffee"></i>
This is the <strong>Profile Page</strong>. Use this to <strong>ONLY</strong> change your peronsal details
</div>
<h3>Personal info</h3>
<input class="form-control" value="{{$userInfo['data']['id']}}" type="hidden" name="user_id">
<div class="form-group">
<label class="col-lg-3 control-label">First Name:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['first_name']}}" type="text" name="first_name">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Last Name:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['last_name']}}" type="text" name="last_name">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Username:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['profile']['username']}}" type="text" name="username">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Email Address:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['email']}}" type="text" name="email">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Gender</label>
<div class="col-lg-8">
<div class="ui-select">
<select id="gender" class="form-control" name="gender">
<option value="{{$userInfo['data']['profile']['gender']}}" selected>{{$userInfo['data']['profile']['gender']}}</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Other">Other</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">City:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['profile']['city']}}" type="text" name="city">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">State:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['profile']['state']}}" type="text" name="state">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Country:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['profile']['country']}}" type="text" name="country">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Mobile:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['profile']['mobile']}}" type="text" name="mobile">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Occupation:</label>
<div class="col-lg-8">
<input class="form-control" value="{{$userInfo['data']['profile']['occupation']}}" type="text" name="occupation">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label"></label>
<div class="col-md-8">
<input class="bkgrnd-blue text-white btn btn-primary" value="Update Profile" type="submit">
<span></span>
Cancel
</div>
</div>
</form>
</div>
</div>
</div>
This solution came from https://laravel.io/forum/01-30-2015-form-submission-to-the-same-page. Hope it helps
I have done a get route to display the page. I then did route a post to post form data.
Then I passed the $data variable to blade where I did an isset to check if it is created which displays the results
Display initial page
public function destinationSearchGet(){
$headData = array('pageTitle' => 'Admin Home - View all destinations');
return view('admin.destination_search', $headData);
}
post data back to the same page and create a new variable
public function destinationSearchPost(){
$headData = array('pageTitle' => 'Admin Home - Search results');
$formData = Request::input('destination');
$data = ParentRegionList::destinationSearch($formData);
return view('admin.destination_search', $headData)->with(compact('data'))
}
use blade to check if it exists
#if (isset($data))
<p>{{dd($data)}}</p>
#endif

send a php variable as part of an html form

I am working on a website which I didn't create and to which I do not have full access (I can create a page and add html scripts but not much more)
I am trying to add a form which will send data to be processed by a third-party servlet.
I am trying to include in this form the client ID, which I saw can be retrieved using the php functionsession_id().
My question is, how to send this information along with the rest of the input data.
my form for now is this:
<form class="form-horizontal" action = "url" method="POST" target="_blank">
<fieldset>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="selectbasic">Culture</label>
<div class="col-md-4">
<select id="Crop" name="Crop" class="form-control">
<option value="1">Maïs</option>
<option value="2">Ble</option>
</select>
</div>
</div>
<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="selectbasic">Produit</label>
<div class="col-md-4">
<select id="Product" name="Product" class="form-control">
<option value="Iodure d'azote">Iodure D'azote</option>
<option value="Desherbant">Desherbant</option>
</select>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="area">Surface</label>
<div class="col-md-4">
<input id="Area" name="Area" type="text" placeholder=" " class="form-control input-md" required="">
<span class="help-block">en Ha</span>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="dose">Dosage</label>
<div class="col-md-4">
<input id="Dose" name="Dose" type="text" placeholder="" class="form-control input-md" required="">
<span class="help-block">en L/Ha</span>
</div>
</div>
<div class="form-group">
<!--need to get the actual id-->
<input type="hidden" value="1" name = "ID"/>
<input type="submit" value="Ajouter" />
</div>
</fieldset>
</form>
Since this is my first time handling web apps, is there something obvious i'm missing?
OK i was lacking basic understanding of php. sorry for bothering,
the answer was here
i just had to write
<input type="hidden" value="<?php echo session_id();?>" name = "ID"/>
instead of
<input type="hidden" value="1"name = "ID"/>

Categories