Add search fields to search bar magento - php

A friend has asked me to look at a website they had built (long story short they fell out so site didnt get finished). There is a search bar on the left hand side with 3 different search categories
Ive found the code for it in form.mini.phtml
<div id="search1">
<h3>
SEARCH >>>
</h3>
<form id="search_mini_form" action="<?php echo $catalogSearchHelper->getResultUrl() ?>" method="get">
<div id="label_area">
<div id="label_area">
</div>
<input type="text" name="label" id="label" value="Label >>>" onclick="if(this.value!='Label >>>'){ } else { this.value =''; } "size="15" class="text2">
</div>
<div id="label_area">
<div id="label_area">
</div>
<input type="text" name="artist" id="artist" value="Artists >>>" onclick="if(this.value!='Artists >>>'){ } else { this.value =''; } "size="15" class="text2">
</div>
<div id="label_area">
<div id="label_area">
</div>
<input id="search" type="text" name="<?php echo $catalogSearchHelper->getQueryParamName() ?>" value="<?php echo $catalogSearchHelper->getEscapedQueryText() ?>" class="text2" maxlength="<?php echo $catalogSearchHelper->getMaxQueryLength();?>" /></div>
<div id="label_area"> <input type="image" src="<?php echo $this->getSkinUrl('images/go.jpg')?>" />
</div>
</form>
</div>
<!--<form id="search_mini_form" action="<?php echo $catalogSearchHelper->getResultUrl() ?>" method="get">
<div class="form-search">
<label for="search"><?php echo $this->__('Search:') ?></label>
<input id="search" type="text" name="<?php echo $catalogSearchHelper->getQueryParamName() ?>" value="<?php echo $catalogSearchHelper->getEscapedQueryText() ?>" class="input-text" maxlength="<?php echo $catalogSearchHelper->getMaxQueryLength();?>" />
<button type="submit" title="<?php echo $this->__('Search') ?>" class="button"><span><span><?php echo $this->__('Search') ?></span></span> </button>-->
<div id="search_autocomplete" class="search-autocomplete"></div>
<script type="text/javascript">
//<![CDATA[
var searchForm = new Varien.searchForm('search_mini_form', 'search', '<?php echo $this->__('Keywords>>>>>>>') ?>');
searchForm.initAutocomplete('<?php echo $catalogSearchHelper->getSuggestUrl() ?>', 'search_autocomplete');
//]]>
</script>
<!-- </div>
</form>-->
It looks like the developer has hashed this together, My question is, how do go about getting the label/artist fields working? sorry for the clumsiness, Im a novice with PhP, Ive tried a couple of approaches with no joy, thank you very much in advance :)

Related

Search function with php PDO and mysql

