This is my simple index.php file
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
$this->title = 'Qwert';
?>
<?php $variable=1; //that variable
$f=ActiveForm::begin() ?>
<?php
if($variable==1){
echo Html::submitButton('First Button',['name'=>'b','value'=>1])."<br/>";
}else{
echo Html::submitButton('Second Button',['name'=>'b','value'=>2]);}
if(Yii::$app->request->post('b')==='1' ) {$variable=2;}
if(Yii::$app->request->post('b')==='2' ) {$variable=1;} ?>
<?php ActiveForm::end() ?>
So I want to after click First button it appears Second. Where is my mistake?
You should do the request in your controller and do some ajax in your view.
Keep bellow statements after $variable declaration.
if(Yii::$app->request->post('b')==='1' ) {$variable=2;}
if(Yii::$app->request->post('b')==='2' ) {$variable=1;}
Like
$variable=1;
if(Yii::$app->request->post('b')==='1' ) {$variable=2;}
if(Yii::$app->request->post('b')==='2' ) {$variable=1;}
In my Controller, I have to add return.
if(Yii::$app->request->post('b')==='1' ) {$variable=2; return $this->render('index');}
if(Yii::$app->request->post('b')==='2' ) {$variable=1;return $this->render('index');}
Related
I have this code
<?php
require '..\..\vendor\autoload.php';
define('SITE_URL','https://www.historietas.mx');
$paypal = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'my_redential',
'my_secret'
)
);
?>
And this code
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl(SITE_URL.'\controladores\pagos\pay.php?success=true')
->setCancelUrl(SITE_URL.'\controladores\pagos\pay.php?success=false');
$payment = new Payment();
$payment->setIntent('sale')
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions([$transaction]);
try{
$payment->create($paypal);
}
catch(PayPal\Exception\PayPalConnectionException $e){
echo $e->getCode();
echo $e->getData();
die($e);
}
echo $approvalUrl = $payment->getApprovalLink();
and I have this error:
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'ReturnUrl is not a fully qualified URL'
I don't know what's hapenning I am not using any special character in the url, why is giving me this error? please help, it is very frustating...
remove space from url from your Url that's the issue
include 'vendor/autoload.php';
$checkUrl = 'https://yourdomein.org/user/registration/paypaypal-ch?approval=true&plan=single&email=dghdg#dfgsdh.com&firstname=dshdh0d&lastname=dhdas';
try {
\PayPal\Validation\UrlValidator::validate($checkUrl);
echo "Validated\n";
} catch (InvalidArgumentException $ex) {
echo $ex->getMessage() . "\n";
}
Remove ?success=true
and
Remove ?success=false
from
$redirectUrls->setReturnUrl(SITE_URL.'\controladores\pagos\pay.php?success=true')
->setCancelUrl(SITE_URL.'\controladores\pagos\pay.php?success=false');
and it will wotk for sure.
I had the same problem and it was resolved by using
route('your route name '['parameter 1','parameter2'])
$redirectUrls->setReturnUrl(route('your route name '['parameter 1','parameter2']));
I have already properly defined the index to be POST-ed but still it says Undefined Index
Below is my code:
in the _form.php:
<?php echo $form->labelEx($model,'clientPackagedService_id'); ?>
<?php $client = Client::model()->findByPk(1);?>
<?php echo $form->dropDownList($model, 'clientPackagedService_id', CHtml::listData($client->clientPackagedservices(array('condition'=>'client_id='.$client->id.' AND booking_id IS NULL')),'id','packagedServiceInfo'),
array(
'disabled'=>'disabled',
'prompt'=>'Select Packaged Service...',
'ajax' => array( 'type'=>'POST', //request type
'url'=>CController::createUrl('updateMasseuseAndStationListPSID'), //url to call.
//This line-> 'data'=>array('clientPackagedService_id'=>'js:this.value', 'dt'=>'js:$("#Booking_date").val()', 'timeStart'=>'js:$("#Booking_timeStart").val()'),
'dataType'=>'json',
'success'=>'js:function(data) {
//alert(data.masseuse);
var mass="#'.CHtml::activeId($model, 'masseuse_id').'";
$(mass).html(data.masseuse);
$(mass).trigger("chosen:updated");
$(mass+"_chzn").css("width","300px");
$(mass+"_chzn > .chzn-drop").css("width","298px");
var station="#'.CHtml::activeId($model, 'station_id').'";
$(station).html(data.station);
$(station).trigger("chosen:updated");
$(station+"_chzn").css("width","300px");
$(station+"_chzn > .chzn-drop").css("width","298px");
//alert(data.timeEnd);
var timeEnd="#'.CHtml::activeId($model, 'timeEnd').'";
$(timeEnd).val(data.timeEnd);
}',
)
)
); ?>
in the controller.php:
public function actionUpdateMasseuseAndStationListPSID(){
$sid = Booking::getServices($_POST['clientPackagedService_id']);
....(codes to update Masseuse, Station, and TimeEnd.
}
in the model.php
public static function getServices($cpsID){
$psID = Yii::app()->db->createCommand('SELECT packagedService_id FROM client_packagedservice WHERE id='.$cpsID)->queryAll();
$sID = Yii::app()->db->createCommand('SELECT service_id FROM packaged_service WHERE id = '.$psID)->queryAll();
return $sID;
}
As you can see, I have already posted the appropriate name $_POST['clientPackagedService_id'] in the controller.php, but I still get the Error 500: Undefined index: clientPackagedService_id.
Did I do something wrong somewhere? Please advise. Thanks
I think problem is the data your are posting with ajax request. This is your data:
'data'=>array('clientPackagedService_id'=>'js:this.value', 'dt'=>'js:$("#Booking_date").val()', 'timeStart'=>'js:$("#Booking_timeStart").val()'),
Try to change it into this:
'data'=>array('clientPackagedService_id'=>'js:$(this).value', 'dt'=>'js:$("#Booking_date").val()', 'timeStart'=>'js:$("#Booking_timeStart").val()'),
Best way for debugging ajax request is to inspect browser's console. You can see ajax's posted data and realize your problem.
I'm using prestashop and i want to run a/b test. It means you test 2 different templates of your website in the same time as the traffic is redirected 50% to templateA and 50% to templateB.
I have to theme in my folder :
-ThemeA
-ThemeB
To run the test i need to access themeB via a different url form themeA.
So in the folder "/config" i modified the file setting.inc.php like this :
if(isset($_GET['ab']))
{
define('_THEME_NAME_', 'themeB');
}
else{
define('_THEME_NAME_', 'themeA');
}
Now i can reach themeb by typing : www.myshop.com/?ab
My problem is, whenever i click a link, the ?ab parameter is lost and it goes back to template A.
I found someone using another cms that resolved to problem using this code :
`$this->redirect(array('name')); `
But i don't know how to adapt it to prestashop and where should i put it.
Any help would be very appreciated.
Thanks
One quick workaround might be using session, if session is started ([http://sg3.php.net/manual/en/function.session-start.php][1]) before your "theme check".
// Page => watermelons.php
<?php
session_start();
if(isset($_GET['ab']) || isset($_SESSION['ab'])) {
$_SESSION['ab'] = 'themeB';
define('_THEME_NAME_', 'themeB');
} else{
define('_THEME_NAME_', 'themeA');
}
echo _THEME_NAME_;
?>
<br />go to coconuts
// Page => coconuts.php
<?php
session_start();
if(isset($_GET['ab']) || isset($_SESSION['ab'])) {
$_SESSION['ab'] = 'themeB';
define('_THEME_NAME_', 'themeB');
} else{
define('_THEME_NAME_', 'themeA');
}
echo _THEME_NAME_;
?>
<br />go to watermelons
I'm using an old version of symfony 1.0.11
slot('breadcrumbs');
include_component('page','breadcrumbs',array('past_pages'=>array(
'/module/action/parameter/value'=>'Home ')));
end_slot();
The problem with this code is that parameter and value do not get passed, so If i click on home i get /module/action but the parameters are not being passed. Any suggestions?
Thanks.
There is also a way automatically set the breadcrumbs this is in the breadcrumbs actions:
// Get the full path without get parameters
$fullPath = $request->getPathInfo();
// get the get parameters
$urlParams = $request->getGetParameters();
// set get parameters as string for url
$this->extend = "";
foreach ($urlParams as $key => $urlParam) {
if (empty($this->extend)) {
$this->extend = "?";
}
this->extend .= $key."=".$urlParam;
}
// Get the URL path and Explode by /
$paths = explode('/', $fullPath);;
$this->paths = $paths;
then in the component itself, you can foreach through the paths and if empty just continue. And always give the GET variables with the link if the browser has some.
Home
<?php foreach($paths as $path):
if(empty($path))
continue;
if(empty($fullPath))
$fullPath = "";
$fullPath .= "/".$path.$extend;
$path = str_replace("-", " ", $path);
?>
<?php if(key($paths->getRawValue()) != (count($paths)-1)): ?>
<?php echo ucwords($path); ?>
<?php else: ?>
<span><?php echo ucwords($path); ?></span>
<?php endif; ?>
This way you never have to set your breadcrumbs if you have a correct url structure.
the way i fixed it is
include_component('page','breadcrumbs',array('past_pages'=>array(
'/module/action?parameter=value'=>'Home ')));
I have this SOAP request that I use in php to get some information, but I can't seem to figure out how to do this in Xcode, hopefully somebody can point me in the right direction
<?php
$wsdl_url = "https://www.service.com/mySoapService.wsdl";
$client = new SoapClient($wsdl_url);
var_dump($client->__getFunctions());
try {
$userName = 'myUsername';
$password = 'myPassword';
$result = $client->retrieveUsage(new SoapParam(array("UserId" => $userName, "Password" => $password), "RetrieveUsageRequestType"));
print '<pre>';
print_r($result);
print '</pre>';
} catch (Exception $e) {
echo $e->getMessage();
}
?>
Add your WSDL, create stubs and off you go, start using your web-service from iOS apps.
http://sudzc.com/
I hope this is what you are looking for.
Enjoy!
I used http://easywsdl.com to generate classes. Works perfect with my WS