mysqli cannot display full data - php

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']; ?>">

Related

not getting value in $_post array

this is my form code, when i am submitting the form i am not getting data in post array,i tried multiple methods but not receiving any response after clicking the button, here is the code
<?php
if (isset($_POST['submit'])) {
echo print_r($_POST);
}
?>
// other stuff
<form class="form-horizontal form-label-left" method="post" action="#" >
<span class="section">Info</span>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Name <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="name" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="name" placeholder="both name(s) e.g Jon Doe" required="required" type="text">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">Description <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<textarea id="description" required="required" name="description" class="form-control col-md-7 col-xs-12"></textarea>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">Type <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<select id="type" name="type" required="required" class="selectpicker form-control col-md-7 col-xs-12">
<option title="Combo 1">Weekly</option>
<option title="Combo 2">Monthly</option>
<option title="Combo 3">Annually</option>
</select>
</div>
</div>
<div class="ln_solid"></div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
<button type="submit" value="submit" name="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
change form action. and change button type
Block quote
<form class="form-horizontal form-label-left" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="submit" value="submit" name="submit" class="btn btn-success" value="Submit" />
Try it now :
<?php
if (isset($_POST['submit'])) {
echo print_r($_POST);
}
?>
// other stuff
<form class="form-horizontal form-label-left" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<span class="section">Info</span>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Name <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="name" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="name" placeholder="both name(s) e.g Jon Doe" required="required" type="text">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">Description <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<textarea id="description" required="required" name="description" class="form-control col-md-7 col-xs-12"></textarea>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">Type <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<select id="type" name="type" required="required" class="selectpicker form-control col-md-7 col-xs-12">
<option title="Combo 1">Weekly</option>
<option title="Combo 2">Monthly</option>
<option title="Combo 3">Annually</option>
</select>
</div>
</div>
<div class="ln_solid"></div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
<button type="submit" value="submit" name="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
Change these lines in your code
<form class="form-horizontal form-label-left" method="post" action="#" >
<button type="submit" value="submit" name="submit" class="btn btn-success">Submit</button>
With
<form class="form-horizontal form-label-left" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="submit" value="submit" name="submit" class="btn btn-success" value="Submit" />
there was script in my code
<script src="../vendors/jquery/dist/jquery.min.js"></script>
and i name my button "submit" so the error was in console
submit is not a function
so when i change the name of my button to "btnsubmit" it works fine.
When you name the button submit, you override the submit() function on the form.

php - error in Autopopulate not working

<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

POST button value works in Chrome but not in Firefox nor IE or Edge

