System print by default else message in php - php

I write these code for searching functionality in my project.
If user enter correct zip code it show one form if zip code is wrong it show some message which i write in else condition.
But by default is show the else message when user enter first time on page.
I want to show that(message which i write in else condition) message if user enter wrong zip code what i do?Any suggestion.
<small>Enter your zipcode to book our service</small>
<?php if($this->isAllowedZipcode=="Matched"){?>
<div class="row">
</div>
<?php } ?>
<?php } else
{ ?>
<div class="row">
<div class="col-sm-12 col-xs-12">
<p>Sorry but our services are not available in your area. We are working hard to cover as much area as we can. Thank you for using the system.</p>
<?php } ?>

Your code seems to be incorrect/incomplete, but as per your requirements, you could do it as follow:
<small>Enter your zipcode to book our service</small>
<?php if($this->isAllowedZipcode=="Matched"){ ?>
<div class="row">
//ZIPCODE MATCHED
</div>
<?php } else { ?>
<div class="row">
<div class="col-sm-12 col-xs-12">
<p>Sorry but our services are not available in your area. We are working hard to cover as much area as we can. Thank you for using the system.</p>
</div>
</div>
<?php } ?>

You can use elseif condition when you can test if the zip code is set, not only else.
<small>Enter your zipcode to book our service</small>
<?php if($this->isAllowedZipcode=="Matched"){?>
<div class="row">
</div>
<?php } elseif (isset($inputZipCode))
{ ?>
<div class="row">
<div class="col-sm-12 col-xs-12">
<p>Sorry but our services are not available in your area. We are working hard to cover as much area as we can. Thank you for using the system.</p>
<?php } ?>

Related

How to get two href with a condition in a button with php?

On my page, I have a button that links to a form.
Right now, it s linked to the English version even when the page is in Spanish.
Is it possible to add a condition like, if the English version => link to the English version form and if it s the Spanish version link to the Spanish form?
On this button <?php _e("Let's Grow", "mywebsite"); ?>
The spanish link is /aplicar/
Thank you in advance!
<div class="banner bg-purple">
<div class="container">
<div class="row d-flex align-items-center m-h-400 bg-img-building-blocks">
<div class="col-6"></div>
<div class="col-6">
<h3><?php _e("we believe your potential", "mywebsite"); ?><br/><?php _e("is good business", "mywebsite"); ?>.</h3>
<?php _e("Let's Grow", "mywebsite"); ?>
</div>
</div>
</div>
</div>
you can use get_locale():
<?php $link = get_locale() == 'es_ES' ? 'aplicar' : 'apply'; ?>
<?php _e("Let's Grow", "ascendus"); ?>

Codeigniter website PHP code theme not working to register & Login

I noticed that the login function and registration function is clearly not working and keeps giving an error, not giving the option to register nor login to the previous account registered on the database. Here is the code of login.php and user.php. The website uses CodeIgniter and that could be where the problem is I think.
Code for login.php in JustWallet 2.0.4\application\views\user:
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<div class="header-st mb-4">
<div class="container">
<div class="row">
<div class="col-md-12">
<h3>
<?php echo lang('core button sign_in') ?>
</h3>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row mt-5">
<div class="col-md-6 offset-md-3">
<div class="card">
<div class="card-body">
<?php echo form_open('', array('class'=>'')); ?>
<div class="form-group">
<label for="exampleInputEmail1"><?php echo lang('core button username_email'); ?></label>
<?php echo form_input(array('name'=>'username', 'id'=>'username', 'class'=>'form-control', 'placeholder'=>lang('core button enter_username'), 'maxlength'=>256)); ?>
</div>
<div class="form-group">
<label for="exampleInputPassword1"><?php echo lang('core button password'); ?></label>
<?php echo form_password(array('name'=>'password', 'id'=>'password', 'class'=>'form-control', 'placeholder'=>lang('core button enter_password'), 'maxlength'=>72, 'autocomplete'=>'off')); ?>
</div>
<div class="row">
<div class="col-md-12">
<div class="g-recaptcha" data-sitekey="<?php echo $this->settings->google_site_key; ?>"></div>
</div>
<div class="col-md-6">
<?php echo lang('core button forgot'); ?></br>
<?php echo lang('core button create'); ?>
</div>
<div class="col-md-6 text-right">
<button type="submit" class="btn btn-success"><?php echo lang('core button login'); ?></button>
</div>
</div>
<?php echo form_close(); ?>
</div>
</div>
</div>
</div>
</div>
I am getting these errors:
When using the correct login details from the database):
Invalid username or password
When trying to login to an account that already exists in the database:
Unable to access an error message corresponding to your field name Password.(_check_login)
When trying to register a new account (even though that is a new account to be created):
Your account could not be created at this time. Please try again.
Here is an image of the existing account in the database and the whole database:
Your <?php form_open() ?> still empty.
please provide your controller/method link inside form_open('controller/method',$parameter)
We couldn't see because u still don't provide your controller code.
My thoughts: You still have blank form_open. And Why are you use google recapthca?, I mean, you should check your "recaptcha" validation in your controller. This cannot be done until you have given the controller segment to this question.
UPDATED:
Hmm, I confused, why did u update a Plain text to your password here?
Next this is under your login callback method inside User.php:
Red circle explanation:
Your password supposed to be hashed programmatically when the user create their account. When you validate it using callback _check_login() here, It might be verified with hash comparation under password_verify() function inside your model. Why did you do that? (updating the password manually with the plain text ? :D)
And this is my biggest question to you.. Did you know about google recaptcha before? Google recaptcha only work in hosted site not localhost. Are you using your own program, I mean your own recaptcha's site /secret key? well.. it seems you don't own this program. When you try to validate with another site/secret's key, you cannot continue (see here https://www.google.com/recaptcha/about/), otherwise you have to delete every recaptcha validations in this program.

