desmogiec
Forum Replies Created
-
Oh, sorry for the late reply, I wasn’t home.
Here’s the gist for passing datas to mysql: https://gist.github.com/DesmoGiec/af5d13cdf5eef8857a64a1f0fe21659d
Here’s the one that makes the replacements: https://gist.github.com/DesmoGiec/1186f2f8570421c555677953ebb37942
Here’s the source: https://pastebin.com/JdDuyy4xNow, I’ve somehow managed to pass the values by using a css trick in order to get discordid, nick and event name to be written in a text input, not editable by users.
As said, replacement with php, which works just fine with visible fields, are broken when used in hidden fields.I’ve used the replacement in the past and always worked fine, it’s a recent issue.
Anyway, thanks for the help! ??Oh!
It’s working now!But now, my %replacements% are broken.
I logged the result for each data, and I get:
[04-May-2023 17:26:03 UTC] hidden-1: %nickname% [04-May-2023 17:26:03 UTC] hidden-5: %DiscordID%
Now, I’ve tried to assign a %replacement% to a text input field, and it is working.
I’m assuming that only with hidden fields there are problems..?
I’ve always used hidden fields though, and now that I’m looking into it I see that other forms are not replacing texts within hidden fields.. maybe an update caused that?
Can you check for me..?
Thanks for now, much appreciated ??- This reply was modified 1 year, 6 months ago by desmogiec.
Hello there!
I’m bringing up this discussion because I have a, I think, related issue.
I’ve added three “calculation” field, and I want to retrieve data from these.
So, I’ve added this in my php:$var1 = (string) $_POST['calculation-1']; $var2 = (string) $_POST['calculation-2']; $var3 = (string) $_POST['calculation-3'];
But it returns this
[03-May-2023 19:31:38 UTC] PHP Warning: Undefined array key "calculation-1" in /home/xkchthzl/public_html/wp-content/mu-plugins/form_to_mysql.php on line 121 [03-May-2023 19:31:38 UTC] PHP Warning: Undefined array key "calculation-2" in /home/xkchthzl/public_html/wp-content/mu-plugins/form_to_mysql.php on line 125 [03-May-2023 19:31:38 UTC] PHP Warning: Undefined array key "calculation-3" in /home/xkchthzl/public_html/wp-content/mu-plugins/form_to_mysql.php on line 129
What’s happening here?
- This reply was modified 1 year, 6 months ago by desmogiec.
Ok.
I just saw it.
In your code you wrote $servername = “locahost”.
Since I didn’t change that I didn’t notice until now..
Changed to locaLhost, now all is working like a charm.
Thanks for the help!
Much appreciated ??
I’ve tried some changes, the error “An error occurred while processing the form. Please try again” was occurring cause of the “echo” I’ added in the code.
Once I removed them, the error didn’t show up anymore.
Still, the entries aren’t written in the second database.
So I’ve created a new table “Student”, with “firstname” “email” columns, and used the code as is which you provided, but even doing that didn’t work.
Any hint on what I should check server side?
I have no clues ??
Thank you!
I’ve tried the code, but an error returns…
“An error occurred while processing the form. Please try again”
From your code I’ve added other vars from the form, but I’ve followed your code in order to add them.
<?php add_action( 'forminator_custom_form_submit_before_set_fields', function( $entry, $form_id, $field_data_array ){ $user = (string) $_POST['hidden-1']; $evento = (string) $_POST['text-2']; $hotlap = (string) $_POST['text-1']; $hotstint = (string) $_POST['text-3']; $discordID = (string) $_POST['hidden-5']; $datepost = (string) $_POST['hidden-3']; $timepost = (string) $_POST['hidden-4']; $servername = "locahost"; $username = "xxx"; $password = "xxx"; $dbname = "xxx"; //Connect to the DB https://www.w3schools.com/php/php_mysql_insert.asp, try { $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "INSERT INTO Times (User, Event, HotLap, HotStint, Data, Time, DiscordID ) VALUES (?,?,?,?,?,?,?)"; $stmt = $conn->prepare($sql); $stmt->execute([$user, $evento, $hotlap, $hotstint, $datepost, $timepost, $discordID]); echo "New record created successfully"; } catch(PDOException $e) { echo $sql . "<br>" . $e->getMessage(); // Add a validation in case of error } $conn = null; }, 10, 3);
I know that maybe is a “basic php” issue, I’ve tried to read your link but I didn’t get where I’m getting stuck at…
I’ve checked inside my web configuration, pdo in enabled with its module pdo_mysql, so I don’t think it’s a server issue.
I’ve also doublechecked my table and it’s ok, user and password are ok too, I already use them in a nodejs app in order to access the db so it’s not an access problem.
Dumb question, I’ve created a mu-plugin php file where I’ve inserted this code, is that right…. right?
Forum: Plugins
In reply to: [TablePress - Tables in WordPress made easy] Tables don’t sort outOh my…
copy/paste issue I think…
Sorry for that, and thanks for the support ??Forum: Plugins
In reply to: [TablePress - Tables in WordPress made easy] Tables don’t sort outOh, my bad, here it is
https://www.executiveproject.team/academy-live-leaderboard/Tabs are in the spoilers field
Ok, I got it.
The problem was that I’ve made the form loading in ajax.
Disabling it has solved the issue.
Now it’s working fine ??What if I want to use that even on ajax loading?
(I’ve been using ajax since some of our users reported that from iphone forms didn’t work properly, issues that didn’t come out when using ajax..)Big thanks for now ??
Ok, I noticed that [] are not to be used, so I have that portion of code working now.
let _form = $(‘#forminator-module-18041’);
if( _form.length ) {
[…]The second part of the code, still get no results at all
_form.find('#forminator-field-text-2').on('change', function(){ let _value = $(this).val(); if( _value ){ _form.find('#forminator-field-text-3').val( _value.replaceAll(' ','-') ); }
Am I using wrong ids?
- This reply was modified 3 years, 2 months ago by desmogiec.
Hello,
thanks for the reply!I’ve tried the second one but apparently doesn’t work.
Not sure if I’ve wrote the right ids<?php add_action( 'wp_footer', function(){ ?> <script> (function($){ $(function(){ let _form = $('#forminator-module-[18041]'); if( _form.length ){ _form.find('#forminator-field-text-2').on('change', function(){ let _value = $(this).val(); if( _value ){ _form.find('#forminator-field-text-3').val( _value.replaceAll(' ','-') ); } }); } }) })(window.jQuery); </script> <?php }, 21 );
I’ve found those ids by using the console in firefox.
For testing purpose I’ve made a specular input text to see if something happens, to be changed in hidden when it works.Stupid question, this is working “live”, right?
When I type in text-2, it should appear in text-3 with replaced spaces instantly..?Forum: Plugins
In reply to: [TablePress - Tables in WordPress made easy] Responsive Scroll doesn’t workHello Tobias,
well…
How can I say it.. It was my fault, I’ve mistyped the shortcode, but didn’t notice until now.Works perfectly, sorry to bother you!
Keep up with the amazing work!
Hello Dimitris.
That works like a charm!
I made a little mashup and got this:public function my_form_change_upload_dir( $form_id ) { $this->new_dir_id = $form_id; add_filter( 'upload_dir', array( $this, 'my_form_ad_formid_to_upload_dir' ) ); } /** * Hook into the upload_dir filter and change the path. * * @param array $param The upload dir parameters array. */ public function my_form_ad_formid_to_upload_dir( $param ) { $dir_name = $this->new_dir_id; $form = Forminator_API::get_form( $this->new_dir_id ); if ( $form instanceof Forminator_Custom_Form_Model ) { $dir_name = $form->raw->post_name; } $new_path = '/' . $dir_name . '/' . wp_get_current_user()->user_login; $param['path'] = $param['basedir'] . $new_path; $param['url'] = $param['baseurl'] . $new_path; return $param; }
So.. now I have a tree like this
uploads/"form name"/"user1" /"user2" [...]
I didn’t use an if statement to check if the user is logged in because the form itself is hidden to visitors.
Thanks for the amazing support!- This reply was modified 4 years, 9 months ago by desmogiec.
Ok, thank you. ??
Hello!
Yep, you’re right.
I was trying with a section title show/hidden, and with sections it shows everything.
It works using text fields instead, and I’m ok with this, I can use auto filling text fields as a workaround.Thank you!