Jump to content

Problem with checkbox and redirect


Juergen
 Share

Recommended Posts

hello @ all,

today I am struggeling with the following problem:

I have a checkbox field in a frontend user profile form.

<input name="delete" type="checkbox"> Delete profile image

If the user clicks the checkbox the profile image will be deleted after submission.

In the same form there is also a select drop down field for the language where the user can change his prefered language (German or English). After saving the user will be redirected to the english page with these lines of code.

if ($newuserlanguage) {//if language has changed            
                $languageurl = $page->localUrl($newuserlanguage); //get url for the new language           
                $session->redirect($languageurl); //redirect to the new page       
            }

This piece of code will be executed POST after submitting the form and works as expected. The user will be redirected to the new page after submit.

PROBLEM:

The redirect leads to that the checkbox value is always empty - in other words the checkbox status (checked or unchecked) will not be stored if a redirect is present.

If I remove the redirect code it will work as expected. I am not a PHP-Pro so I have no idea how I can fix this problem.

Has anyone an idea how to handle checkboxes and redirects. I dont want to store values in a cookie if there could be another way. I have tried it to store it in a session but I cannot get it to work.

Best regards Jürgen

Link to comment
Share on other sites

Sorry,

I dont need to save the checkbox status after redirect, because the redirect only take place if the form has no errors. So all correct data will be submitted via the form and will be stored in the database before the redirect starts. No need to keep the checkbox state alive.

[CLOSED]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...