Hide a tab with no content on a Magento EE product page

I have successfully added a tab to my view.phtml page located at app/design/frontend/enterprise/aps/template/catalog/product.
I tried an if statement to hide it if the Specifications field is empty, i.e. no content. The issue is, it doesn't work. It still shows the tab even if there is no content.
My code is below at the end of post.
2 Questions:
Am I taking the correct approach? Basically, I am making a tab to have an Expert Review tab. I originally was going to use a cms block, but figured purposing the Specifications field was easier, for one, but also I could ignore the tab if no content
Can you please help ? :)
Thanks so much and here is my code and I attached a screenshot of the empty tabs.
<div class="wa-product-details-tab product-description">
<div class="wa-product-details-tab-heading product-desc-tab">
<div rel=".wa-product-tab-details-item-1" class="wa-product-heading-item wa-product-heading-item-1 wa-product-heading-item-active">
<span>Description</span>
</div>
<div rel=".wa-product-tab-details-item-2" class="wa-product-heading-item wa-product-heading-item-2">
<span>Specs</span>
</div>
<div rel=".wa-product-tab-details-item-3" id="review-form" class="wa-product-heading-item wa-product-heading-item-3">
<?php
$summaryData = Mage::getModel('review/review_summary')
->setStoreId(Mage::app()->getStore()->getId())
->load($_product->getId());
?>
<span >Reviews (<?php echo $summaryData->getReviewsCount();?>)</span>
</div>
<div rel=".wa-product-tab-details-item-4" class="wa-product-heading-item wa-product-heading-item-4">
<span>APS Advisor Review</span>
</div>
</div>
<div class="wa-product-tab-details product-desc">
<div style="display: block;" class="wa-product-tab-details-item wa-product-tab-details-item-1">
<?php echo $_product->getDescription(); ?>
</div>
<div style="display: none;" class="wa-product-tab-details-item wa-product-tab-details-item-2">
<p> <?php echo $this->getChildHtml('additional')?></p>
</div>
<div style="display: none;" class="wa-product-tab-details-item wa-product-tab-details-item-3">
<p>
<?php echo $this->getChildHtml('review_form') ?>
<?php echo $this->getChildHtml('product_additional_data_review') ?>
</p>
</div>
<div style="display: none;" class="wa-product-tab-details-item wa-product-tab-details-item-4">
<?php if ($_product->getSpecifications()); ?>
</div>
</div>
I am not sure if I understood your issue correctly. I am assuming that you want to hide the "APS Advisor Review" tab if there is no content in it.
For this you can use an if condition to check if $_product->getSpecifications() has any content, and show the tab title only if there is any content like this
<?php if( !empty($_product->getSpecifications()) ){ ?> <!-- displays the tab title only if the product has any specifications -->
<div rel=".wa-product-tab-details-item-4" class="wa-product-heading-item wa-product-heading-item-4">
<span>APS Advisor Review</span>
</div>
<php } ?>

