php


how to pass an valuable with redirect?


I am having trouble trying to pass an valuable after the user fail the authorization. I would like to pass $error to the welcome controller but not sure how. Please help. Thank you.
private function _user_check()
{
//after form validation, I pass username and password to the model
$this->load->model('user_query');
$result=$this->user_query->query($this->input->post('username'),$this->
input->post('password'));
if($result)
{
redirect('main');
}else{
// I am not sure how to pass this error message to my welcome controller
$data['error']='Please check your username or password';
redirect('welcome');
}
}
In the redirect function, you aren't providing a full URL, so CI is going to treat the parameter as an URI segments to the controller.
Knowing this, you could have something like:
redirect('welcome/error/error_user_pass');
and have your "error_user_pass" that is being passed reference error constants defined in your CI project.
Maybe something like this in your application/config/constants.php file:
define('error_user_pass', 'incorrect user or password, please check yo self!');
Then in your 'welcome' controller having something like this:
class Welcome extends CI_Controller {
public function error(){
$errors = func_get_args();
foreach( $errors as $error ){
//echo error, or save it, or whatev
}
}
}

Related Links

CakePHP acting strange when running stored procedures
How do i get only the first part of the MIME type in PHP
PHP from root user, mkdir permission denied
How to keep the user logged on the entire web
I am using a Html form with PHP, how do i use $_GET to be assigned to a variable to be used in an IF statement in this specific code
Username with folder mod_rewrite
Best place in html page for php block when passing variables to javascript
Yii2 change active database based on controller
Grandchild theme Wordpress
date_default_timezone_set is producing weird results, what gives?
Running shell_exec() in background AND getting its output afterwards
how to handling non English chars with php
foreach multiple arrays and group values determined by an ID value on each array
Running Magento locally
Local laravel project redirects to live site
i want so send email from localhost in WAMP server using PHP [duplicate]

Categories

HOME
office365
vagrant
yii
xcode8.1
couchdb
enums
hid
tabs
vue-resource
azure-data-lake
sentry
save
scheduler
azure-graph-api
twitter-oauth
alljoyn
grocery-crud
django-rq
android-contacts
rpmbuild
checkout
multiple-tables
azure-machine-learning
pst
acl
ccavenue
npoi
pyspark-sql
javax.persistence
guice
dotcms
netbios
argv
fotorama
ms-media-foundation
devtools
keyboard-layout
subclassing
identify
mv
elastica
llvm-ir
assert
sbjson
swfupload
grails-spring-security
fiware-wirecloud
moinmoin
zend-form
docker-ucp
windows-media-player
icecast
photoswipe
sonicmq
phppgadmin
openstack-glance
extjs4.1
datediff
gnome-terminal
test-data
emacs25
prefetch
perl-data-structures
ogg
multi-touch
visual-studio-monaco
jsf-2.3
always-on-top
callouts
traversable
gravatar
flush
vim-plugin
ngcordova
green-threads
componentart
kefir.js
erlog
htmltidy
maven-shade-plugin
utf8-decode
jquery-mobile-flipswitch
ecos
angular-ui-select
hyperloglog
jack
principalcontext
lsa
eclim
postgres-xc
rikulo
handshake
system-requirements
xcode4.5
struts2-s2hibernate
uploading
vows
firefly-mv
botnet
airprint
nsconnection
printqueue
git-log
ixmldomdocument
browser-based
external-sorting
database-cloning
objectinstantiation
suggestbox
rootkit

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App