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

How to check if a xml value is null in Flex?
Why overriding Doctrine_Record::save() give me a strict standard error in Symfony 1.2?
expanding a mysql JOIN query in PHP
Which PHP Framework is most closely cloned to ActiveRecord (RoR)
Different Image depending if user has already voted
Concurrency Problem
jQuery+AJAX delete anchor not working
How can open I unconditionally to open the open_basedir?
What's the reason for cookies mysteriously reappearing?
How can I generate a screenshot of a webpage using a server-side script?
MySQL - pass database field through PHP function before returning result
mysqli for php on Ubuntu 8.04 LAMP stack
How do I prevent an included PHP script from changing the Location URL?
How to use the php command line interactively?
How can I use and access an SQLite DB using PHP and Wamp Server?
Converting byte-stream into numeric data-type

Categories

HOME
qt
rust
magento2
apache-nifi
mpdf
cucumber
livecode
hdfs
website
google-search-console
sentry
fedora
pyresttest
eddystone
elastic-load-balancer
fasm
nsstring
responsivevoice
pm2
multi-step
global-variables
playframework-2.0
jaspersoft-studio
multiple-tables
cmake-gui
android-custom-view
activeadmin
backtracking
altium-designer
react-bootstrap-table
tsung
bitbake
fatfs
premake
rust-cargo
john-the-ripper
char-pointer
redgate
ms-solver-foundation
identify
eclipse-gmf
cloudera-quickstart-vm
flipkart
opal-framework
robust
yoast
moinmoin
nothing
lightning-workbench
cordova-ios
line-intersection
aurelia-fetch-client
email-forwarding
.when
degrees
openerp-6
ipywidgets
xmlbeans
dcount
spring-mongo
mathml
jtag
adp
powerpoint-2013
highlighting
mathnet
onepage-checkout
management-studio-express
ioexception
enunciate
msgpack
nette
textscan
erlog
fuseesb
mathematical-expressions
findersync
lifetime
zend-mail
berkeley-db-xml
distributed-r
network-printers
prism.js
stripe.net
cloo
autonumber
colon
void-pointers
aero
ui-design
cyrillic
ckeditor.net
daap
voice-recording
pageheap
mmc3
radscheduler
nsrangeexception
page-curl
azure-acs
ognl
turbine
eaccelerator
android-2.1-eclair
android-input-method
rtti
database-cloning

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