Error
Unfortunately, you do not have the permission to view this article.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Check if checkbox checked after form submission

Check if checkbox checked after form submission 10 years 7 months ago #28644

Hey,

just want to know, if there is a possibility to check after form submission, if a checkbox was checked or not and perform an action with that result.
So, I want to check that with php in setting "Script called after form has been processed".


Thanks and regards

Daniel
The administrator has disabled public write access.

Check if checkbox checked after form submission 10 years 7 months ago #28657

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
You can insert the following script in "PHP Scripts called on form process" and it will check if any checkboxes were toggled.
if (count($_POST['form']['name_of_your_checkbox_group_field']) > 0){
perform action
}

PS: You will have to write your own code inside the if statement.
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.

Check if checkbox checked after form submission 10 years 7 months ago #28660

Thank you!!

Are you familiar with registering a user-account trough php? :blush:

I want to register an account if this checkbox is marked, but my code doesn't work.
I paste it below:

if (count($_POST['form']['WantRegister']) > 0){
$postData = JRequest::getVar('form');
jimport('joomla.user.helper');
 
$data = array(
"name"=>strip_tags($postData['FullName']),
"username"=>strip_tags($postData['Email']),
"password"=>strip_tags($postData['Password']),
"password2"=>strip_tags($postData['Password']),
"email"=>strip_tags($postData['Email']),
"block"=>0,
"groups"=>array("1","20")
);
 
$user = new JUser;
//Write to database
if(!$user->bind($data)) {
throw new Exception("Could not bind data. Error: " . $user->getError());
}
if (!$user->save()) {
//throw new Exception("Could not save user. Error: " . $user->getError());
echo "<br>Could not save user $name - " . $user->getError();
}
}
Last Edit: 10 years 7 months ago by payment225.
The administrator has disabled public write access.

Check if checkbox checked after form submission 10 years 7 months ago #28691

any thoughts on this? :blush:
The administrator has disabled public write access.

Check if checkbox checked after form submission 10 years 7 months ago #28694

Why not use the user registration plugin :)?
The administrator has disabled public write access.

Check if checkbox checked after form submission 10 years 7 months ago #28696

Because I want to build a form like:

1. Only Mailaddress-field is shown
2. There is a checkbox "You also want to register?"
-> checkbox not marked = only get newsletters, this is already working
3. If this checkbox is marked, there will be shown some more fields
4. with this info an account should be registered


So, in my opinion I have to create an own registration script, am I right? :)
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!