Hello GreyHead! First I wish to thank you a lot. Because I followed other topics and solved all of my problems.
Well, my question is: Could the form check if a value was already been submitted, before someones try to submit the same value?
The objective is to display an user-friendly error related to a key marked as "unique" in the DB.
So, if I fill all the fields and submit repeating the value, I'll get a SQL error message saying that value couldn't be repeated ("unique"). That's not user-friendly, and will not be record in DB.
Could you help me on this? Thank you!!
Well, my question is: Could the form check if a value was already been submitted, before someones try to submit the same value?
The objective is to display an user-friendly error related to a key marked as "unique" in the DB.
So, if I fill all the fields and submit repeating the value, I'll get a SQL error message saying that value couldn't be repeated ("unique"). That's not user-friendly, and will not be record in DB.
Could you help me on this? Thank you!!
Hi Aluizojr,
You can do this check in two ways.
a) In the browser using Ajax to check the database. There's an extract from The ChronoForms Book here explaining how to check an email address like this.
b) In the ServerSide validation - where you'd add the code to do a database lookup.
Ideally you'd add both for security :-)
Bob
You can do this check in two ways.
a) In the browser using Ajax to check the database. There's an extract from The ChronoForms Book here explaining how to check an email address like this.
b) In the ServerSide validation - where you'd add the code to do a database lookup.
Ideally you'd add both for security :-)
Bob
Oh thank you for all mr. Bob!
Well, due my small time to do that, I did a server-side validation with the help of another topics. I added a link to the user go back and correct the field, but I couldn't recover the Session back, all the fields were blank again.
Because my knowledge in PHP are pretty little, could you help me to do this?
Best regards,
Aluizojr.
Well, due my small time to do that, I did a server-side validation with the help of another topics. I added a link to the user go back and correct the field, but I couldn't recover the Session back, all the fields were blank again.
Because my knowledge in PHP are pretty little, could you help me to do this?
Best regards,
Aluizojr.
Hi Aluizojr,
Please set "Republish fields if error occured" to "Try to republish" on the Form Editor General tab.
Bob
Please set "Republish fields if error occured" to "Try to republish" on the Form Editor General tab.
Bob
Hi Bob,
I'd set "Republish fields if error occured" to "Try to republish", but I still get back with the fields blank.
The link has a javascript code: <a href="javascript:history.go(-1);">Clique aqui para corrigir o CPF. </a>
Thanks for the light speed answer!
I'd set "Republish fields if error occured" to "Try to republish", but I still get back with the fields blank.
The link has a javascript code: <a href="javascript:history.go(-1);">Clique aqui para corrigir o CPF. </a>
Thanks for the light speed answer!
Hi Aluizojr ,
Then don't use that link. That's relying on the browser to store the form info.
Where have you put it anyhow? If there is an error found in the serverside validation the form will be re-loaded without needing a link.
Bob
Then don't use that link. That's relying on the browser to store the form info.
Where have you put it anyhow? If there is an error found in the serverside validation the form will be re-loaded without needing a link.
Bob
Hi Bob! 🙂
There's the code in serverside validation. Also there's comments and some text in Portuguese, which is my language, sorry.
There's the code in serverside validation. Also there's comments and some text in Portuguese, which is my language, sorry.
<?php
$cpf = $_REQUEST['cpf'];
$sql = mysql_query("SELECT * FROM jos_chronoforms_Trabalhe_Conosco WHERE cpf = '$cpf'");
if(mysql_num_rows($sql) == 1){
//Aqui é se o CPF já constar no banco (below if CPF already exists)
echo '<h2 style="color: red">CPF já consta no cadastro.</h2><br/><a href="javascript:history.go(-1);">Clique aqui para corrigir o CPF. </a>';
}else{
//Aqui é se o CPF não estiver cadastrado (below if CPF don't exists, so everything's ok)
echo '<h3>Obrigado!</h3>
<h2>Seu cadastro foi efetuado com sucesso!</h2>';
}
?>
Hi Aluizojr,
Here's your code re-written in Joomla! code. This needs to go in the ServerSide validation box on the Validation tab or it will not work correctly.
Bob
Here's your code re-written in Joomla! code. This needs to go in the ServerSide validation box on the Validation tab or it will not work correctly.
<?php
$cpf = JRequest::getString('cpf', '', 'post');
$db =& JFactory::getDBO();
$query = "
SELECT COUNT(*)
FROM `#__chronoforms_Trabalhe_Conosco`
WHERE `cpf` = $db->quote($cpf) ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count ) {
//Aqui é se o CPF já constar no banco (below if CPF already exists)
return 'CPF já consta no cadastro.';
}
?>
Bob
This topic is locked and no more replies can be posted.