I am using joomla for my website
I have a function in my controller like this
function genericLogis(){
$model = &$this->getModel( JRequest::getCmd( 'view' ) );
$view = &$this->getView( JRequest::getCmd( 'view' ), 'html' );
$view->setModel($model, true);
$view->setLayout('logistical');
$view->logistical();
}
and in my model I have this
function getBasicos(){
JRequest::checkToken() or jexit( 'Invalid Token' );
$plantilla=1;
$db=& JFactory::getDBO();
$query= "SELECT *
FROM ".$db->nameQuote('#__accedo_materiales')."
WHERE ".$db->nameQuote('plantilla')."=".$db->quote($plantilla).";";
$db->setQuery( $query );
$materialesBasicos=$db->loadObjectList();
return $materialesBasicos;
}
and my view is a form like this
<?php defined('_JEXEC') or die('Restricted access'); ?>
<form action="index.php?option=<?php echo $option; ?>&view=<?php echo $view; ?>" method="post" name="adminForm">
.....
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="view" value="materiales" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
why when I click on the link to see this form I see Invalid Token!!
Related
I'm using form_open() for open form but form method is always showing get.
echo $this->request->getMethod() showing always get.
generated HTML is:
<form action="http://darkadmin.com/admin" method="post" accept-charset="utf-8">
<input type="hidden" name="_csrf" value="45435e3abd2d067883dacd6f62280fa7" />
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<input type="submit" value="Submit">
</form>
View:
<?php if(isset($validation)) { ?>
<?php echo $validation->listErrors(); ?>
<?php } ?>
<?php echo form_open(current_url().'admin'); ?>
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<input type="submit" value="Submit">
<?php echo form_close(); ?>
Controller:
<?php
namespace App\Controllers;
class Login extends BaseController
{
public function __construct(){
helper(['form', 'url']);
}
public function index()
{
$rules = [
'fname' => 'required',
'lname' => 'required'
];
echo $this->request->getMethod();
if($this->request->getMethod() == 'post' && $this->validate($rules)){
echo 'Success';
} else {
$this->data['validation'] = $this->validator;
}
return view($this->data['config']->theme.'login_view',$this->data);
}
}
How can I solve this problem? Please help me
this is my payment gateway page
<?php
$MERCHANT_KEY = "WTLZQBOb"; // add your id
$SALT = "6MyvUWk9pP"; // add your id
//$PAYU_BASE_URL = "https://test.payu.in";
$PAYU_BASE_URL = "https://secure.payu.in";
$action = '';
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
$posted = array();
$posted = array(
'key' => $MERCHANT_KEY,
'txnid' => $txnid,
'amount' => 1,
'firstname' => Auth::user()->name,
'email' => Auth::user()->email,
'productinfo' => 'PHP Project Subscribe',
'surl' => 'http://infohp.in/admin/callback-pay-u-money',
'furl' => 'http://infohp.in/admin/cancel-payment',
'service_provider' => 'payu_paisa',
);
if(empty($posted['txnid'])) {
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
}
else
{
$txnid = $posted['txnid'];
}
$hash = '';
$hashSequence = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10";
if(empty($posted['hash']) && sizeof($posted) > 0) {
$hashVarsSeq = explode('|', $hashSequence);
$hash_string = '';
foreach($hashVarsSeq as $hash_var) {
$hash_string .= isset($posted[$hash_var]) ? $posted[$hash_var] : '';
$hash_string .= '|';
}
$hash_string .= $SALT;
$hash = strtolower(hash('sha512', $hash_string));
$action = $PAYU_BASE_URL . '/_payment';
}
elseif(!empty($posted['hash']))
{
$hash = $posted['hash'];
$action = $PAYU_BASE_URL . '/_payment';
}
?>
<html>
<head>
<meta name="csrf-token" content="{{ csrf_token() }}">
<script>
var hash = '<?php echo $hash ?>';
function submitPayuForm() {
if(hash == '') {
return;
}
var payuForm = document.forms.payuForm;
payuForm.submit();
}
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
</script>
</head>
<body onload="submitPayuForm()">
Processing.....
<form action="<?php echo $action; ?>" method="post" name="payuForm"><br />
<input type="hidden" name="key" value="<?php echo $MERCHANT_KEY ?>" /><br />
<input type="hidden" name="hash" value="<?php echo $hash ?>"/><br />
<input type="hidden" name="txnid" value="<?php echo $txnid ?>" /><br />
<input type="hidden" name="amount" value="1" /><br />
<input type="hidden" name="firstname" id="firstname" value="<?=Auth::user()->name?>" /><br />
<input type="hidden" name="email" id="email" value="<?=Auth::user()->email?>" /><br />
<input type="hidden" name="productinfo" value="PHP Project Subscribe"><br />
<input type="hidden" name="surl" value="http://infohp.in/admin/callback-pay-u-money" /><br />
<input type="hidden" name="furl" value="http://infohp.in/admin/cancel-payment" /><br />
<input type="hidden" name="service_provider" value="payu_paisa" /><br />
<?php
if(!$hash) { ?>
<input type="submit" value="Submit" />
<?php } ?>
</form>
</body>
</html>
this is my URL link
<input type="hidden" name="surl" value="http://infohp.in/admin/callback-pay-u-money" /><br />
<input type="hidden" name="furl" value="http://infohp.in/admin/cancel-payment" /><br />
I am trying to use payUmoney in my laravel 7 project i am geting error
When I am trying to get payuMoney payment response status and redirect in my URL page in laravel 7, can you please help me how to resolve that problem. please help me as soon as possible .
except this route on app/Http/Middleware/VerifyCsrfToken.php (except array)
$except = ['*cancel-payment*'];
I am working on codeigniter and integrating the payumoney payment gateway. Here I have a registration form and there are various fields in the form Now what I am doing I want to add payumoney payment gateway but the problem is this when I add write the fname or amount from myself the it works fine but while I use $this->input->post('first_name') It shows error like follows
click to view the image (Here is the error in the image)
Here is the data variables
the values for data array
My code is follows :
function checkout() {
$this->load->config('payu');
$MERCHANT_KEY = $this->config->item('MERCHANT_KEY');
$SALT = $this->config->item('SALT');
$PAYU_BASE_URL = $this->config->item('PAYU_BASE_URL');
$action = '';
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
$udf1 = '';
$udf2 = '';
$udf3 = '';
$udf4 = '';
$udf5 = '';
$amount = $this->input->post('corporate_plan_rate');
$productinfo = 'test';
$fname = $this->input->post('user_name');
$email = $this->input->post('user_email');
$data = array(
'mkey' => $MERCHANT_KEY,
'tid' => $txnid,
'MERCHANT_KEY'=>$MERCHANT_KEY,
'txnid'=>$txnid,
'SALT'=>$SALT,
// 'hash' => $hash,
'amount' => $amount,
'pinfo' => $productinfo,
'name' => $fname,
'productinfo'=>$productinfo,
'mailid' => $email,
'phoneno' => '9646403748',
'udf1' => $udf1,
'udf2' => $udf2,
'udf3' => $udf3,
'udf4' => $udf4,
'udf5' => $udf5,
);
$this->load->view('payu/checkout.php', $data);
}
and here is my view page:
<html>
<head>
<!--<script src="//code.jquery.com/jquery.min.js"></script>-->
<script>
// $(function () {
// setTimeout(function () {
// $('form').submit();
// }, 2000)
// });
</script>
</head>
<body>
<?php
$hashstring = $MERCHANT_KEY . '|' . $txnid . '|' . $amount . '|' . $productinfo . '|' . $name . '|' . $mailid . '|' . $udf1 . '|' . $udf2 . '|' . $udf3 . '|' . $udf4 . '|' . $udf5 . '||||||' . $SALT;
$hash = strtolower(hash('sha512', $hashstring));
?>
<h2>PayU Form</h2>
<br/>
<form method="post" name="payuForm" action="https://test.payu.in/_payment">
<input name="key" type="hidden" value="<?php echo $mkey ?>" />
<input name="txnid" type="hidden" value="<?php echo $tid ?>" />
<input type="hidden" name="hash" value="<?php echo $hash ?>"/>
<input name="amount" type="hidden" value="<?php echo $amount; ?>" />
<input name="productinfo" type="hidden" value="<?php echo $pinfo; ?>">
<input type="hidden" name="service_provider" value="payu_paisa" size="64" />
<input name="udf1" type="hidden" value="">
<input name="udf2" type="hidden" value="">
<input name="udf3" type="hidden" value="">
<input name="udf4" type="hidden" value="">
<input name="udf5" type="hidden" value="">
<input name="firstname" id="firstname" type="hidden" value="<?php echo $name; ?>"/>
<input name="email" id="email" type="hidden" value='<?php echo $mailid; ?>'>
<input name="phone" type="hidden" value="<?php echo $phoneno; ?>">
<input name="surl" type="hidden" value="<?php echo base_url('payu/success'); ?>" size="64" />
<input name="furl" type="hidden" value="<?php echo base_url('payu/cancel'); ?>" size="64" />
<input name="curl" type="hidden" value="<?php echo base_url('payu/cancel'); ?>" />
<input type="submit" name="submit_form" value="Click Here for Payment" class="btn btn-info btn-block" >
</form>
</body>
</html>
Please help me find out the problem and resolve it out.. Thanx
Please completely replace your controller function with below codes
function checkout()
{
$MERCHANT_KEY = "enter your test merchant key here";
$SALT = "enter your test salt here";
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
$udf1 = '';
$udf2 = '';
$udf3 = '';
$udf4 = '';
$udf5 = '';
$amount = $this->input->post('corporate_plan_rate');
$productinfo = 'test_payment';
$fname = $this->input->post('user_name');
$email = $this->input->post('user_email');
$hashstring = $MERCHANT_KEY . '|' . $txnid . '|' . $amount . '|' . $productinfo . '|'. $fname . '|' . $email .'|'.$udf1.'|' .$udf2.'|' .$udf3.'|'.$udf4.'|'.$udf5.'||||||'. $SALT;
$hash = strtolower(hash('sha512', $hashstring));
$data = array(
'mkey' => $MERCHANT_KEY,
'tid' => $txnid,
'hash' => $hash,
'amount' => $amount,
'pinfo' => $productinfo,
'name' => $fname,
'productinfo'=>$productinfo,
'mailid' => $email,
'phoneno' => '9646403748',
);
$this->load->view('payu/checkout', $data);
}
Now completely replace your checkout view file with following codes
<html>
<head>
</head>
<body>
<h2>PayU Form</h2>
<br/>
<form method="post" name="payuForm" action="https://test.payu.in/_payment">
<input name="key" type="hidden" value="<?php echo $mkey ?>" />
<input name="txnid" type="hidden" value="<?php echo $tid ?>" />
<input type="hidden" name="hash" value="<?php echo $hash ?>"/>
<input name="amount" type="hidden" value="<?php echo $amount; ?>" />
<input name="productinfo" type="hidden" value="<?php echo $pinfo; ?>">
<input type="hidden" name="service_provider" value="payu_paisa" size="64" />
<input name="udf1" type="hidden" value="">
<input name="udf2" type="hidden" value="">
<input name="udf3" type="hidden" value="">
<input name="udf4" type="hidden" value="">
<input name="udf5" type="hidden" value="">
<input name="firstname" id="firstname" type="hidden" value="<?php echo $name; ?>"/>
<input name="email" id="email" type="hidden" value='<?php echo $mailid; ?>'>
<input name="phone" type="hidden" value="<?php echo $phoneno; ?>">
<input name="surl" type="hidden" value="<?php echo base_url('payu/success'); ?>" size="64" />
<input name="furl" type="hidden" value="<?php echo base_url('payu/cancel'); ?>" size="64" />
<input name="curl" type="hidden" value="<?php echo base_url('payu/cancel'); ?>" />
<input type="submit" name="submit_form" value="Click Here for Payment" class="btn btn-info btn-block" >
</form>
</body>
</html>
Please try above code without adding any of your own codes for testing and if the same error occurs comment below.
for somehow my codeigniter form validation is not showing on login page
given below is my login page in view
<div class="full_w">
<p>Food4U</p>
<?php echo validation_errors(); ?>
<?php echo form_open('staff/valid_login'); ?>
<label for="city">Select City</label>
<select name="city" class="text">
<option value="">Select City</option>
<?php echo $this->front_model->get_Fcities(); ?>
</select>
<label for="login">Username:</label>
<input id="login" name="username" class="text" />
<label for="pass">Password:</label>
<input id="pass" name="password" type="password" class="text" />
<div class="sep"></div>
<button type="submit" class="ok">Login</button>
<a class="button" href="">Change Password</a>
<?php echo form_close(); ?>
</form>
</div>
given below are functions in controller
function valid_login()
{
$this->form_validation->set_rules('city','City','required|trim|xss_clean|callback_validate_credentials');
$this->form_validation->set_rules('username','Username','required|trim|xss_clean|callback_validate_credentials');
$this->form_validation->set_rules('password','Password','required|trim');
if($this->form_validation->run())
{
$data = array(
'username' =>$this->input->post('username'),
'is_loggedin' => 1
);
$this->session->set_userdata($data);
redirect('staff/member');
}
else
{
$this->load->view("dashboard/login");
}
}
function member()
{
$row['content']=$this->load->view("dashboard/member",array(),true);
$this->load->view("dashboard/template", $row);
}
function validate_credentials()
{
if($this->staff_model->can_login())
{
return true;
}
else
{
$this->form_validation->set_message('validate_credentials','Incorrect Username or Password');
return false;
}
}
and my model function is
function can_login()
{
$this->db->where('DB_User_City',$this->input->post('city'));
$this->db->where('DB_User_Login',$this->input->post('username'));
$this->db->where('DB_User_Pass',$this->input->post('password'));
$query= $this->db->get('frp_db_user');
if($query->num_rows() == 1)
{
return true;
}
else
{
return false;
}
}
if user just click on submit button user should see a message and if user provide any single value incorrect then user must also see whats wrong with login so that user can provide correct information
inside your view for each fields you set validation blow its field or some where else
write like this codes to show your validation errors.
<div class="full_w">
<p>Food4U</p>
<?php echo validation_errors(); ?>
<?php echo form_open('staff/valid_login'); ?>
<label for="city">Select City</label>
<select name="city" class="text">
<option value="">Select City</option>
<?php echo $this->front_model->get_Fcities(); ?>
</select>
<br />
<?=form_error('city')?>
<br />
<label for="login">Username:</label>
<input id="login" name="username" class="text" />
<br />
<?=form_error('username')?>
<br />
<label for="pass">Password:</label>
<input id="pass" name="password" type="password" class="text" />
<br />
<?=form_error('password')?>
<br />
<div class="sep"></div>
<button type="submit" class="ok">Login</button>
<a class="button" href="">Change Password</a>
<?php echo form_close(); ?>
</form>
</div>
Your code seems like ok. Try this one
if($this->form_validation->run() == FALSE)
{
//redirect to your login form
}
else
{
//redirect to dashboard
}
please let me know if you face any problem.
I have this form:
<html>
<head>
<title>التسجيل</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
</head>
<body dir="rtl">
<?php echo validation_errors(); ?>
<?php echo form_open('form'); ?>
<h5>الإسم الكامل:</h5>
<input type="text" name="fullname" value="" size="50" />
<h5>الجوال:</h5>
<input type="text" name="mobile" value="" size="50" />
<h5>هاتف المنزل:</h5>
<input type="text" name="home" value="" size="50" />
<h5>اسم المستخدم:</h5>
<input type="text" name="username" value="" size="50" />
<h5>كلمة السر:</h5>
<input type="text" name="password" value="" size="50" />
<h5>اعادة كلمة السر:</h5>
<input type="text" name="cpassword" value="" size="50" />
<h5>الايميل:</h5>
<input type="text" name="email" value="" size="50" />
<br><br>
<div><input type="submit" value="التسجيل" /></div>
</form>
</body>
</html>
Please don't mind the arabic writings.The controller as follows:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Membership extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
}
public function index()
{
//Loads the login page which has a registration option
$this->load->view('login');
}
public function register()
{
$post = $this->input->post();
if($post)
{
//handle posted data
$fullname = $this->input->post('fullname');
$email = $this->input->post('email');
$mobile = $this->input->post('mobile');
$home = $this->input->post('home');
$username = $this->input->post('username');
$password = $this->input->post('password');
$confirmPassword = $this->input->post('cpassword');
$memberType = 'silver';
if ($this->form_validation->run() == FALSE)
{
$this->load->view('register');
}
else
{
$this->load->view('welcome_message');
}
}else{
$this->load->view('register');
}
}
}
Now when I click submit button on the form, it shows 404 and link in address bar is:
http://domain.com/index.php/form
Why is this happening? It should check if posted, then load x. if not load y.
Am a beginner in codeigniter so apologies.
As you have copied code from CI user guide :
form_open('form'); // here is a form action which is form class index function
just change it to :
form_open('membership/register');
which means :
form_open('location/to/sumbit/to');
that's it!
Change
<?php echo form_open('form'); ?>
To
<?php echo form_open('membership/register'); ?> // class/function