$_POST is not working while sending Chtml data from view to controller. Its showing an empty array

I am new in Yii framework. I am using Chtml form to send data from view to controller and want to print the result and insert it to database. But in my case its showing an empty array. I couldn't able to understand where I am doing wrong. So please help me regarding this.
in controller
public function actionTest1()
{
$obj = new Pad;
if(isset($_POST))
print_r($_POST);// to check the desired result
if(isset($_POST['Pad']))
{
$obj->attributes=$_POST['Pad'];
if($obj->save()) // insert the data
$this->redirect(array('view','id'=>$obj->id));
}
}
in view
<?php echo CHtml::beginForm('','post',array('id'=>'step1Form')); ?>
<div class="stopPad">
<div class="floatLeft padTop5 marRight5">
<?php
echo CHtml::radioButton('stoppad',false,array('value'=>'Stop Pad after goal is reached'));
?>
</div>
<div class="currencyText padTop4 floatLeft">Stop Pad after goal is reached</div>
<div class="clearBoth"></div>
</div>
<div class="stopPad">
<div class="floatLeft padTop5 marRight5">
<?php
echo CHtml::radioButton('stoppad',false,array('value'=>'No limites'));
?>
</div>
<div class="currencyText padTop4 floatLeft">No limites</div>
<div class="clearBoth"></div>
</div>
<div class="nextText">
<?php echo CHtml::link('Next >',array('pad/test1'));?>
</div>
<?php echo CHtml::endForm(); ?>
Please help. Thanks in advance!
You are not submitting your form and of course $_POST will be empty. Line below is just a link:
<?php echo CHtml::link('Next >',array('pad/test1'));?>
You must change it to :
<?php echo CHtml::submitButton('Next >');?>
And also add an action to your form.
Updating the question with the changes I have done. Its redirect me to pad/test1 showing array() as result.
in controller
public function actionTest1()
{
$obj = new Pad;
if(isset($_POST))
CVarDumper::dump($_POST);// to check the desired result
if(isset($_POST['Pad']))
{
$obj->attributes=$_POST['Pad'];
if($obj->save()) // insert the data
echo "=====";
}
}
in view
<?php echo CHtml::beginForm( '','post'); ?>
<div class="stopPad">
<div class="floatLeft padTop5 marRight5">
<?php
echo CHtml::radioButton('stoppad',false,array('value'=>'Stop Pad after goal is reached'));
?>
</div>
<div class="currencyText padTop4 floatLeft">Stop Pad after goal is reached</div>
<div class="clearBoth"></div>
</div>
<div class="stopPad">
<div class="floatLeft padTop5 marRight5">
<?php
echo CHtml::radioButton('stoppad',false,array('value'=>'No limites'));
?>
</div>
<div class="currencyText padTop4 floatLeft">No limites</div>
<div class="clearBoth"></div>
</div>
<div class="nextText">
<?php echo CHtml::button('Next >', array('submit' => array('pad/test1'))); ?>
</div>
<?php echo CHtml::endForm(); ?>
A common source of confusion among new Yii users is how the 'safe' validator works, how it works with other validators, and why it's necessary in the first place. This article means to clear up this confusion, as well as explain the notion of Massive Assignment.
http://www.yiiframework.com/wiki/161/understanding-safe-validation-rules/

How to hide someparts in otherpage except home in codeigniter

I want to show a slider module on home page but hide it on rest of the site. Could anyone help me hide it. I am using HMVC in Codeigniter
<div class="col-xs-12 col-md-11 col-lg-11 navdiv" id="services_menu">
<?php
echo Modules::run('slider');
?>
</div>
You can try
<?php
if($this->router->fetch_class()=='home_controller_name'){
?>
<div class="col-xs-12 col-md-11 col-lg-11 navdiv" id="services_menu">
<?php
echo Modules::run('slider');
?>
</div>
<?php
}
?>
Create an seperate view for slider as slider.php. Put your following code into it
<div class="col-xs-12 col-md-11 col-lg-11 navdiv" id="services_menu">
<?php
echo Modules::run('slider');
?>
</div>
And while loading the Home page, Load this slider.php also like as follows :
$this->load->view("header.php");
$this->load->view("slider.php");
$this->load->view("home.php", $data);
$this->load->view("footer.php");
For other pages don't load the view slider.php.
Cheers!!

Categories