I don´t want to let any user to add same value twice in a field and tries to use this server validation:
But it does not work. The form submit and the record get stored in database. If I try ...WHERE text12='a value that is in the database' it works. So I figuered out that I don´t get the submitted value from my form.
<?php
global $mainframe;
$database =& JFactory::getDBO();
$sql = "SELECT * FROM jos_chronoforms_mantorp WHERE text_12='JRequest::getVar('text_12')'";
$database->setQuery( $sql );
$result = $database->loadObject();
if($result){
return "Laget är redan registrerat!!!!";
}
?>
But it does not work. The form submit and the record get stored in database. If I try ...WHERE text12='a value that is in the database' it works. So I figuered out that I don´t get the submitted value from my form.
Hi Jelu,
I suspect that the code you have still returns an empty object so doesn't behave as you expected. Try this version:
Bob
Later: corrected the WHERE line and remove an uneccessary $sql= line
I suspect that the code you have still returns an empty object so doesn't behave as you expected. Try this version:
<?php
$db =& JFactory::getDBO();
$text =& JRequest::getString('text_12', '', 'post');
$sql = "
SELECT COUNT(*)
FROM #__chronoforms_mantorp
WHERE coupon = ".$db->quote($text).";";
if ( $debug ) echo "sql: ".print_r($sql, true)."<br /><br />";
$db->setQuery( $sql );
if ( $database->loadResult() != 0 ) {
return "Laget är redan registrerat!!!!";
}
?>
NB Not tested and may need debuggingBob
Later: corrected the WHERE line and remove an uneccessary $sql= line
I have tested it a little bit but it does not work. Should I have 2 sql-statemenets? And where does coupun come from? Perhaps I can change that to text_12?. It does Not work anyway I tested it. But when I use a named team eg eRace it works and I have an errormessage "Laget är redan registrerat!!!!". (Laget = The Team) Swedish.
I will test a little bit more but is there a way to see what value that the WHERE-claus use.
Sorry if this is newbie questions but I am still learning.
I found Debug feature and have this error:
Everything in Debug says it is OK otherwise.
I don´t know if this says anything for somebody, for me it does NOT.
Regards
JeLu
and P.S. Thanks for your Replay Geryhead D.S
I will test a little bit more but is there a way to see what value that the WHERE-claus use.
Sorry if this is newbie questions but I am still learning.
I found Debug feature and have this error:
Parse error: syntax error, unexpected T_STRING in /home/skrotbil/public_html/components/com_chronocontact/chronocontact.php(190) : eval()'d code on line 10
_POST: Array ( [text_4] => My Name[text_9] => Street 15 [text_10] => 11111 [text_7] => City [text_12] => eRace [text_0] => [email]my@online.com[/email] [chrono_verification] => mjYQe [hidden_0] => 0 [a634938e329905ee152959b08bf15458] => 1 )
Everything in Debug says it is OK otherwise.
I don´t know if this says anything for somebody, for me it does NOT.
Regards
JeLu
and P.S. Thanks for your Replay Geryhead D.S
Hi jelu,
Sorry, there were at least) two mistakes in there. I left in the second $sql = . . . and I missed some quotes off the end of the sql.
I've corrected it (I hope) and added a debug line to print out the sql for you.
Bob
Sorry, there were at least) two mistakes in there. I left in the second $sql = . . . and I missed some quotes off the end of the sql.
I've corrected it (I hope) and added a debug line to print out the sql for you.
Bob
Now it works like a charm and I have learned a new thing today :mrgreen:
Thank you very much
And A Very Merry Christmas to You Greyhead and also to Max for exellent suport at this forum.
And A Happy New Year 😀
Thank you very much
And A Very Merry Christmas to You Greyhead and also to Max for exellent suport at this forum.
And A Happy New Year 😀
I spook to soon. It works as long as you have a teamname without spaces. If I name it eRace it works but if I name it e Race it does not. I will try to test and will come back here if I find a sulotion.
Hi JeLu,
:-) sometime you get lucky!
There should be no problem with spaces in the name entered in the form.
Bob
:-) sometime you get lucky!
There should be no problem with spaces in the name entered in the form.
Bob
My site won't take a space in the name. Says only a-z. Location:
http://www.collectibles-museums.com/about-us/220-submit-a-site.html
Thank you.
http://www.collectibles-museums.com/about-us/220-submit-a-site.html
Thank you.
Hi jacks88,
True - the alpha validation allows [a-zA-Z] no spaces, you'll need to hack the regexp in the validation file if you need to allow spaces (or skip the validation).
Bob
True - the alpha validation allows [a-zA-Z] no spaces, you'll need to hack the regexp in the validation file if you need to allow spaces (or skip the validation).
Bob
This topic is locked and no more replies can be posted.