Want To Exec command To Solr - php

this Is My Code In View
<form class="form-horizontal" id="USER_ID_LOGING" name="USER_ID_LOGIN" action="<?php echo base_url('feed_admin/feed_submit') ?>" method="POST">
<div class="form-group">
<label for="inputPass" class="col-sm-1 control-label">Feed</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="input_feed" name="input_feed" value="<?php echo set_value('input_feed'); ?>" />
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<button type="submit" class="btn btn-success"> input Feed </button>
</div>
</div>
</form>
this is controller
function feed_submit(){
$this->form_validation->set_rules('input_feed','feed','required');
if($this->form_validation->run() == true)
{
$feedlink = $this->input->post("input_feed");
$solr_check ="dir";
$solr_directory="cd C:\solr";
$solr_dir = passthru("$solr_directory $solr_check" );
echo $solr_dir;
}
My Problem Is I want To execute Command To Cd To Another Floder like This
cd C:\solr and add new feed To solr
Thank you For your answer

Related

How to pass value of a form to another form PHP?

I have a form A in index.php which I need to pass the value of 'notebook_id' to formB in create_new_note.php. I used POST method to do this but it is not working.
form A in index.php
<!-- Modal -->
<div class="modal" id="newNotebookModal" tabindex="-1" aria-labelledby="newNotebookModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<center><h5 class="modal-title" id="newNotebookModalLabel">Create a New Notebook</h5></center>
</div>
<div class="modal-body">
<form class="forms-sample" method="post">
<div class="form-group">
<label for="notebook_name_label">Notebook Name</label>
<input type="text" class="form-control" name="notebook_name" id="notebook_name" placeholder="Notebook Name">
</div>
</div>
<div class="modal-footer">
<button class="btn btn-outline-secondary btn-fw">Cancel</button>
<input type="submit" class="btn btn-primary" name="submit" value="Create"/>
</div>
</form>
</div>
</div>
</div>
</div>
Form B
<form class="forms-sample" method="post">
<div class="form-group">
<label for="note_title_label">Title</label>
<input type="hidden" name="notebook_id" value="<?php echo $notebook_id; ?>">
<input type="text" class="form-control" name="note_title" id="note_title" placeholder="Title">
</div>
<div class="form-group">
<textarea class="form-control" name ="note_content"id="note_content" rows="40"></textarea>
</div>
<button class="btn btn-outline-secondary btn-fw">Cancel</button>
<input type="submit" class="btn btn-primary" name="submit" value="Create"/>
</form>
I used MVC framework, hence this is my Controller code and Model code
// Controller
function addNotebook($std_id) {
$notebook = new ManageNotesModel();
$notebook->std_id = $std_id;
$notebook->notebook_name = $_POST['notebook_name'];
if($notebook->addNotebook() > 0) {
$message = "Your notebook has been created!";
echo "<script type='text/javascript'>alert('$message');
window.location = '../ManageNotesView/create_new_note.php'</script>";
}
}
// Model
function addNotebook(){
$sql = "insert into notebook(std_id, notebook_name)values(:std_id, :notebook_name)";
$args = [':std_id'=> $this->std_id, ':notebook_name'=>$this->notebook_name];
$stmt = DB::run($sql, $args);
$count = $stmt->rowCount();
return $count;
}
Please help me, I'm new to this I tried to make way through it, but cant seem to figure out whats wrong
As I see your code is creating a new row in the database. After saving row into database you want to know the last inserted id of the entity called Notebooks. Reuse that value and pass it into your template of creating titles. If your MVC framework does not know the last inserted id, you should customize it and add functionality to do that.
Check last_inserted_id

Modify button doesn't work despite i call the patch method '#method('PATCH')', and i want to show the document but it doesn't appear

the edit doesn't work when i click on edit button it recover the values of the input but do not modify it in the database
Edit.blade.php
#extends('index')
#section('content')
<script language="javascript" type="text/javascript" src={{ URL::to('js/extension.js') }}></script>
<div class="form-group" style="margin-top: 100px;">
<form class="forms-sample" action="/documentSideBar" method="get" enctype="multipart/form-data">
#csrf
#method('PATCH')
<div class="form-group">
<label for="nomDocument">Nom document</label>
<input type="text" class="form-control" id="nomDocument" name="nomDocument"
value="{{$document->nomDocument}}" onChange='getoutput2()'>
</div>
<div class="form-group">
<label for="description">Description</label>
<input type="text" class="form-control" id="description" name="description"
value="{{$document->description}}">
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group row">
<label class="col-sm-3 col-form-label">Type</label>
<div class="col-sm-9">
<select class="form-control">
<option>Documents administratifs</option>
<option>Documents financiéres</option>
</select>
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="fille">Importer un fichier</label>
<input type="file" onChange='getoutput()' name="file" id="fille" class="form-control">
<input id='extension' type='hidden' name='extension'>
<input id="pathe" type="hidden" name="path">
</div>
<button type="submit" class="btn btn-success mr-2">Modifier</button>
<button class="btn btn-light">Annuler</button>
</form>
</div>
#endsection
documentSideBar.blade.php
<td style="width:300px">
<a href="/download/{{$document->id}}" class="btn btn-success"><i
class="glyphicon glyphicon-download-alt"></i></a>
<a href="/documentSideBar/{{$document->id}}/edit" style="float:right" class="btn btn-primary">
<i class="glyphicon glyphicon-edit"></i>
</a>
<form action="{{ action('DocumentsController#destroy', $document->id)}}" method="POST">
#method('DELETE')
#csrf
<button class="btn btn-danger"><i
class="glyphicon glyphicon-trash"></i></button>
</form>
</td>
this is the edit and update method in the controller
DocumentsController.php
public function edit($id)
{
$document = Document::findOrFail($id);
return view('documents.edit', compact('document'));
}
public function update(Document $document)
{
$document->nomDocument = request('nomDocument');
$document->description = request('description');
$d=request('path');
if(isset($d)){
$document->path ='username'.'/'.request('path');
}
$document->save();
return redirect('/documentSideBar');
}
public function show($id)
{
$document = Document::findOrFail($id);
return view('documentSideBar', compact('document'));
}
also i I want to adjust the buttons , idon't how to make the space between them
the error was in the web.php : here is the right route
Route::resource('documentSideBar','DocumentsController');
Route::get('download/{id}','DocumentsController#download');
Route::get('show/{id}','DocumentsController#show');
Route::post('/update/{id}','DocumentsController#update');
You should change your form method to POST, and change your action to the resource pattern:
<form class="forms-sample" action="{{route('documentSideBar.update', $document->id)}}" method="POST" enctype="multipart/form-data"
#csrf
#method('PATCH')
When you're modifying data in your database you should use POST, not GET.
Take a look here to see more information about the methods.
You also should take a look at the Resource Controller section to understand more about what are you using

Dropzone sending all queue of uploaded files to the controller once

I am trying to send multiple files in one request using DropZone js.
<script type="text/javascript">
Dropzone.autoDiscover = false;
var file= new Dropzone(".dropzone",{
url: any url,
method:"post",
paramName:"PhotoFiles",
addRemoveLinks:true,
autoProcessQueue: false
});
//Upload file onsubmit
$('#UploadMultiFiles').submit(function(){
file.processQueue();
});
file.on("sending",function(a,b,c){
a.token=Math.random();
c.append("token",a.token);
});
The issue is I have other inputs in the same form that is why I used onsubmit, and these inputs are saved in a table and the images from dropzone are saved in another table with and both tables have one to many relationship
The Controller like:
public function university_offers($id){
$data['university_offer_name']=$this->input->post('university_offer_name');
$data['university_id_fk']=$this->input->post('university_id_fk');
$data['university_offer_details']=$this->input->post('university_offer_details');
if ($this->input->post('save')){
$data2['university_offer_id_fk'] = insertrecords('university_offers',$data);
$data2['university_id_fk'] = $data['university_id_fk'];
//when I put the next IF at the begining of the function it works but ofcourse without the other data fields that I need.
if(isset($_FILES) && $_FILES != null){
$data2['photo_name'] = upload_image('PhotoFiles');
insertrecords('university_offer_photos',$data2);
}
if (insertrecords('university_offer_photos',$data2)==true)
message('success','');
redirect('Admin/university_offers/0','refresh');
}
$data['view']="admin/universities/university_offers";
$this->load->view('index',$data);
}
What I need is sending al uploaded files and do a loop in the controller to save it right in the database, not sending each file to the controller and saving it.
Edit:
My view is like:
<form action="university_offers/<?=$id?>" id="UploadMultiFiles" autocomplete="off" method="post" enctype="multipart/form-data" class="m-t-5" novalidate>
<div class="form-body">
<h3 class="card-title">بيانات العرض</h3>
<hr>
<div class="row p-t-20">
<div class="col-md-6">
<div class="form-group">
<label class="control-label">إسم العرض<span class="text-danger">*</span></label>
<div class="controls">
<input type="text" autocomplete="off" name="university_offer_name" class="form-control" required value="<?php if(isset($result)) echo $result['university_offer_name']?>" data-validation-required-message="يجب إدخال إسم العرض" placeholder="إسم العرض">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="control-label">إسم الجامعة<span class="text-danger">*</span></label>
<div class="controls">
<select name="university_id_fk" id="select" class="form-control" required data-validation-required-message="يجب إختيار الجامعة" aria-invalid="false">
<option value="">إختر الجامعة</option>
<?php
foreach (selectrecords("*",'universities') as $university):
$select = '';
if(isset($result) && $result['university_id_fk'] == $university->university_id_pk)
$select = 'selected';
?>
<option <?=$select?> value="<?php echo $university->university_id_pk ?>"><?php echo $university->university_name ?></option>
<?php endforeach;?>
</select>
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label class="control-label">تفاصيل العرض<span class="text-danger">*</span></label>
<div class="controls">
<textarea id="mymce" name="university_offer_details"><?php if(isset($result)) echo $result['university_offer_details'] ?></textarea>
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label class="control-label">صور العرض<span class="text-danger">*</span></label>
<div class="row">
<?php
if(isset($result)) {
foreach (selectrecords('*','university_offer_photos',array('university_offer_id_fk'=>$result['university_offer_id_pk'])) as $photo):
echo'
<div class="form-group text-center" id="'.$photo->photo_id_pk.'">
<div class="col-md-12">
<img style="border: none; height: 150px; width: 150px; border-radius: 10px;" class="img-thumbnail" src="'.base_url().'public/uploads/images/'.$photo->photo_name.'">
</div>
حذف الملف
</div>
';
endforeach;
}
?>
</div>
<div class="dropzone">
<div class="dz-message">
<span> Drag and Drop your files here Or Click here to upload</span>
</div>
</div>
</div>
</div>
</div>
<div class="form-actions">
<input type="hidden" id="url" value="university_offers/<?=$id?>" />
<?php
if($id == 0)
echo '<button type="submit" id="butt" name="save" value="save" class="btn btn-primary"> <i class="fa fa-check"></i> حفظ</button>';
else
echo '<button type="submit" id="butt" name="edit" value="edit" class="btn btn-primary"><i class="fa fa-check"></i> حفظ</button>';
?>
<button type="reset" class="btn btn-inverse"><i class="fa fa-times"></i> إلغاء</button>
<?php
if($id == 0)
echo'<button type="button" id="backword" class="btn btn-second"><i class="fa fa-undo"></i> رجوع</button>';
else{
echo '<input type="hidden" name="university_offer_id_pk" value="'.$result['university_offer_id_pk'].'"/>
<button type="button" class="btn btn-second"><i class="fa fa-undo"></i> رجوع</button>';
}
?>
</div>
</div>
</form>
upload_image function, I put it in the Helper
function upload_image($file_name){
$CI =& get_instance();
$config['upload_path'] = 'public/uploads/images';
$config['allowed_types'] = 'gif|Gif|ico|ICO|jpg|JPG|jpeg|JPEG|BNG|png|PNG|bmp|BMP|WMV|wmv|MP3|mp3|FLV|flv|SWF|swf';
$config['max_size'] = '1024*8';
$config['encrypt_name']=true;
$CI->load->library('upload',$config);
if(! $CI->upload->do_upload($file_name)){
return false;
}else{
$datafile = $CI->upload->data();
thumb($datafile);
watermark($datafile);
return $datafile['file_name'];
}}

Jquery Multiple forms on a page not been submitted with conditional submit

So, I have multiple forms on a page and I am trying to submit them conditionally using the same button, for some reason, I cannot trigger the submit button. Below is my code.
$("#save_contact").on("click", function () {
var contact_type = $("#contact_type").val();
console.log(contact_type);
if (contact_type == 2) {
console.log("here");
$('#supplier_form').submit();
} else if (contact_type == 3) {
} else if (contact_type == 4) {
} else if (contact_type == 5) {
} else if (contact_type == 1) {
}
});
This is my form, at the moment I have only created 1 form.
<div id="supplier_div" class="form_to_save">
<form id="supplier_form" name="supplier_form" action="{{route('save_reception_contacts')}}">
<hr>
<h4>Supplier</h4>
<input type="hidden" name="_token" value="{{csrf_token()}}">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>Company</label>
<input type="text" name="company" id="company" />
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Notes</label>
<textarea name="notes" id="notes"></textarea>
</div>
</div>
</div>
<input type="hidden" name="contact_type_hidden">
<input type="hidden" name="user_type_hidden">
</form>
</div>
<div class="col-md-6">
<button type="button">Back</button>
<button type="button" class="save" id="save_contact">Save</button>
</div>
You have unclosed <hr> at
<form id="supplier_form" name="supplier_form" action="{{route('save_reception_contacts')}}">
<hr>
and an unclosed <div class="row">
<input type="hidden" name="_token" value="{{csrf_token()}}">
<div class="row">
otherwise I can't see anything wrong with submitting the form, you haven't provided relevant HTML that i could create the snippet.
You are creating a new variable and assigning the value of "contact_type" element. But I can not find this element in the HTML.
I have modified your code:
<div id="supplier_div" class="form_to_save">
<form id="supplier_form" name="supplier_form" action="{{route('save_reception_contacts')}}">
<hr></hr>
<h4>Supplier</h4>
<input type="hidden" name="_token" value="{{csrf_token()}}">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>Company</label>
<input type="text" name="company" id="company" />
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>contact_type</label>
<input type="text" name="contact_type" id="contact_type" />
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Notes</label>
<textarea name="notes" id="notes"></textarea>
</div>
</div>
</div>
</div>
<input type="hidden" name="contact_type_hidden">
<input type="hidden" name="user_type_hidden">
</form>
</div>
<div class="col-md-6">
<button type="button">Back</button>
<button type="button" class="save" id="save_contact">Save</button>
</div>
Note that there is now a new input "contact_type".
And here is the script, where you will need to uncomment in order to send the form.
$("#save_contact").on("click", function() {
var contact_type = $("#contact_type").val();
if (contact_type == 2) {
console.log("2");
//$('#supplier_form').submit();
} else if (contact_type == 3) {
console.log("3");
//$('#supplier_form').submit();
} else if (contact_type == 4) {
console.log("4");
//$('#supplier_form').submit();
} else if (contact_type == 5) {
console.log("5");
//$('#supplier_form').submit();
} else if (contact_type == 1) {
console.log("1");
//$('#supplier_form').submit();
}
});
I am assuming you want to send the same and only form, not differents one, as it seems to understand from the initial question.

Form posting does not work

I am having trouble to post a html form. I am posting one form and getting the post value to my variable and then I am post this form but this form is not posting.
HTML code:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" autocomplete="off">
<div class="widget-box">
<div class="widget-title"> <span class="icon"> <i class="icon-user"></i> </span>
<h5>Amc details</h5>
</div>
<div class="widget-content">
<div class="controls controls-row">
<div class="control-group span3">
<label for="normal" class="control-label">Installation Date<span style="color:red">*</span></label>
<div class="controls">
<input type="text" id="amc-ins-date" data-date="01-02-2016" name="amc-ins-date" data-date-format="dd-mm-yyyy" class="datepicker span12" placeholder="Enter installation date">
</div>
</div>
<div class="control-group span3">
<label for="normal" class="control-label">Start Date<span style="color:red">*</span></label>
<div class="controls">
<input type="text" id="amc-start-date" data-date="01-02-2016" name="amc-start-date" data-date-format="dd-mm-yyyy" placeholder="Enter amc start date" class="datepicker span12 ins-date">
</div>
</div>
<div class="control-group span3">
<label class="control-label">End Date<span style="color:red">*</span></label>
<div class="controls">
<input type="text" id="amc-end-date" data-date="01-02-2016" name="amc-end-date" data-date-format="dd-mm-yyyy" placeholder="Enter amc end date" class="datepicker span12 ins-date">
</div>
</div>
<div class="control-group span3">
<label class="control-label">Amount<span style="color:red">*</span></label>
<div class="controls">
<input type="text" id="amc-amount" name="amc-amount" class="span12" placeholder="Enter amc amount">
</div>
</div>
</div>
</div>
<div class="form-actions">
<input style="float:right" type="submit" name="amc-installation" class="btn btn-success" value="Save">
</div>
</form>
PHP code:
// i have submitted a form here and its posted
// installation details
$mc_serial = $_POST['mc-serial'];
$mc_model = $_POST['mc-model'];
$contract_type = $_POST['contract_type'];
$no_of_copies = $_POST['no-of-copies'];
$spare_part = join(",",$_POST['spare-part']);
$eng_name = $_POST['eng-name'];
$review = $_POST['review'];
// check if the machine already exits
if(IsMachine($mc_serial,$con)){
echo msgIsMachine();
exit();
}
if($contract_type == 'AMC'){
require './forms/amc.php'; // this is the html i have shown above
} elseif ($contract_type == 'ASC') {
require './forms/asc.php';
} elseif ($contract_type == '4C') {
require './forms/4c.php';
} elseif ($contract_type == 'RENTAL') {
require './forms/rental.php';
} elseif ($contract_type == 'WARRANTY') {
require './forms/warranty.php';
}
if(isset($_POST['amc-installation']) && !empty($_POST['amc-installation'])){
echo "posted";
var_dump($_POST);($_POST);
}
The output of var_dump is NULL. I don't get any problem.
You echo the second form (during the script which responds to the submission of the first one), but then immediately check for values returned from it within the same script execution. You have to wait for the user to post the form back before you can check the submitted values. This would be a separate postback, and therefore a separate execution context for the PHP.
So the code to check the values from the second form needs to be in a separate section (or file) which is triggered by the submission of the second form.
There's no $POST in PHP you should use $_POST instead :
if(isset($_POST['amc-installation']) && !empty($_POST['amc-installation'])){
echo "posted";
var_dump($_POST);
}
NOTE : You should place the var_dump($_POST); inside the if statement, so it will be trrigered just after the submit.
Hope this helps.
if(isset($_POST['amc-installation']) && !empty($_POST['amc-installation'])){
echo "posted";
var_dump($_POST);
}
You should use $_POST not $POST.
Hope this will helps you :)

Categories