Hello everyone,
I am trying to add survey participant into Limesurvey mysql db from Wordpress gravity forms plugin.
I want to allow participant to add themselves to Central participants database directly from Wordpress using forms from gravity forms.
Do you have any idea how can I do this? Here is my code so far:
The code is being integrated into wordpress theme's function.php
// Update limesurvey db along with gravity forms
add_action("gform_after_submission_4", "push_fields", 10, 2);
function push_fields($entry, $form){
$rfname = $entry["1"];
$rlname = $entry["2"];
$remail = $entry["4"];
$language = "en";
$blacklisted = "N";
$owner_uid = "1";
$created_by = "1";
$username ="username";
//$password = "somepass";
$password = "";
$host = "localhost";
$table = "ls_participants";
$con=mysqli_connect("$host","$username","$password","$table");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"INSERT INTO table (firstname, lastname, email, language, blacklisted, owner_uid, created_by) VALUES ('$rfname','$rlname', '$remail', '$language', '$blacklisted', '$owner_uid', '$created_by')");
}
//End updating lime
Unfortunately I get an error message:
Warning: mysqli_connect(): (28000/1045): Access denied for user 'username'@'localhost' (using password: NO) in /www/yourdomain.com/www/root/wp/wp-content/themes/currenttheme/functions.php on line 741
Failed to connect to MySQL: Access denied for user 'username'@'localhost' (using password: NO)
Possible issues: Lime survey has been installed using softaculous from cPanel, so I don't know whether this installer sets password or not on the mysql db, and if sets what is it. I've tried without pass but the error message above occurs, I've tried with my admin pass but it doesn't work either.
Do you guys have any ideas what could be the issue?
Some additional info:
www.gravityhelp.com/documentation/articl...rm_after_submission/
Thank you,
Grigor Dimitrov