Products search on the website - GET in HTML script - joomla

I created an online store with a search bar and "search" button separately.
How can I associate the search with products available on the website and by the "search" button?
I would like the search to take place in html script.
<form action="/" method="get">
<label for="search">Search in <?php echo home_url( '/' ); ?></label>
<input type="text" name="s" id="search" value="<?php the_search_query(); ?>" />
<input type="image" alt="Search" src="<?php bloginfo( 'template_url' ); ?>/images/search.png" />
</form>
I will be grateful for your help.

Related

Is it possible to call confirmation dialog from controller in codeigniterr?

I am using codeigniter of version 3. When I submit that form, i have to save the data of that form and a confirmation dialog with yes no option has to appear. If user clicks yes i have to redirect to a page and if use clicks to no i have to redirect to another page .How can i do that?
My View code:
<form id="saveRenewFirm" action="<?php echo base_url() ?>firm/saveFirmInfo" method="post" role="form">
<div class="row">
<div class="col-25">
<label> Name of the firm:</label>
</div>
<div class="col-75">
<input type="text" id="firm_name" name="firm_name" value="<?php echo $firmDetail->firm_name; ?>" <?php echo $status;?> style="width:50%;" />
</div>
</div></p>
<div class="row">
<div class="col-25">
<label>Category :</label>
</div>
<div class="col-75">
<input type="text" name="category" id="category" value="<?php echo $firmDetail->category; ?>" <?php echo $status;?> />
</div>
</div>
<div class="row">
<div class="col-25">
<label>Phone no :</label>
</div>
<div class="col-75">
<input type="text" name="phone_no" id="phone_no" value="<?php echo $firmDetail->phone; ?>" <?php echo $status;?> />
</div>
</div>
<div class="row">
<div class="col-25">
<label>Address :</label></div><div class="col-75"><input type="text" name="address" style="width:400px;" id="address" value="<?php echo $firmDetail->address; ?>" <?php echo $status;?> />
</div>
</div>
<button value="submit" name="action" type="submit" class="button" >Submit</button>
<?php echo form_hidden('renew_id',$firmDetail->renew_id);?>
</form>
My controller:
public function saveFirmInfo() {
$this->setValidation();
if($this->form_validation->run() == FALSE){
$this->index();
} else {
$data = array(
'firm_name' => $this->input->post('firm_name'),
'category' => $this->input->post(category),
'phone_no' => $this->input->post('phone_no'),
'address' => $this->input->post('address'));
$new_id = $this->renewed_firm_model->insert($data);
if($new_id>0){
$this->session->set_flashdata('success', 'Firm Detail submitted. Do you want to continue to payment?');
}else {
$this->session->set_flashdata('error', 'Error during processing, please try again...');
}
redirect('member/profile','refresh');
}
I want to bring a confirmation dialog instead of flash message to continue for payment . If user clicks yes then i have to redirect to payment page and if user clicks no another page has to be opened.
You can either do this 2 ways.
The first way, and the easiest given your current code would be to redirect to a page after the user submits the form that has a question and 2 options (yes or no).
The second way would be to submit the form via ajax and launch a modal on success function. This would be more intensive, and require substantial changes to your current save function.

Codeigniter url route can not pust right url

In this view, I want to post login data to controller but it didn't work and return this url: http://[::1]/ci/index.php/verifylogin
View:
<?php echo form_open('verifylogin'); ?>
<label for="username">Username:</label>
<input type="text" size="20" id="username" name="username"/>
<br/>
<label for="password">Password:</label>
<input type="password" size="20" id="passowrd" name="password"/>
<br/>
<input type="submit" value="Login"/>
I think below code help u.
<?php echo form_open(base_url('verifylogin')); ?>
verifylogin may be your method name so pass your controller name after.
ex. : base_url('controller_name/verifylogin')
Problem is about "base_url" settings, I set it $config['base_url'] = 'localhost:83/ci/';; and it worked.

Unresponsive form submit button in my CodeIgniter

I am trying to get to know CodeIgniter. I just couldn’t figure out what the problem with the code below is. However, when I click on the ‘submit’ button, nothing happens. I mean no record is inserted in the database table.
The php in the view is as follows.
<?php echo form_open('site/create'); ?>
<?php echo form_close();?>
<p>
<label for="title">Title</label>
<input type="text" name="title" id="title" />
</p>
<p>
<label for="content">Content</label>
<input type="text" name="content" id="content" />
</p>
<p>
<input type="submit" value="submit" />
</p>
Down goes the controller
<?php
class site extends CI_Controller
{
function index()
{
$this->load->view('options_view');
}
function create()
{
$rec=array(
'title' => $this->input->post('title'),
'content'=>$this->input->post('content')
);
$this->site_model->add_record($rec);
$this->index();
}
}
?>
And the model is as follows.
<?php
class site_model extends CI_Model
{
function get_records()
{
$query=$this->db->get('other');
return $query->result();
}
function add_record($rec)
{
$this->db->insert('other',$rec);
return;
}
function update_record($rec)
{
$this->db->where('id',2);
$this->db->update('other',$rec);
}
function delete_rec()
{
$this->db-delete();
}
}
?>
The form close has to be at the end:
<?php echo form_open('site/create'); ?>
<p>
<label for="title">Title</label>
<input type="text" name="title" id="title" />
</p>
<p>
<label for="content">Content</label>
<input type="text" name="content" id="content" />
</p>
<p>
<input type="submit" value="submit" />
</p>
<?php echo form_close();?>
It's better and easier to use the form library from codeigniter.
I believe you must be familiar with Html already to start using codeIgniter so this should be easy... Like all html forms you need to have an opening tag and a closing tag, what you have done is open and close the form at the top before the other elements. So as expected, the submit button wont do what you need it to do. The solution is to move
<?php echo form_close();?>
to the bottom so your code appears as such
<?php echo form_open('site/create'); ?>
<p>
<label for="title">Title</label>
<input type="text" name="title" id="title" />
</p>
<p>
<label for="content">Content</label>
<input type="text" name="content" id="content" />
</p>
<p>
<input type="submit" value="submit" />
</p>
<?php echo form_close();?>
All the best.

how to add multiple newsletter in one page with magento?

I want to add two newsletter in my site.One is in the footer and another one when i hover the topmenu.
I tried to add two newsletter in my page and it also worked but the problem is if i am adding another newsletter in my site then first newsletter is not working.I donot know what is the problem.
If anyone knows this, please help me out.
Thanks!
I put subscribe_footer.phtml in \app\design\frontend\default\mytheme\template\newsletter
<div class="row-7-col-1">
<h2><?php echo $this->__('newsletter') ?></h2>
<p><?php echo $this->__('Sign up to our newsletter and get exclusive deals you wont find anywhere else straight to your inbox!') ?></p>
<form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-footer-validate-detail-footer">
<input type="text" name="email" id="newsletter-footer" title="<?php echo $this->__('Sign up for our newsletter') ?>" class="input-text required-entry validate-email" />
<input type="submit" title="<?php echo $this->__('Submit') ?>" class="newsbtn" value="submit">
</form></div>
<script type="text/javascript">
//<![CDATA[
var newsletterSubscriberFormDetail = new VarienForm('newsletter-footer-validate-detail-footer');
//]]>
</script>
</div>
For another newsletter,I put subscribe.phtml in \app\design\frontend\default\mytheme\template\newsletter
<div class="row-7-col-1">
<h2><?php echo $this->__('newsletter') ?></h2>
<p><?php echo $this->__('Sign up to our newsletter and get exclusive deals you wont find anywhere else straight to your inbox!') ?></p>
<form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-validate-detail">
<input type="text" name="email" id="newsletter" class="field required-entry validate-email"/>
<input type="submit" title="<?php echo $this->__('Submit') ?>" class="newsbtn" value="submit">
</form></div>
<script type="text/javascript">
//<![CDATA[
var newsletterSubscriberFormDetail = new VarienForm('newsletter-validate-detail');
//]]>
</script>
</div>
please check and tell me why only one newsletter validation is working
<div class="block block-subscribe">
<form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-validate-detail_footer">
<input type="text" name="email" placeholder="Enter email" id="email_footer" class="input-text required-entry validate-email mytxt2" />
<button type="submit" title="<?php echo $this->__('Subscribe') ?>" class="button"><span><span><?php echo $this->__('Subscribe') ?></span></span></button>
</form>
<script type="text/javascript">
//<![CDATA[
var newsletterSubscriberFormDetail_footer = new VarienForm('newsletter-validate-detail_footer');
//]]>
</script>
Two Newsletters are working as well as validation also worked for me.
Copy the newsletter/subscribe file and rename to newsletter/subscribe2.
Then just rename the validation name on newsletter.

Submitting form action using javascript codeigniter

i have error for submitting form using javascript. the error said unknown column array. what is wrong with my array or maybe on my javascript.
this is my sample code.
<form action="">
<input type="text" name="name">
<input type="text" name="age">
<input type="button"onClick="this.form.action='<?php echo site_url('core')?>/'+'add_name';this.form.submit();" value="new"/>
</form>
WORKING WITHOUT JS
Try this:
<?php
$frmAttrs = array("id"=>"addFrm");
echo form_open('core/add_name', $frmAttrs);
?>
<input type="text" name="name">
<input type="text" name="age">
<!-- <input type="button" onClick="this.form.action='<?php //echo site_url('core/')?>'+'add_name';this.form.submit();" value="new"/> -->
<input type="button" id="submitFrm" onClick="this.form.submit();" value="new" />
</form>

Resources