Strange error. I've tested to use or and it's not working.
I have a form which I need to send the value of the submit button, here it's should be 'save' for the $_POST['saveBtn']
My form is declared like this :
<form id="clientFrm" action="index.php" class="form-horizontal form-label-left" method="post">
I have tried this :
<button id="saveBtn" name="saveBtn" type="submit" class="btn btn-success" value="save">save</button>
or
When I do a var_dump in Firefox (or IE or Edge), I get that :
array(16) { ["IDCompagnie"]=> string(1) "1"["Nom"]=> string(14) "Test" ["Adresse"]=> string(10) "test111111" ["Ville"]=> string(0) "" }
And when I do it in Chrome, everything works well! Here the var_dump in Chrome :
array(17) { ["IDCompagnie"]=> string(1) "1" ["Nom"]=> string(14) "MI-Consultants" ["Adresse"]=> string(7) "test111" ["Ville"]=> string(0) "" ["saveBtn"]=> string(4) "save" }
I only have one element named with 'saveBtn' in my form...
Do you know why it's only working on Chrome?
Here's the complete code :
<?php
$currentURL='index.php';
include 'header.php';
$db->connect();
//var_dump($_POST);
if( ISSET( $_POST['saveBtn'] ) && $_POST['saveBtn'] == 'save'){
unset($_POST['saveBtn']);
unset($_POST['telephone1']);
unset($_POST['telephone2']);
include 'misc/bd/saveCompagnie.php';
}
$cie = $db->getOne('compagnie');
if($cie){
foreach ($cie as $key => $value){
$$key = $value;
}
}
$db->where('IDCompagnie = 1');
$users = $db->get('user');
$db->__destruct();
?>
<!-- page content -->
<div class="right_col" role="main">
<div class="">
<div class="page-title">
<div class="title_left">
<h3>Modifier Informations Compagnie</h3>
<?php //var_dump($cie); ?>
</div>
</div>
<div class="clearfix"></div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>Informations générales </h2>
<div class="clearfix"></div>
</div>
<div class="x_content">
<br />
<form id="clientFrm" action="index.php" data-parsley-validate class="form-horizontal form-label-left" method="post">
<input type="hidden" id="IDCompagnie" name="IDCompagnie" value="<?php echo ISSET($IDCompagnie) ? $IDCompagnie : '' ?>">
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="Nom">Nom <span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="Nom" name="Nom" class="form-control col-md-7 col-xs-12" required="required" type="text" value="<?php echo ISSET($Nom) ? $Nom : '' ?>">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="Adresse">Adresse</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="Adresse" name="Adresse" class="form-control col-md-7 col-xs-12" type="text" value="<?php echo ISSET($Adresse) ? $Adresse : '' ?>">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="Ville">Ville</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="Ville" name="Ville" class="form-control col-md-7 col-xs-12" type="text" value="<?php echo ISSET($Ville) ? $Ville : '' ?>">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="Province">Province</label>
<div class="col-md-2 col-sm-2 col-xs-12">
<input id="Province" name="Province" class="form-control col-md-7 col-xs-12" type="text" value="<?php echo ISSET($Province) ? $Province : '' ?>">
</div>
<label class="control-label col-md-2 col-sm-2 col-xs-12" for="CodePostal">Code Postal</label>
<div class="col-md-2 col-sm-2 col-xs-12">
<input id="CodePostal" name="CodePostal" type="text" class="form-control" value="<?php echo ISSET($CodePostal) ? $CodePostal : '' ?>">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="telephone">Téléphone</label>
<div class="col-md-2 col-sm-2 col-xs-12">
<input id="telephone1" name="telephone1" type="text" class="form-control" data-inputmask="'mask' : '(999) 999-9999'" value="<?php echo ISSET($Telephone1) ? $Telephone1 : '' ?>">
<span class="fa fa-phone form-control-feedback right" aria-hidden="true"></span>
<input id="Telephone1" name="Telephone1" type="hidden" value="<?php echo ISSET($Telephone1) ? $Telephone1 : '' ?>">
</div>
<label class="control-label col-md-2 col-sm-2 col-xs-12" for="telephone">Téléphone</label>
<div class="col-md-2 col-sm-2 col-xs-12">
<input id="telephone2" name="telephone2" type="text" class="form-control" data-inputmask="'mask' : '(999) 999-9999'" value="<?php echo ISSET($Telephone2) ? $Telephone2 : '' ?>">
<span class="fa fa-phone form-control-feedback right" aria-hidden="true"></span>
<input id="Telephone2" name="Telephone2" type="hidden" value="<?php echo ISSET($Telephone2) ? $Telephone2 : '' ?>">
</div>
</div>
<div class="clear-margin"></div>
<div class="x_title">
<h2>Autres Informations </h2>
<div class="clearfix"></div>
</div>
<div class="item form-group">
<label class="control-label col-md-2 col-sm-2 col-xs-12" for="TauxHoraire">Taux Horaire</label>
<div class="col-md-2 col-sm-2 col-xs-12">
<input type="text" id="TauxHoraire" name="TauxHoraire" min="0" class="form-control col-md-7 col-xs-12" value="<?php echo ISSET($TauxHoraire) ? $TauxHoraire : '' ?>">
<span class="fa fa-usd form-control-feedback right" aria-hidden="true"></span>
</div>
<label class="control-label col-md-2 col-sm-2 col-xs-12" for="Financement">Financement</label>
<div class="col-md-2 col-sm-2 col-xs-12">
<input type="text" id="Financement" name="Financement" class="form-control col-md-7 col-xs-12" value="<?php echo ISSET($Financement) ? $Financement : '' ?>">
<span class="fa fa-percent form-control-feedback right" aria-hidden="true"></span>
</div>
<label class="control-label col-md-2 col-sm-2 col-xs-12" for="EntenteSignature">Entente Signature</label>
<div class="col-md-2 col-sm-2 col-xs-12">
<input type="number" id="EntenteSignature" name="EntenteSignature" min="0" max="100" class="form-control col-md-7 col-xs-12" value="<?php echo ISSET($EntenteSignature) ? $EntenteSignature : 50 ?>">
<span class="fa fa-percent form-control-feedback right" aria-hidden="true"></span>
</div>
</div>
<div class="clear-margin"></div>
<div class="x_title">
<h2>Valeurs constantes </h2>
<div class="clearfix"></div>
</div>
<div class="item form-group">
<label class="control-label col-md-2 col-sm-2 col-xs-12" for="CoutEnvoiPoste">Coût Envois Postaux (unitaire)</label>
<div class="col-md-2 col-sm-2 col-xs-12">
<input type="text" id="CoutEnvoiPoste" name="CoutEnvoiPoste" maxlength="5" class="form-control col-md-7 col-xs-12" value="<?php echo ISSET($CoutEnvoiPoste) ? $CoutEnvoiPoste : 0.00 ?>">
<span class="fa fa-usd form-control-feedback right" aria-hidden="true"></span>
</div>
<label class="control-label col-md-2 col-sm-2 col-xs-12" for="CoutMachineTimbre">Coût Machine à Timbre (mensuel)</label>
<div class="col-md-2 col-sm-2 col-xs-12">
<input type="text" id="CoutMachineTimbre" name="CoutMachineTimbre" maxlength="5" class="form-control col-md-7 col-xs-12" value="<?php echo ISSET($CoutMachineTimbre) ? $CoutMachineTimbre : 0.00 ?>">
<span class="fa fa-usd form-control-feedback right" aria-hidden="true"></span>
</div>
<label class="control-label col-md-2 col-sm-2 col-xs-12" for="PctImpressionPapeterie">% d'impression et papeterie</label>
<div class="col-md-2 col-sm-2 col-xs-12">
<input type="number" id="PctImpressionPapeterie" name="PctImpressionPapeterie" min="0" class="form-control col-md-7 col-xs-12" value="<?php echo ISSET($PctImpressionPapeterie) ? $PctImpressionPapeterie : 0 ?>">
<span class="fa fa-percent form-control-feedback right" aria-hidden="true"></span>
</div>
</div>
<div class="larger clear-margin"></div>
<div class="x_title">
<h2>Listes des Utilisateurs </h2>
<div class="clearfix"></div>
</div>
<div class="item form-group">
<table id="datatable-buttons" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
<thead>
<tr>
<th>Nom</th>
<th>Prénom</th>
<th>Username</th>
<!-- th>Rôle</th-->
</tr>
</thead>
<tbody>
<?php
foreach( $users as $row ) {
?>
<tr>
<td><?php echo setEncodage($row['Nom'])?></a></td>
<td><?php echo setEncodage($row['Prenom'])?></td>
<td><?php echo setEncodage($row['Username'])?></td>
<!-- td><?php //echo $row['Role']?></td-->
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<div class="ln_solid"></div>
<div class="form-group">
<div class="col-md-12 col-md-offset-5">
<input id="cancelBtn" name="cancelBtn" type="button" class="btn btn-primary" value="Cancel">
<button id="saveBtn" name="saveBtn" type="submit" class="btn btn-success" value="save">Enregistrer</button>
</div>
</div>
<div class="ln_solid"></div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- /page content -->
<?php
include 'footer.php';
include 'js/pageJS/indexJS.php'
?>
</body>
</html>

Codeigniter: how to check if username already exists from mysql database

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!

can't tap on a php included section on mobile

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.

Categories