I'm Working on a Webshop for a School Project. The website is done and works as intended. Except for the Search function, which works but does something weird.
This is the Code from my Search Page
<?php
$stmt = $auth_user->runQuery("SELECT * FROM customer WHERE id=:id");
$stmt->execute(array(":id"=>$user_id));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
if(isset($_POST['btn-offer']))
{
try
{
$auth_user->redirect('offer.php');
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
?>
<form method="post" class="form-signin">
<div class="form-group">
<input type="text" class="form-control" name="search" placeholder="Enter an Item"/> <br />
<button type="Search" name="btn-search">
<i class="glyphicon glyphicon-open-file"></i> Search
</button>
<hr />
</div>
<?php
if(isset($error)){
foreach($error as $error){
?>
<div class="alert alert-danger">
<i class="glyphicon glyphicon-warning-sign"></i> <?php echo $error; ?>
</div>
<?php
}
}
else if(isset($_GET['search'])){
//$search_term = $_SESSION['search_term'];
$stmt = $user_req->runQuery("SELECT * FROM requests WHERE item LIKE :search");
$stmt->bindValue(":search","%".$_SESSION['search_term']."%");
$stmt->execute();
while($userReq=$stmt->fetch(PDO::FETCH_ASSOC)){
?><h6> Request ID </h6><?php echo($userReq['id']); ?> <br /><br /> <?php
?><h6> Requested Item </h6><?php echo($userReq['Item']); ?> <br /><br /> <?php
?><h6> Requested Price </h6><?php echo($userReq['price']); ?> <br /><br /> <?php
?><h6> Requested Quantity </h6><?php echo($userReq['quantity']); ?> <br /><br /> <?php
?><h6> Subject </h6><?php echo($userReq['subject']); ?> <br /><br /> <?php
?><h6> Description </h6><?php echo($userReq['descr']);
?>
<br />
<form action="offer.php" method="post" class="form-signin">
<input type="hidden" class="form-control" name="offer_id" value="<?php echo htmlspecialchars($userReq['id']); ?>"/> <br />
<input type="hidden" class="form-control" name="offer_item" value="<?php echo htmlspecialchars($userReq['Item']); ?>"/> <br />
<button type="Search" name="btn-offer">
<i class="glyphicon glyphicon-open-file"></i> Create Offer
</button>
</form>
<form action="all_offers.php" method="post" class="form-signin">
<input type="hidden" class="form-control" name="offer_id" value="<?php echo htmlspecialchars($userReq['id']); ?>"/> <br />
<button type="Search" name="btn-show">
<i class="glyphicon glyphicon-open-file"></i> Show Offers
</button>
</form>
<hr />
<?php
}
?>
<?php
}
?>
<br />
</form>
It displays everything as desired (all entries containing the search input).
But if i click on Create Offer, the hidden Input Types gets passed to my Search function just once. It wont update it with the new hidden variables if i click on another create offer button.
Offer.php file
<?php
if(isset($_POST['offer_id']))
{
$_SESSION['off_rid'] = $_POST['offer_id'];
$_SESSION['offer_item'] = $_POST['offer_item'];
}
?>
<h2 class="form-signin-heading">Create Offer for Request ID <?php echo htmlspecialchars($_SESSION['off_rid']); ?></h2><hr />
<form method="post" class="form-signin">
<input type="hidden" class="form-control" name="off_rid" value="<?php echo htmlspecialchars($_SESSION['off_rid']); ?>"/> <br />
<div class="form-group">
<label>Requested Item</label>
<input type="text" class="form-control" name="off_item" placeholder="<?php echo htmlspecialchars($_SESSION['offer_item']); ?>" value="<?php if(isset($error)){echo htmlspecialchars($_SESSION['offer_item']);}?>" readonly/>
</div>
<div class="form-group">
<input type="number" class="form-control" name="off_price" placeholder="Enter a Price" value="<?php if(isset($error)){echo $off_price;}?>" />
</div>
<div class="form-group">
<input type="number" class="form-control" name="off_quant" placeholder="Enter the Quantity" value="<?php if(isset($error)){echo $off_quant;}?>" />
</div>
<hr />
<div class="form-group">
<button type="submit" name="btn-createoffer">
<i class="glyphicon glyphicon-open-file"></i> Post Offer
</button>
</div>
<?php
if(isset($error)){
foreach($error as $error){
?>
<div class="alert alert-danger">
<i class="glyphicon glyphicon-warning-sign"></i> <?php echo $error; ?>
</div>
<?php
}
}
else if(isset($_GET['posted'])){
?>
<div class="alert alert-info">
<i class="glyphicon glyphicon-log-in"></i> Successfully submitted the Offer!
</div>
<?php
}
?>
<br />
</form>
If i search for every entry containing "ni" i get all the entries, the hidden Inputtypes are also correct.
If i click on create offer it should write the id and the item on the redirected Page but it only works once. if i go back and search another item it still displays the info from the first item i created an offer.
Can anybody point out what i'm doing wrong. I'm stuck on this Problem since a few days and just cant figure it out.
Thanks in advance

New line in email body after each field

I have the following code for a form in my site for reservations, but the email I'm getting has all the information of the form cramped up, and need to separate each field in a new line. Must be pretty easy for anyone, I'm just not good at code.
<form <?php echo !empty($post_options['id']) ? ' id="'.esc_attr($post_options['id']).'"' : ''; ?> data-formtype="<?php echo esc_attr($post_options['layout']); ?>" method="post" action="<?php echo esc_url($post_options['action'] ? $post_options['action'] : admin_url('admin-ajax.php')); ?>">
<?php jarvis_sc_form_show_fields($post_options['fields']); ?>
<div class="sc_form_info">
<div class="sc_form_item sc_form_field none"><input type="text" name="eventname" value="<?php echo (!empty($eventname)) ? esc_attr($eventname) : esc_html__('Any', 'jarvis'); ?>"></div>
<div class="sc_form_item sc_form_field label_over"><input type="text" name="username" placeholder="<?php esc_attr_e('Name', 'jarvis'); ?>"></div>
<div class="sc_form_item sc_form_field label_over"><input type="text" name="email" placeholder="<?php esc_attr_e('E-mail', 'jarvis'); ?>"></div>
<div class="sc_form_item sc_form_field label_over"><input type="number" name="number" min="1" max="1000" placeholder="<?php esc_attr_e('Number of people', 'jarvis'); ?>"></div>
</div>
<div class="sc_form_item sc_form_field date_time">
<div class="sc_form_item sc_form_item_date sc_form_field label_top">
<div class="sc_form_date_wrap icon-calendar-light">
<input placeholder="Date" class="js__datepicker" type="text" >
</div>
</div>
<div class="sc_form_item sc_form_item_time sc_form_field label_top">
<div class="sc_form_time_wrap icon-clock-empty">
<input placeholder="Time" class="js__timepicker" type="text" >
</div>
</div>
</div>
<div class="sc_form_item sc_form_button"><button class="sc_button sc_button_style_border gradient_bd hover"><?php esc_html_e('Book the table', 'jarvis'); ?></button></div>
<div class="result sc_infobox"></div>
</form>
Help is appreciated. ;)
add a <br> to add line breaks and start at a new line.
The HTML element produces a line break in text (carriage-return). It
is useful for writing a poem or an address, where the division of
lines is significant.
See the example below
<p>
Hi <br>
i <br>
am using multiple <br>
breaks <br>
</p>
Hope this helps!

magento newsletter subscription not working in magento 1.9.2.2

newsletter subscription not working in all pages. no newsletter confirmation mail send to customers
<div class="custom-subscribe">
<div class="title">
<span><?php echo $this->__('Newsletter') ?></span>
</div>
<form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-validate-detail">
<div class="form-subscribe-header">
<label for="newsletter"><?php echo $this->__('Sign Up for Our Newsletter:') ?></label>
</div>
<div class="input-box">
<input type="text" name="email" id="newsletter" title="<?php echo $this->__('Sign up for our newsletter') ?>" class="input-text required-entry validate-email form-control" />
</div>
<div class="actions">
<button type="submit" title="<?php echo $this->__('Subscribe') ?>" class="button"><span><span><?php echo $this->__('Subscribe') ?></span></span></button>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var newsletterSubscriberFormDetail = new VarienForm('newsletter-validate-detail');
//]]>
</script>
Please check below solutions:
In the Magento backend "System > Permissions > Variables" and "System > Permissions > Blocks"
Add newsletter/subscribe and refreshed cache.
More info:
There is a new check on the template directive, see Mage_Core_Model_Email_Template_Filter::blockDirective() line 176
if ($this->_permissionBlock->isTypeAllowed($blockParameters['type'])) {
$type = $blockParameters['type'];
$block = $layout->createBlock($type, null, $blockParameters);
}
Also check in system configuration as below:
System--->Advanced--->Advanced

Is it possible to have two actions fire on a form?

I understand you can't have two form elements. Here is my code below:
<form method="post" action="http://enews.thewebsite.com/q/Z_-p5ayQihZRLi2J67qUQ1aYrMDxK9jLRT" accept-charset="UTF-8">
<form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-validate-detail<?php echo $this->getAdditionalFormId(); ?>">
<input type="hidden" name="crvs" value="hj8DUzs3ID-3PTnoCEYQBZnP-ywiXCvSIopgDNLjkjI8uXaXEdhIDPteMAiIyBcEx_IEuTzvEtyZyY_6wp6uKKp5ljddRi7lbgSnjg9EM_tdAFCK1mCGHA7rrAZ8_zyk1GjuYtSzOIe60HJ-s5oV9doy1naJOZ-afDbkKAOxuVw"/>
<div class="form-subscribe">
<div class="form-subscribe-header">
<label for="newsletter"><?php echo $this->__('Sign Up to Receive Our Newsletters') ?></label>
</div>
<div class="form-subscribe-input"><input name="email" type="text" id="newsletter" value="<?php echo $this->__('Email Address') ?>" onclick="this.value=='<?php echo $this->__('Email Address') ?>'?this.value='':''" onblur="this.value==''?this.value='<?php echo $this->__('Email Address') ?>':''" class="input-text required-entry validate-email" /></div>
<div class="form-subscribe-submit"><button type="submit" class="button" title="<?php echo $this->__('Sign Up') ?>"><span><?php echo $this->__('Sign Up') ?></span></button></div>
</div>
</form></form>
<script type="text/javascript">
//<![CDATA[
var newsletterSubscriberFormDetail = new VarienForm('newsletter-validate-detail<?php echo $this->getAdditionalFormId(); ?>');
//]]>
</script>
The first post action is the one that is taking precedence. I would like them both to fire in the order they are now.
Is this possible?
Perhaps i can use some javascript like so:
<script type="text/javascript">
function doPreview()
{
form=document.getElementById('newsletter-validate-detail');
form.target='_blank';
form.action='thewebsite'; //first action
form.submit();
form.action='backto-other-action'; //second action???
form.target='';
}
</script>

How to add message after submitting form? PHP, Wordpress

I trying to make a feature, where the user recieves a message saying "Your changes have been saved" after the user has pressed "save changes". When the form is being submittet the page is just refreshed and not redirected to any other page.
I have tried several things but nothing seems to work. I am good at HTML but not PHP. I would love if any of you could help me out!
My code for my profile template is the folowing:
<div class="user-image">
<div class="bordered-image thick-border">
<?php echo get_avatar(ThemexUser::$data['user']['ID'], 200); ?>
</div>
<div class="user-image-uploader">
<form action="<?php echo themex_url(); ?>" enctype="multipart/form-data" method="POST">
<label for="avatar" class="button"><span class="button-icon upload"></span><?php _e('Skift billede','academy'); ?></label>
<input type="file" class="shifted" id="avatar" name="avatar" />
<input type="hidden" name="user_action" value="update_avatar" />
<input type="hidden" name="nonce" value="<?php echo wp_create_nonce(THEMEX_PREFIX.'nonce'); ?>" />
</form>
</div>
</div>
<div class="user-description">
<form action="<?php echo themex_url(); ?>" class="formatted-form" method="POST">
<div class="message">
<?php ThemexInterface::renderMessages(); ?>
</div>
<div class="sixcol column">
<div class="field-wrapper">
<input type="text" name="first_name" size="30" value="<?php echo ThemexUser::$data['user']['profile']['first_name']; ?>" placeholder="<?php _e('Fornavn','academy'); ?>" />
</div>
</div>
<div class="sixcol column last">
<div class="field-wrapper">
<input type="text" name="last_name" size="30" value="<?php echo ThemexUser::$data['user']['profile']['last_name']; ?>" placeholder="<?php _e('Efternavn','academy'); ?>" />
</div>
</div>
<div class="clear"></div>
<!-- ADRESSE -->
<?php if(!ThemexCore::checkOption('profile_signature')) { ?>
<div class="field-wrapper">
<input type="text" name="signature" value="<?php echo ThemexUser::$data['user']['profile']['signature']; ?>" placeholder="<?php _e('Adresse','academy'); ?>" />
</div>
<?php } ?>
<div class="user-fields">
<?php ThemexForm::renderData('profile', array(), ThemexUser::$data['user']['profile']); ?>
</div>
<?php } ?>
<span class="button-icon save"> </span><?php _e('Gem ændringer','academy'); ?>
<input type="hidden" name="user_action" value="update_profile" />
<input type="hidden" name="nonce" value="<?php echo wp_create_nonce(THEMEX_PREFIX.'nonce'); ?>" />
</form>
</div>
you are submitting to another url. So you can add something like the below to your functions file to display a message when the url is appended with msg. (you can account for multiple messages using the switch below, look it up) also you will need to add `?msg=yourmessagevariable' to your form action.
add_action('wp_print_scripts', 'notifcation', 100);
function notifcation () {
if($_GET['msg']) {
$message= sanitize_text_field($_GET['msg']);
switch($message) {
case 'reg-business':
$notehead= 'Please register first';
$msg= 'Please register your business before continuing';
break;
case 'nowvalid':
$notehead= "Congratulations";
$msg='You have successfully connected ';
break;
case 'Completed':
$notehead= 'Edited';
$msg='You have successfully edited your advert';
break;
}
?>
<section id="notification" class="notif notif-notice">
<h6 class="notif-title"><?php echo $notehead;?></h6>
<p><?php echo $msg; ?></p>
<div class="notif-controls">
Close
</div>
</section>
<script type="text/javascript">
jQuery(document).ready(function() {
setTimeout(function(){
jQuery('#notification').css('display', 'none');
},3000)
});
jQuery('.notif-close').click(function(e){
e.preventDefault();
jQuery(this).parent().parent().css('display', 'none');
})
</script>
<?php
}
}

Categories