Im using Joomla 1.5.22 and the related Chronoforms-version. I needed ages to learn a little bit how to validate an input server side, and it works.
I´m not native speaker and so its not easy for me to get through an php turtorial.
First question:
I want only to prevent bad code, nothing else and print nothing, if the code is bad, only strip it. The formfield I want to protect is {text_3}
$text_3 = JRequest::getString('text_3','', 'post');
Is this working?
Second question:
It would be easier to write code in the onsubmit field, I learn the code is (with php tags)
$input = JRequest::getString('some_input', 'default value', 'post');
JRequest::setVar('some_input', $input);
But I don´t understand: Do I have to define some of this fields?. Is "some-input" an example, "default value?". Do I have to name alle the fields like some input {text3} and default value?
Please can you show me the code with {text_3} Thanks a lot for your help.
Sorry, it sounds silly to you; but I tried very long to find somthing about. But I think its easy to make the basic safety code in the onsubmit code field?
I´m not native speaker and so its not easy for me to get through an php turtorial.
First question:
I want only to prevent bad code, nothing else and print nothing, if the code is bad, only strip it. The formfield I want to protect is {text_3}
$text_3 = JRequest::getString('text_3','', 'post');
Is this working?
Second question:
It would be easier to write code in the onsubmit field, I learn the code is (with php tags)
$input = JRequest::getString('some_input', 'default value', 'post');
JRequest::setVar('some_input', $input);
But I don´t understand: Do I have to define some of this fields?. Is "some-input" an example, "default value?". Do I have to name alle the fields like some input {text3} and default value?
Please can you show me the code with {text_3} Thanks a lot for your help.
Sorry, it sounds silly to you; but I tried very long to find somthing about. But I think its easy to make the basic safety code in the onsubmit code field?
Hi Remotec,
You can execute PHP in either the SeverSide Validation box or in one of the OnSubmit Code boxes.
The differences are (a) the point in the process when the code is executed -- the serverside validation is first and (b) the serverside validation box is designed as a function and it returns any value (other than false or an empty string) then the form processing will be stopped and the form will be re-displayed with the value returned as an error message.
This code by itself does nothing except set a value for the $text_3 variable:
This is the example that you want to use; it (a) sanitizes the result from the form and (b) makes sure that a value is set:
You need to replace 'some_input' with the name of an input from your form e.g. 'text_3' and replace 'default value' with a default value for the input if you want to set one, otherwise leave this blank.
The result will be like:
Bob
You can execute PHP in either the SeverSide Validation box or in one of the OnSubmit Code boxes.
The differences are (a) the point in the process when the code is executed -- the serverside validation is first and (b) the serverside validation box is designed as a function and it returns any value (other than false or an empty string) then the form processing will be stopped and the form will be re-displayed with the value returned as an error message.
This code by itself does nothing except set a value for the $text_3 variable:
$text_3 = JRequest::getString('text_3','', 'post');
This is the example that you want to use; it (a) sanitizes the result from the form and (b) makes sure that a value is set:
$input = JRequest::getString('some_input', 'default value', 'post');
JRequest::setVar('some_input', $input);
You need to replace 'some_input' with the name of an input from your form e.g. 'text_3' and replace 'default value' with a default value for the input if you want to set one, otherwise leave this blank.
The result will be like:
<?php
$input = JRequest::getString('text_3', '', 'post');
JRequest::setVar('text_3', $input);
?>
Bob
This topic is locked and no more replies can be posted.