<div class="form-group">
<label class="col-md-3 col-sm-3 col-xs-12" for="">Member No of the Transferer<span class="required">*</span></label>
<div class="col-md-3 col-sm-6 col-xs-12">
<input required="" class="form-control col-md-7 col-xs-12" id="old_member_no" type="number" name="old_member_no" <?php if(isset($editData)) echo 'readonly style="pointer-events: none;"'; ?> value="{{ old('old_member_no',isset($editData) ? $editData->old_member_no:"") }}">
<input type="hidden" name="member_no" value="{{ old('member_no',isset($editData) ? $editData->member_no:"") }}" />
</div>
<span class="help-block"></span>
</div>
<div class="form-group">
<label class="col-md-3 col-sm-3 col-xs-12" for="">Name of the Transferer<span class="required">*</span></label>
<div class="col-md-3 col-sm-6 col-xs-12 ">
<input required="" class="form-control col-md-7 col-xs-12" id="" type="text" name="full_name" value="{{ old('full_name',isset($editData) ? $editData->full_name:"") }}">
</div>
<span class="help-block"></span>
</div>
<div class="form-group">
<label class="col-md-3 col-sm-3 col-xs-12" for="">Address of the Transferer<span class="required">*</span></label>
<div class="col-md-3 col-sm-6 col-xs-12 ">
<input required="" class="form-control col-md-7 col-xs-12" id="house" type="text" name="house" value="{{ old('house',isset($editData) ? $editData->house:"") }}">
</div>
<span class="help-block"></span>
</div>
Hello guys. I'm doing a project. I'm developing a form with autopopulate. If number is typed and after pressing enter the address and name should be fetched from database. kindly help me
Since it is not clear to me but base on your descriptions... You would need to use Javascript/JQuery here and use Event functions when the entering a field
Related
I have a Laravel application with a registration form, and anyone can register multiple accounts.
I want to limit the registration to one account per IP address. How do I achieve this? I also want to only accept Gmail.
Here is my registration form:
<h4> {{ $page_title }} </h4>
<span class="liner"></span>
<div class="row">
<div class="col-md-6 col-md-offset-2 col-sm-12">
<h4> Registration </h4>
<span class="liner"></span>
<div class="widget-content clearfix">
<form action="{{ route('post-member') }}" method="post" class="form-horizontal" enctype="multipart/form-data">
{!! csrf_field() !!}
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">Member Plan</label>
<div class="col-sm-8">
<select name="price_id" id="" class="form-control" required>
#foreach($price as $p)
#if($p->id == $pr)
<option value="{{ $p->id }}" selected>{{ $p->title }} - {{ $general->currency }} {{ $p->price }}</option>
#else
<option value="{{ $p->id }}">{{ $p->title }} - {{ $general->currency }} {{ $p->price }}</option>
#endif
#endforeach
</select>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">Name</label>
<div class="col-sm-8">
<input type="text" name="name" class="form-control" id="inputEmail3" placeholder="Name" required>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">Email</label>
<div class="col-sm-8">
<input type="email" name="email" class="form-control" id="inputEmail3" placeholder="Email" required>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">Phone</label>
<div class="col-sm-8">
<input type="text" name="phone" required class="form-control" id="inputEmail3" placeholder="Phone">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">Address</label>
<div class="col-sm-8">
<textarea name="address" id="" cols="30" rows="3"
class="form-control" required></textarea>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">Profile Picture</label>
<div class="col-sm-8">
<input type="file" name="image" id="" required class="form-control">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Password</label>
<div class="col-sm-8">
<input type="password" required name="password" class="form-control" id="inputPassword3" placeholder="Password">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Confirm Password</label>
<div class="col-sm-8">
<input type="password" required name="password_confirmation" class="form-control" id="inputPassword3" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-8">
<button type="submit" class="btn btn-default"><i class="fa fa-send"></i> Registration</button>
</div>
</div>
</form>
I have a table named testads and the data are as below
Link to table image
I want to make an update page where the data are select by row. I have no problem with updating the data however when the data is displayed in update page, instead of the company name Subway Malaysia, it only shows Subway. This happens to all the data with more than one word. I can't seem to find what's the problem
Here are the php code:
<?php
include('./include/connection.php');
$ID=$_GET['no'];
$query = "SELECT no, id_company, company_name, jobName,state, location, jobDesc, contact FROM testads where no='$ID'";
$result = mysqli_query($link, $query) or die ("error.");
while ($row = mysqli_fetch_array($result)){
$id=$row['no'];
?>
<form class="form-horizontal form-label-left" method="post" action="edit_query.php<?php echo '?no='.$id; ?>">
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="comp-name">Company Name <span class="required"></span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="comp-name" required="required" name="cname" class="form-control col-md-7 col-xs-12" value=<?php echo $row['company_name']; ?>>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="comp-id">Company ID <span class="required"></span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="comp-id" required="required" name="cid" class="form-control col-md-7 col-xs-12" value=<?php echo $row['id_company']; ?>>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="job-name">Job Name <span class="required"></span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="job-name" required="required" name="jname" class="form-control col-md-7 col-xs-12" value=<?php echo $row['jobName']; ?>>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="desc">Job Description<span class="required"></span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<textarea id="desc" name="description" class="form-control" maxlength="2000" value=<?php echo $row['jobDesc']; ?>></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="stt">State</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<select name="state" class="form-control">
<option value="Johor"<?php echo $row['state'] == 'Johor' ? 'selected="selected"' : '' ; ?>>Johor</option>
<option value="Malacca"<?php echo $row['state'] == 'Malacca' ? 'selected="selected"' : '' ; ?>>Malacca</option>
<option value="Pahang"<?php echo $row['state'] == 'Pahang' ? 'selected="selected"' : '' ; ?>>Pahang</option>
<option value="Selangor"<?php echo $row['state'] == 'Selangor' ? 'selected="selected"' : '' ; ?>>Selangor</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="loc">Location<span class="required"></span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="loc" required="required" name="location" class="form-control col-md-7 col-xs-12" value=<?php echo $row['location']; ?>>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="ctc">Contact<span class="required"></span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="ctc" required="required" name="contact" class="form-control col-md-7 col-xs-12" value=<?php echo $row['contact']; ?>>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
<button class="btn btn-success" type="submit" name="submit">Update</button>
</div>
</div>
</form>
You need to quote your values:
<input ... value="<?php echo $row['company_name']; ?>">
im very new at laravel, and now, I'm building an edit form and the date of Birth will always back to time "1-1-1970" everytime i want to change it.
Whats wrong with my code?
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="date_of_bday">
Date Of Birthday
<span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="single_cal1" type="text" class="form-control has-feedback-left #if($errors->has('date_of_bday')) parsley-error #endif"
name="date_of_bday" placeholder="Date Of Birthday" aria-describedby="inputSuccess2Status" value="{{ date('m/d/Y', strtotime($member->dob)) }}" required>
<span class="fa fa-calendar form-control-feedback left" aria-hidden="true"></span>
</div>
</div>
Use Carbon to parse the date and format it accordingly
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="date_of_bday">
Date Of Birthday
<span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="single_cal1" type="text" class="form-control has-feedback-left
#if($errors->has('date_of_bday')) parsley-error #endif"
name="date_of_bday"
placeholder="Date Of Birthday"
aria-describedby="inputSuccess2Status"
value="{{ Carbon\Carbon::parse($member->dob)->format('m/d/Y') }}"
required>
<span class="fa fa-calendar form-control-feedback left" aria-hidden="true"></span>
</div>
</div>
I'm currently working on codeigniter. I am not so expert using framework. I have a registration form of an employee and I want it to display "username already exists" beside the Username input after I submit a button.
Here is the image of tables from mysql database:
Image of tables from mysql database
Here is the controller (home.php):
public function viewAddEmployeeForm() {
$this->load->model('Model_home');
$data = array();
$data['dropdown'] = $this->Model_home->get_dropdown();
$this->load->view('imports/header');
$this->load->view('imports/menu');
$this->load->view('emp_add', $data);
}
public function saveEmployee() {
$this->load->model('Model_home');
$p = new Model_home();
$p->date_employed = $this->input->post('date_emp');
$p->designation_id = $this->input->post('emp_desi');
$p->username = $this->input->post('username');
$p->password = $this->input->post('pswrd');
$p->name = $this->input->post('emp_name');
$p->midname = $this->input->post('emp_mname');
$p->lastname = $this->input->post('emp_lname');
$p->CityAddress = $this->input->post('emp_cadd');
$p->license_num = $this->input->post('emp_license');
$p->TIN_num = $this->input->post('emp_tin');
$p->SSSNo = $this->input->post('emp_sss');
$p->PhilHealth = $this->input->post('emp_ph');
$p->DoB = $this->input->post('emp_dob');
$p->Gender = $this->input->post('emp_gender');
$p->contnum = $this->input->post('emp_mobno');
$p->ContactPerson = $this->input->post('emp_contpers');
$p->ContactPerson_Num = $this->input->post('emp_contpersnum');
$p->ContactPerson_Add = $this->input->post('emp_contpersadd');
if($p->designation_id == 1){
$p->user_type = 0;
}else{
$p->user_type = 1;
}
$result = $p->saveEmployee();
if (!$result) {
echo mysqli_error($result);
}
else {
redirect('home/goSettings', 'refresh');
}
}
Here is the view: (emp_add.php):
<h1>Add Employee</h1>
<br>
<?php echo form_open('home/saveEmployee',array('class'=>'form-horizontal'));?>
<h4> Personal Information </h4>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">First Name <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="emp_name" name="emp_name" required="required" class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Last Name <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="emp_lname" name="emp_lname" required="required" class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="form-group">
<label for="middle-name" class="control-label col-md-3 col-sm-3 col-xs-12">Middle Name / Initial</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="emp_mname" name="emp_mname" class="optional form-control col-md-7 col-xs-12" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Gender</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<div id="gender" class="btn-group" data-toggle="buttons">
<select id="emp_gender" name="emp_gender" class="form-control">
<option id="emp_gender" name="emp_gender" value="Male">Male</option>
<option id="emp_gender" name="emp_gender" value="Female">Female</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Date Of Birth <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="emp_dob" name="emp_dob" class="date-picker form-control col-md-7 col-xs-12" required="required" type="date">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Address <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="emp_cadd" name="emp_cadd" class="form-control col-md-7 col-xs-12" required="required" type="text">
</div>
</div>
<h4> Employee Identification </h4>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">License Number</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="emp_license" name="emp_license" class="optional form-control">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">TIN Number</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="emp_tin" name="emp_tin" class="optional form-control">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">SSS Number</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="emp_sss" name="emp_sss" class="optional form-control" >
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">PhilHealth</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="emp_ph" name="emp_ph" class="optional form-control" >
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Username <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="username" name="username" required="required" class="form-control col-md-7 col-xs-12" onblur="return check_username();">
<div id="Info"></div>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Password <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="password" id="pswrd" name="pswrd" required="required" class="form-control col-md-7 col-xs-12">
</div>
</div>
<h4> Work details </h4>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Date Employed <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="date_emp" name="date_emp" class="date-picker form-control col-md-7 col-xs-12" required="required" type="date">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Designation <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<?php echo form_dropdown('emp_desi', $dropdown, '', 'class="form-control" id="emp_desi"'); ?>
</div>
</div>
<h4> Contact Information </h4>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Mobile Number <span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="emp_mobno" name="emp_mobno" class="form-control" required="required" >
</div>
</div>
<h4> Contact Person </h4>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Name <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="emp_contpers" name="emp_contpers" required="required" class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Address <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="emp_contpersadd" name="emp_contpersadd" required="required" class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Mobile Number <span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="emp_contpersnum" name="emp_contpersnum" required="required" class="form-control" >
</div>
</div>
<div class="ln_solid"></div>
<div class="form-group">
<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
<button type="submit" class="btn btn-success" name="emp_submit" id="emp_submit" onclick="alert('You have successfully added an employee')">Submit</button>
</div>
</div>
</form>
Here is the model (model_home.php):
public function saveEmployee() {
if (isset($this->empnum)) {
$query = $this->updateEmployee();
}
else {
$query = $this->addEmployee();
}
return $query;
}
public function get_dropdown() {
$result = $this->db->select('designation_id, designation')->get('designation')->result_array();
$dropdown = array();
foreach($result as $r) {
$dropdown[$r['designation_id']] = $r['designation'];
}
return $dropdown;
}
Try this
$this->form_validation->set_rules('username', 'Username', 'required|is_unique[users.username]');
Here is_unique[users.username], users refer to users table & username refer to field name in users table. This will automatically check for username in users table.
To see if something already exists in a database you usually either use the LIKE command or a REGEXP command to test if the entry is already there. See this article for how to use REGEXP:
mySQL regex in the where clause
If the item is already there it will return the item. If not it should return NULL or nothing.
Then all you do is to refresh the pre-existing HTML web page. The only change you need in your current web page is a bit of PHP code that just echos the returning information. So something simple like:
<?php echo $foundIt; ?>
You put that next to where they put in the username (or the username is displayed). Be sure to declare the variable with a blank field if nothing is found. I.E.:
$foundIt = "";
Otherwise your web page will generate an error saying it is undefined.
I see sriAnkush answered your question. My answer is using plain HTML. Looks like his is using CodeIgniter. :-)
try controller function like this. Get Username in $username and pass it to model. use Select query where username is equal to $username and return the array. If there is any similar username $result will be greater than or equal to 1. so it will show username already exist else it will save your data.
public function saveEmployee() {
$username=$this->input->post('username');
$result=$this->model->checkUsername($username);
if($result>=1){
echo "Username Already exists";
}
else{
// Query to save the username and data;
}
}
Good Luck!
I have an HTML page where a form section is included like this :
<?php include 'templates/register-form.php'?>
In a web browser there is no problem and everythig is working .
But on mobile , i can see the section , but cannot tap on it , the input doesn't react and neither the buttons .
What can it be?
thanx!
the code below is the included section.
<form role="form">
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12 pull-right">
<div class="form-group">
<label for="nusername" language="en">username :</label>
<input type="text" class="form-control input-sm login-input" name="nusername" placeholder="שם משתמש" value="<?php echo Input::get('username')?>">
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12 pull-right">
<div class="form-group">
<label for="fullname" language="en">full name :</label>
<input type="text" class="form-control input-sm login-input" name="fullname" placeholder="שם מלא" value="<?php echo Input::get('fullname')?>">
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12 pull-right">
<div class="form-group">
<label for="npassword" language="en">password :</label>
<input type="password" class="form-control input-sm login-input" name="npassword" placeholder="שם מלא" value="<?php echo Input::get('password')?>">
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12 pull-right">
<div class="form-group">
<label for="password_again" language="en">password again :</label>
<input type="password" class="form-control input-sm login-input" name="password_again" placeholder="הקלד את הסיסמא שנית" value="<?php echo Input::get('password_again')?>">
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12 pull-right">
<div class="form-group">
<label for="email" language="en">email:</label>
<input type="email" class="form-control input-sm login-input" name="email" placeholder="אי-מייל" value="<?php echo Input::get('email')?>">
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12 pull-right">
<div class="form-group">
<label for="adress" language="en">adress:</label>
<input type="text" class="form-control input-sm login-input" name="adress" placeholder="כתובת" value="<?php echo Input::get('adress')?>">
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12 pull-right">
<div class="form-group">
<label for="phone" language="en">phone:</label>
<input type="tel" class="form-control input-sm login-input" name="phone" placeholder="טלפון" value="<?php echo Input::get('phone')?>">
</div>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 pull-right">
<div class="form-group">
<a class="form-control input-sm register-button btn btn-success pull-left" name="register-button" >הירשם</a>
</div>
</div>
In each field, your label attaches to the input field using the for-attribute. Safari connects for-attributes to id's, not names. Add the correct id to each of your inputs.
Example:
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12 pull-right">
<div class="form-group">
<label for="nusername" language="en">username :</label>
<input type="text" class="form-control input-sm login-input" id="username" name="nusername" placeholder="שם משתמש" value="<?php echo Input::get('username')?>">
</div>
</div>
Also, I suspect you just left it out of your example, but don't forget your tag, which might cause some issues in the Browser.