Buy Now
Sign in

Newbie. Where does it save the data?

SwingeyP , January 13 2021, 14:27
SwingeyP 7
January 13 2021, 14:27 #395659
HI. I have created a simple form CF7.
Where does the data actually get stored?
Can I define the table to store the data? How?
I read in another post about adding the savedata to the end of the form but I can't see how.
admin 32
January 15 2021, 03:57 #395674
you should add a "Save Data" action to the last page of the form (usually, unless you have other reasons to save the data earlier)
You should check the video tutorials from the link in my signature, it will show you how to use actions in general!
SwingeyP 7
January 15 2021, 14:41 #395681
Thanks for your response.
I have added the Save Data action and the External Database but I am still getting nowhere.
How do I setup the connection to the external database. In this case?
(26.41 KiB)
3 Downloads/Views
SwingeyP 7
January 15 2021, 17:01 #395683
I managed to fathom out database connection for 'read' with the following script applied to the HTML / RUN PHP actions.

// Get the Joomla user info
$user =& JFactory::getUser();
$name = '';
$email = '';
$readonly = '';
if ( $user->id > 0 ) {
$ID = $user->id;
$UserName = $user->username;
$readonly = "readonly='readonly'";

//Setup the LFT database connection (LFT_DATA not the Joomla instance)
$servername = "localhost";
$username = "LFT_DataUser";
$password = "[Ur1dirm3p]";
$dbname = "LFT_DATA";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);

$sql = "SELECT JoomlaID, SiteID, SiteName FROM SiteDetails"; // where Joomla UserID = SiteID or something like that.
$result = $conn->query($sql);

if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "Joomla id: " . $row["JoomlaID"]. "<br>". "Site Name: " . $row["SiteName"]. "<br>". "Site Id: " . $row["SiteID"]. "<br>";
} else {
echo "0 results";

It's a bit clumsy but OK for this test.
What I want to know now is can I assign the values to a field on the form. Ie create a text field called Site ID and have it display what is in $row["SiteID"]