I am wondering if when a user submits our form and it saves to a database, whether it can automatically removed if its a duplicate.
Example:
Record 23: Test Name - testemail@testemail.com - 01234567890
x
x
x
x
x
x
x
x
x
x
Record 34: Test Name - testemail@testemail.com - 01234567890
The database or a script will then run through our table, see if "Test Name" is there and then delete the just posted record.
Example:
Record 23: Test Name - testemail@testemail.com - 01234567890
x
x
x
x
x
x
x
x
x
x
Record 34: Test Name - testemail@testemail.com - 01234567890
The database or a script will then run through our table, see if "Test Name" is there and then delete the just posted record.
Hi georges999,
You could do this with the Custom Serverside Validation action. Add a MySQL query to check the table and if the email is found end the form processing.
Bob
You could do this with the Custom Serverside Validation action. Add a MySQL query to check the table and if the email is found end the form processing.
Bob
Thank you for your reply, I have looked at this and not too clued on the whole php thing? would it be something along the lined of
column2 = email input column in this example
Should that work?
$db->query"INSERT INTO table_name (table,columns,go,here) values (column1, column2, column3, column4) WHERE NOT EXISTS (SELECT * FROM table_name WHERE column2 = $form->['email_input'])"
column2 = email input column in this example
Should that work?
Hi georges999,
I'd be very surprised if that worked, it looks as though you have cut and pasted odd bits of code together. Have you tested it?
This might be closer to what you need:
Bob
I'd be very surprised if that worked, it looks as though you have cut and pasted odd bits of code together. Have you tested it?
This might be closer to what you need:
<?php
$db =& JFactory::getDBO();
$query = "
SELECT COUNT(*)
FROM `#__table_name`
WHERE `column2` = '{$form->['email_input']}' ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count > 0 ) {
return false;
}
?>
Bob
To be honest, W3 schools and looking at a bit of other coding to try and piece something together.
Im not too bad when it comes to HTML and CSS but PHP is something that ive onley just dived into, so im still learning, Ill try yours and see what I get. Thank You
Im not too bad when it comes to HTML and CSS but PHP is something that ive onley just dived into, so im still learning, Ill try yours and see what I get. Thank You
Just another thing, the table is called "rgh_chronoforms_data_PrizeDraw" so would the
"FROM `#__table_name`"
be "FROM `#__chronoforms_data_PrizeDraw`" or "FROM `#__rgh_chronoforms_data_PrizeDraw`"
Not sure I have my events setup correctly either.. Do I put the DB save under the OnSuccess of the Custom Server Side Validation?
"FROM `#__table_name`"
be "FROM `#__chronoforms_data_PrizeDraw`" or "FROM `#__rgh_chronoforms_data_PrizeDraw`"
Not sure I have my events setup correctly either.. Do I put the DB save under the OnSuccess of the Custom Server Side Validation?

Cant yet get this working, is the above image correct? Also im unsure of whether I use the table prefix or not?
I cant get this working correctly😟 can you help me. I have the follwing code in the Custom Server Side Validation
I have added the DB save on success and stuff as follows. But still cant get it to work.
[[>> I updated the code from a later post : Greyhead <<]]
<?php
$db =& JFactory::getDBO();
$query = "
SELECT COUNT(*)
FROM `#__chronoforms_data_PrizeDraw`
WHERE `email_input` = '{$form->['email_input']}' ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count > 0 ) {
return false;
}
?>
I have added the DB save on success and stuff as follows. But still cant get it to work.

[[>> I updated the code from a later post : Greyhead <<]]
I am still having trouble with this. I think you edited my post greyhound but the code is still the same as what I have in Joomla.
Is my above image theoretically correct?
Is my above image theoretically correct?
The code and setup is correct, you still get duplicate saves ?
Regards,
Max
Regards,
Max
No its not saving and its redirecting to the on Fail URL. I have checked the Database table and the record im using to test is not in there.
What's the name of the field holding the email address in the form and in the database table ?
This is my DIV for the email field:
These are my headers for the database table:
<div class="ccms_form_element cfdiv_text" id="email_input1_container_div" style=""><label>Email</label><input maxlength="150" size="50%" class=" validate['required','email']" title="" type="text" value="" name="email_input" />
<div class="small-message">Please insert your email here.</div><div class="clear"></div><div id="error-message-email_input"></div></div>
These are my headers for the database table:
cf_id cf_uid cf_created cf_modified cf_created_by cf_modified_by cf_ipaddress cf_user_id name_input email_input mobile_input
Hi georges999,
Looking at this again this line
Bob
Looking at this again this line
WHERE `email_input` = '{$form->['email_input']}' ;
should probably be WHERE `email_input` = '{$form->data['email_input']}' ;
Bob
Thank you so much works a treat now!! You have been very helpful!
Beer bought!
This topic is locked and no more replies can be posted.