Forums

"Find my adress" - using ChronoForms?

Nikoopriest 16 Apr, 2012
Hello everyone,

I'm in the middle of a project and I need your guidance.

I have lots of forms on my website for registering diffrent types of hardware, recently I decided to add a new function called "Find my adress" so I thought ChronoForms would come in handy.

I'll explain how I want it to work.

The form has two text boxes and one submit button. The text buttons are "street adress" and "postal code". From this, I want the form to send the information over to a database containing the adresses and postal codes and return with "Your adress was found in our database" or "Sorry, your adress was'nt found". I dont want it to fetch any data, only check if it's in the database.

Is this possible using ChronoForms?

Thanks in advance!

Best regards,
Anton
GreyHead 16 Apr, 2012
Hi Anton,

Yes you can do this. You can either do if after the form submits using Custom Code in the On Submit event. Or you can do it from the form before the form submits using Ajax to do the check.

Bob
Nikoopriest 17 Apr, 2012
Is it possible to load the data in to ChronoForm or is it better to setup a new Mysql database?

<?php
// Make a MySQL Connection
mysql_connect("localhost", "admin", "1admin") or die(mysql_error(Could not connect));
mysql_select_db("adresses") or die(mysql_error());

// Check if the database contains X adress
*MISSING CODE* 

// Check if the adress matches the postal code
*MISSING CODE*

// Print out the contents of the entry 
echo "Street: ".$row['street'];
echo " Is connected!;

?>


How do I tell the code to add the input from the forms? I need the code to scan the database for street adress and postal code. Which of the form values is used and how?

I really appreciate any help as I'm new to this kind of things..😶
GreyHead 17 Apr, 2012
Hi Nikoopriest,

I'm not sure what you mean by a new database? Presumably this data already exists somewhere?

I suggest that you use the Joomla! database code rather than writng your own.

The two missing pieces are both parts of a standard MySQL WHERE clause - check the MySQL manual for the syntax. You can add the form data from the $form->data array e.g. $form->data['street']


Bob
This topic is locked and no more replies can be posted.