Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

redirect() with payload?

Asked Modified Viewed 1,374 times
S
skpacman
S
My PHP-Fusion site: https://skpacman.live
  • Member, joined since
  • Contributed 150 posts on the community forums.
  • Started 25 threads in the forums
  • Started this discussions
asked
Member

I was wondering if you can pass $_POST data with a redirect, or do I have to find some other way to pass post data wile redirecting to an error page?
0 replies

5 posts

C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

Emm FUSION_SELF on the form action and or JavaScript return false.
0 replies
J
JoiNNN
J
JoiNNN 10
  • Veteran Member, joined since
  • Contributed 850 posts on the community forums.
  • Started 100 threads in the forums
answered
Veteran Member

So what is the context? A user pushed a Submit button -> if the inserted data is not good -> redirect to error page? If that's the case is not recommended.
Usually you should use $_GET to pass some data via a redirect, but if you really wanna do that just use $( "#form" ).submit();, as soon as a page loads that form will be submitted.
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Redirect apply with GET. There's no other way around it. :)

redirect(BASEDIR."test.php?error=1");


Test.php


if ($_GET['error'] == 1) {
echo 'success';
}
0 replies
S
skpacman
S
My PHP-Fusion site: https://skpacman.live
  • Member, joined since
  • Contributed 150 posts on the community forums.
  • Started 25 threads in the forums
  • Started this discussions
answered
Member

I found a good way to make it transparent. I have a lot of errors to collect on a rather large form for a client of mine and want to display them nicely, without cluttering the URL with $_GET.

session_start(); at the beginning of the file for the form. when processing the submitted form: for each error, set $_SESSION['error']['error_name'] = "error text"; then redirect() to self. unset($_SESSION['error']) at the end of the file.

if(isset($_SESSION['error'])){
foreach($_SESSION['error'] as $name => $error){
//Display error
}
}
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Nice trick! Using session. I'll experiment and put this tip into knowledge ! :)
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 5 posts
  • Votes 0 votes
  • Topic users 4 members

4 participants

C
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
C
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
S
S
My PHP-Fusion site: https://skpacman.live
  • Member, joined since
  • Contributed 150 posts on the community forums.
  • Started 25 threads in the forums
  • Started this discussions
J
J
JoiNNN 10
  • Veteran Member, joined since
  • Contributed 850 posts on the community forums.
  • Started 100 threads in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet