Forms and databases
Author: M. Bogataj
Visited 4230,
Followers 3,
Shared 0
Can you send data created with e-mail form by e-mail and into database at the same time? How can I display data from database or fill form from database?
Posted on the
The Incomedia answer is no. see previous post:http://answers.websitex5.com/post/30908
I am sure that it is a simple thing to add a mail field but Incomedia seem to ignore such simple requests.
To display the information from your database you need a php script. Your provider should have some help or tutorials on this subject.
Hi Guy's,
It would be complicated to add a database to X5. When you upload to the server there is no way it could connect automatically to a server database. You could use an outside source inside of the program and configure the database yourself! I've used a Wordpress blog before today connected to X5 and that uses a database, but it had to be done separately!!
.
www.frankscybercafe.com
.
Hi Frank,
It's not about having a database in X5 as there are already connectors into mysql databases and this all works perfectly. In fact I am using Email Object Forms to connect to a number of mysql databases. Now if I wasn't using the data submission "Send data to a database" I could use the option "Send data by email" and I get to specifiy the email address it is sent to.
For example. I have a form that people fill if they have an enquiry. The information is sent to me as an email. Brilliant! So I get notified that people have an enquiry. On another site people fill in a form to making a holiday let booking. This also comes as an email. Wonderfull! However, if I choose "Send to a database" the details are sent to a mysql database which means I can store and retrieve that information and so show availability dates. Excellent! However, I don't know that someone has made a booking unless I keep looking at the mysql database. Fail!! Now if only the form could do both - send to a database and send email to an address of my choice. Voila! Both components are there. I can't be difficult to add both components on to a single form.
Ok, here's a workaround to this problem.
In E-mail Form Object I have created fields I use as a booking form for a holiday let. The visitor enters their details. When they click on Send, the data is sent (configured on the Send tab) to a mysql database. I have also chosen the option to send an email to the user with the details (include the collected data). Under Options Confirmation page after sending data: I have a page called Booking confirmation. IMPORTANT: This Confirmation page must only be accessed from this link and from nowhere else on the website.
In Sitemap Creation I click on my page called Booking confirmation. I then go to Page/Level properties and go to the expert tab. In the Custom Code, Before </HEAD>tag I have written the following script:
<?php
$from = "***";
$to = "***";
$subject = "Your Subject!";
$body = "This is text to tell what the message is about. You can put whatever you like";
if (mail($from,$to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
The from and to emails could be the same although it would be useful to create an email address specifically for sending these alerts. It has to be a valid email address.
So, when someone fills in the form, the information is sent to the database, an email is sent to me to tell this has happened. Obviously, any time the Booking confirmation page is accessed an email will be sent so it is important to make sure that it is hidden and not accessible from any page. It is also important to note that the email is only a notification that the someone submitted data to the database. It doesn't confirm that the data is in the database. I have a time stamp field in my database to match the date and time on the email.
I am sure that there is a very easy script that could be run on the server to send the email but as I am not great at creating scripts this was an easy option for me.
Thanks for that Tony very factual and interesting....
There must be some kind of notifier attached to your database or if not should be........
Tell you what I had a few years ago with V8!! I used a "Join my Newsletter" script and it was brilliant (I still have it somewhere I think??)
Now it was a standalone flash widget that I put in and connected it to my database, so I had an email list saved!
This is the part I liked..... It gave me a TXT page on my server with a specific name and when anyone joined my database it actually wrote to this TXT page and all I did was place a link to the page on my desktop and when clicked I copied everyones email address into my contacts!
So Tony it can be done, it's just a case of finding the right script or programmer ha ha!
You can create many email addresses using your server resources and look in there for FREE! scripts too.... I use my server control panel daily!!! (It also has autoresponders in the CP which I use for different sites instead of using X5 responders)
Here is where I purchase all my scripts and templates or any help with my programming needs. I've used these for years Tony well worth looking into especially the HTML5 section:
www.frankscybercafe.com/videostore
Hope this helps buddy....
.
www.frankscybercafe.com
.
Hi Frank,
Unfortunately, mysql doesn't have a trigger command built into it. But you are right, you can run a script on the server to find database updates. My provider provides me with access and information for me to run scripts against their server.
I am able to create a cron job (for those who don't know, this is like Windows Task Scheduler). This job runs whenever you like. so something like every 5 minutes. I could run this against the mysql log to check for changes and then run another script to send an email notification when a change takes place. This would ensure that notification would be given when the data actually goes into the database, although with my method above I can see when a visitor has filled in the information, just in case that information doesn't reach the database for some reason.
I am sad enough to be interested in creating the cron job and scripts myself! However, it's unlikely that most of the WSX5 would be able to or would want to do this. I still think that it would be better for Incomedia to add the option of having a email notification field.