I'm working a while now with this fantastic component, thanks for that!!
But I'm stuck with a problem which I am not able to fix.
I have a database named 'Koper-ID' which has one column 'Koper-ID'.
In my form I have a field named 'Koper-ID'.
When somebody is filling the form, the he puts into the field 'Koper-ID' should be checked within the database.
When the number is found in the database it's a success otherwise a fail. Both events have a simple message displayed.
In the 'on submit' section I made an 'Event switcher' with this code:
But no mather what I fill into the form, when I submit, I receive this:
$db = JFactory::getDbo(); $user = JFactory::getUser(); $query = $db→getQuery(true); $query= SELECT * FROM ‚hyn4b_Koper-ID‚ WHERE ‚Koper-ID’=.$user→get(„Koper-ID”).; $db→setQuery($query); $db→query(); $num_rows = $db→getNumRows(); if ($num_rows==0){ return „success”; }else{ return „fail”; }
What am I doing wrong?
Thanks in advance
But I'm stuck with a problem which I am not able to fix.
I have a database named 'Koper-ID' which has one column 'Koper-ID'.
In my form I have a field named 'Koper-ID'.
When somebody is filling the form, the he puts into the field 'Koper-ID' should be checked within the database.
When the number is found in the database it's a success otherwise a fail. Both events have a simple message displayed.
In the 'on submit' section I made an 'Event switcher' with this code:
$db = JFactory::getDbo();
$user = JFactory::getUser();
$query = $db->getQuery(true);
$query= SELECT * FROM `hyn4b_Koper-ID` WHERE 'Koper-ID'=.$user->get("Koper-ID").;
$db->setQuery($query);
$db->query();
$num_rows = $db->getNumRows();
if ($num_rows==0){return "success";}
else{return "fail";}
But no mather what I fill into the form, when I submit, I receive this:
$db = JFactory::getDbo(); $user = JFactory::getUser(); $query = $db→getQuery(true); $query= SELECT * FROM ‚hyn4b_Koper-ID‚ WHERE ‚Koper-ID’=.$user→get(„Koper-ID”).; $db→setQuery($query); $db→query(); $num_rows = $db→getNumRows(); if ($num_rows==0){ return „success”; }else{ return „fail”; }
What am I doing wrong?
Thanks in advance
Hi Tarrel,
The code should start with a PHP tag:
it also has some other mistakes, please try the following line instead of yours:
Alternatively you may use a "DB Read" action and use the conditions box to supply the field value!
Regards,
Max
The code should start with a PHP tag:
<?php
it also has some other mistakes, please try the following line instead of yours:
$query= "SELECT * FROM `hyn4b_Koper-ID` WHERE 'Koper-ID'='".$form->data("Koper-ID")."'";
Alternatively you may use a "DB Read" action and use the conditions box to supply the field value!
Regards,
Max
Hi Max,
Thanks for your quick reply. Maybe a using "DB Read" is better and more simple.
But I really know nothing about php, can you help with the conditions for this Koper-ID?
Thanks,
Tarrel
Thanks for your quick reply. Maybe a using "DB Read" is better and more simple.
But I really know nothing about php, can you help with the conditions for this Koper-ID?
Thanks,
Tarrel
I found an old message of yours on this forum, I used the code below and it works!
Thanks again!
Tarrel
<?php
return array("Koper-ID" => $form->data("Koper-ID")); ?>
Thanks again!
Tarrel
This topic is locked and no more replies can be posted.