Forums

Chronoforms V5 how to save ip address into table

deltafidesign 10 Jun, 2014
Hi,

how can I save the IP address into DB table when user submit form with Chronoforms V5?

Thanks in advice.
GreyHead 10 Jun, 2014
Hi deltafidesign,

Use PHPMyAdmin to add a column named ip_address of type VARCHAR(16) to your table.

Add a Custom Code action before the DB Save action and add this code to it:
<?php
$form->data['ip_address'] = $_SERVER['REMOTE_ADDR'];
?>

This replicates the code from CFv4

Bob
deltafidesign 10 Jun, 2014
Hi Bob,

thanks for suggestion. Any way to see this been implemented in future releases of Chronoforms V5? I think I can wait for it instead of making an hack now.

Thanks in advice.
GreyHead 10 Jun, 2014
Hi deltafidesign,

Sorry, I have no idea what Max has on his 'to-do' list.

Bob
WanacomEngine 24 Jun, 2014
Hello GreyHead

I just tested your method to get Address IP and save it in DB but that don't work. All data are saved except "ip_address".

<?php
$form->data['ip_address'] = $_SERVER['REMOTE_ADDR'];
?>

I created the field "ip_address" in the DB and I put the PHP code in "Custom Code" in block "on submit" before the event "DB Save".

An idea ?

Thank you for advance.

++ Gilles
GreyHead 24 Jun, 2014
Hi deltafidesign,

Please add a Debugger action to see if the IP address is being added to the $form->data array

Bob
WanacomEngine 24 Jun, 2014
Thank you for your response GreyHead.

I put the debugger and the "ip_address" is there in the array but the save in the DB don't work.
All others field are filled in the DB.

++ Gilles
GreyHead 24 Jun, 2014
Hi deltafidesign,

OK, is the column name in the database exactly ip_address ?

Please copy and paste the debug output here.

Bob
WanacomEngine 24 Jun, 2014
Yes GreyHead

I verified and that's exactly the same name ...

++ Gilles
WanacomEngine 24 Jun, 2014
ChronoForm Version 5.0.0 (6 juin 2014)
WanacomEngine 24 Jun, 2014
Array
(
    [chronoform] => contact
    [event] => submit
    [message] => TEST 5
    [prenom] => John
    [nom] => Doe
    [telephone] => 
    [email] => john.doe@company.com
    [adresse] => 
    [code-postal] => 5000
    [localite] => Namur
    [button10] => Submit
    [contact] => 
    [ip_address] => 91.183.9.72
)
GreyHead 24 Jun, 2014
Hi Gilles,

There should be more debugger code than that I think? Is there not any output from the DB Save action?

Bob
WanacomEngine 24 Jun, 2014
This full debugger response on the print screen in attachment.
Thank you.
WanacomEngine 25 Jun, 2014
Hello GreyHead

There's not more info debugger code than that. I've sent you in MP the URL to test.
Have you had the opportunity staring to ?

Thank you for your help.

++ Gilles
GreyHead 28 Jun, 2014
Hi Gilles,

I checked the form - it looks to me as though the DB Save isn't working at all. Is it enabled.

Bob
adamo 16 Jul, 2014
I am having this same issue. I have a field in my database named "ipaddress". The database is not saving the value. Below is my debug log. This is only for CFV5 it works fine in V4. All fields are being saved except the ipaddress. I even tried to make a hidden field with the field name and id set to the db field name. The hidden field is being populated when I view the source but the field will not save to the db.


ipaddress 	varchar(255) 	utf8_general_ci 	



<input id="ipaddress" class="form-control A" type="hidden" value="10.5.0.8" name="ipaddress">



Array
(
    [option] => com_chronoforms5
    [chronoform] => NewStudentInquiryForm
    [event] => submit
    [new_student_name] => Adam
    [new_student_email] => Test@test.com
    [new_student_occupation] => I am a tester
    [new_student_personalinfo] => 
    [new_student_over18] => Yes
    [new_student_age_under18] => 
    [new_student_best_contact] => Email
    [new_student_how_find] => 
    [new_student_contact_reason] => 
    [new_student_prior_exp_rdo] => No
    [new_student_prior_exp_val] => 
    [new_student_more_info] =>     
    [ipaddress] => 10.5.0.8
    [button21] => Submit
    [id] => 6
)



Array
(
    [26] => Array
        (
            [DB Save] => Array
                (
                    [Queries] => Array
                        (
                            [0] => INSERT INTO `ptko3_chronoforms_data_NewStudentInquiryForm` (`new_student_name`, `new_student_email`, `new_student_occupation`, `new_student_personalinfo`, `new_student_over18`, `new_student_age_under18`, `new_student_best_contact`, `new_student_how_find`, `new_student_contact_reason`, `new_student_prior_exp_rdo`, `new_student_prior_exp_val`, `new_student_more_info`, `user_id`, `created`) values ('Adam', 'Test@test.com', 'I am a tester', '', 'Yes', '', 'Email', '', '', 'No', '', '', '0', '2014-07-16 21:36:09');
                        )
                )
        )
)
GreyHead 17 Jul, 2014
Hi adamo,

Have you added an ipaddress column to the database table?

Bob
Max_admin 17 Jul, 2014
In v5 you should click the "Delete cache" button under the forms manager after any manual changes to the database tables.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
adamo 17 Jul, 2014
Thanks Max,

About 5 minutes after I posted this, I did just that and the field was saved properly to the DB.

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