Is it possible to make a form for a postcode check?
Someone fill in a postcode, and after the search buttom, it wil reply yes or no, depending on which postcode.
Who can help me?
Someone fill in a postcode, and after the search buttom, it wil reply yes or no, depending on which postcode.
Who can help me?
Hi bensch,
Yes I'm sure this can be done but please say a bit more - what are you checking the postcode with to decide yes' or 'no'?'
Bob
Yes I'm sure this can be done but please say a bit more - what are you checking the postcode with to decide yes' or 'no'?'
Bob
Hello Bob,
A reply yes/no is enouch.
Postcode exists out of 4 digits and in about 300 postcodes the answer must be YES, the rest NO.
I hope you can help mee
Ben
A reply yes/no is enouch.
Postcode exists out of 4 digits and in about 300 postcodes the answer must be YES, the rest NO.
I hope you can help mee
Ben
Hi Bensch,
That's better than the UK PostCode table which is about 3 million entries!
Create a database table jos_postcodes with PostCode as a unique key and yes_no with the values Yes or No (or 1 & 0) as a second field.
Add a hidden field in your form with the name 'yes_no' (this lets CF know that the field exists even though it doesn't have a value yet).
In the OnSubmit After field write an sql query to check the table:
This will put the yes/no result into the field results just as though it had been entered into the form directly and you can use it in ChronoForms like any other results field.
Bob
PS This code hasn't been tested and may need debugging!
That's better than the UK PostCode table which is about 3 million entries!
Create a database table jos_postcodes with PostCode as a unique key and yes_no with the values Yes or No (or 1 & 0) as a second field.
Add a hidden field in your form with the name 'yes_no' (this lets CF know that the field exists even though it doesn't have a value yet).
In the OnSubmit After field write an sql query to check the table:
<?php
// load database access
$database =& JFactory::getDBO();
// get the postcode from the results
$postcode = JRequest::getString('postcode', '', 'post');
// look the post code up in the table
$sql = "
SELECT 'yes_no'
FROM #__postcodes
WHERE postcode = '$postcode';";
$database->setQuery( $sql );
if ( !$database->query() ) {
$mainframe->enqueuemessage( $database->getErrorMsg(). 'error');
}
// Write the result back into the for results
JRequest::setVar('yes_no', $database->loadResult(), 'post');
?>
This will put the yes/no result into the field results just as though it had been entered into the form directly and you can use it in ChronoForms like any other results field.
Bob
PS This code hasn't been tested and may need debugging!
This topic is locked and no more replies can be posted.