Hi,
I thought it would be good to allow users (via front end) to be able to click a button and have their email added to a default email template of my (the website owners) choosing. This is something that would be GREAT for my site since right now I'm having to do it on a per request basis manually.๐
PS: this would be some sort of php script right?
Daniel-
I thought it would be good to allow users (via front end) to be able to click a button and have their email added to a default email template of my (the website owners) choosing. This is something that would be GREAT for my site since right now I'm having to do it on a per request basis manually.๐
PS: this would be some sort of php script right?
Daniel-
Hi Daniel,
I don't quite understand this - can you give a bit more detail please?
Bob
I don't quite understand this - can you give a bit more detail please?
Bob
Uuuum, actually this should be in the Chrono Forms area...:P
Either way, here's an example:
On my website, users (buyers) submit requests for price quotes for various products and services. Other users (suppliers) then view these requests online or download them into a CSV file (all with chrono forms and connectivity I might add๐ ). I use the feature in Chrono Forms which allows the form to be emailed to various people to allow the suppliers to receive the requests in their email. Since right now I add and remove their emails by hand, I thought it would be nice to have the whole process automated. The suppliers would have an option to "subscribe" to a specific category (I have a separate form for each category) and their email would be added to the list of emails the forms data (on submit) will get sent to. They would also have the option to remove their email.
I'm guessing that would be really complicated lol...just an idea...
Daniel-
Either way, here's an example:
On my website, users (buyers) submit requests for price quotes for various products and services. Other users (suppliers) then view these requests online or download them into a CSV file (all with chrono forms and connectivity I might add๐ ). I use the feature in Chrono Forms which allows the form to be emailed to various people to allow the suppliers to receive the requests in their email. Since right now I add and remove their emails by hand, I thought it would be nice to have the whole process automated. The suppliers would have an option to "subscribe" to a specific category (I have a separate form for each category) and their email would be added to the list of emails the forms data (on submit) will get sent to. They would also have the option to remove their email.
I'm guessing that would be really complicated lol...just an idea...
Daniel-
Hi Daniel,
If you add a table with columns user_id & catagory_id, you can populate this with the subscriptions using a new ChronoForm and then use a database lookup to pull up the subscriptions for any category when you sent the emails.
A bit fiddly but not difficult.
Bob
If you add a table with columns user_id & catagory_id, you can populate this with the subscriptions using a new ChronoForm and then use a database lookup to pull up the subscriptions for any category when you sent the emails.
A bit fiddly but not difficult.
Bob
Great! I'll give it a shot and let you know how it goes.
PS: It's amazing how some things can have such simple solutions, but still unknown to us lol.
Daniel-
PS: It's amazing how some things can have such simple solutions, but still unknown to us lol.
Daniel-
Bob,
I understand the table and using a form to populate it, but how can I do the database look up?
The way I'm thinking it should work is...
-create a table with the user ID and category columns
-create a ChronoForm for users to "subscribe" to specific categories (in order to get submitted data emailed to them.)
-write a SELECT statement for each form in each category selecting the user emails according to the category name.
-create dynamic to emails for each form using the selected emails from the SQL statement.
Question 1: Where would I put the SELECT statement?
Question 2: How do I get the dynamic email box to use the selected emails?
Unless I'm completely wrong in my thinking...if so I would appreciate a brief example...lol๐
Thank you!
Daniel-
I understand the table and using a form to populate it, but how can I do the database look up?
The way I'm thinking it should work is...
-create a table with the user ID and category columns
-create a ChronoForm for users to "subscribe" to specific categories (in order to get submitted data emailed to them.)
-write a SELECT statement for each form in each category selecting the user emails according to the category name.
-create dynamic to emails for each form using the selected emails from the SQL statement.
Question 1: Where would I put the SELECT statement?
Question 2: How do I get the dynamic email box to use the selected emails?
Unless I'm completely wrong in my thinking...if so I would appreciate a brief example...lol๐
Thank you!
Daniel-
Hi Daniel,
Adding stuff to loads of forms makes for a lot of work.
The simplest way of doing this is probably to code a PHP file by hand and 'include' it into the onsubmit code for each of the forms.
This code would pick up the category info from the current form; do a database lookup to get a list of email names and addresses; then use a foreach loop to send each of them a standard email using the info from the form. None of this uses the ChronoForms stadard code though you might borrow some functions from ChronoForms.
I'm not an expert in SQL and would have to construct the code with a bit of trial and error but it would be something like
Bob
Adding stuff to loads of forms makes for a lot of work.
The simplest way of doing this is probably to code a PHP file by hand and 'include' it into the onsubmit code for each of the forms.
This code would pick up the category info from the current form; do a database lookup to get a list of email names and addresses; then use a foreach loop to send each of them a standard email using the info from the form. None of this uses the ChronoForms stadard code though you might borrow some functions from ChronoForms.
I'm not an expert in SQL and would have to construct the code with a bit of trial and error but it would be something like
SELECT `u.name`, `u.email`
FROM `#_users u`
INNER JOIN `#_signup_table s` ON `u.id` = `s.user_id`
WHERE `s.cat_id` = '$cat_id';
In this case $cat_id is taken from your current form.Bob
Hi Bob,
so here's what I have so far...I was hoping you could tell me if I'm even going in the right direction?
PS: I bought a license... 8) lol
Thanks,
Daniel-
so here's what I have so far...I was hoping you could tell me if I'm even going in the right direction?
<?php
mysql_connect("my host", "my username", "my password") or
die("Could not connect: " . mysql_error());
mysql_select_db("my database name");
$result = mysql_query("SELECT "user_email" FROM the table name will go here WHERE "category" = "Printing"");
$row = mysql_fetch_array($result, MYSQL_NUM));
$to = $row->user_email;
$subject = "A new lead has been submitted"
$message = "submitted form data goes here--not sure how though"
$header = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
foreach($row as $value)
mail($to, $subject, $message, $header);
mysql_free_result($result);
?>
PS: I bought a license... 8) lol
Thanks,
Daniel-
Hi Daniel,
Looks OK - I've tweaked it a bit - mainly to use the Joomal database code for better security.
If you put this in the OnSubmit after box then the submitted data will still be available in the $_REQUEST array and you can use this to build your message.
Bob
Looks OK - I've tweaked it a bit - mainly to use the Joomal database code for better security.
<?php
$message = "submitted form data goes here--not sure how though";
// some code here to build the message
$subject = "A new lead has been submitted";
$header = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$db =& JFactory::getDBO();
$query ="
SELECT `user_email`
FROM `#__the table name will go here`
WHERE `category` = 'Printing' ;
";
$db->setQuery($query);
$subscribers = $db->loadObjectList();
foreach ( $subscribers as $subscriber ) {
mail($subscriber->user_email, $subject, $message, $header);
}
?>
If you put this in the OnSubmit after box then the submitted data will still be available in the $_REQUEST array and you can use this to build your message.
Bob
Bob,
Thanks for the adjustments. Everything works great. I am really happy that I was able to get this to work so quickly and easily. I thought it was going to take a lot longer and be much more work๐.
Daniel-
Thanks for the adjustments. Everything works great. I am really happy that I was able to get this to work so quickly and easily. I thought it was going to take a lot longer and be much more work๐.
Daniel-
Bob,
Having a small problem...
I want to send a plain text email because outlook seems to have issues with reading the headers when using the mail() function, but I can't seem to get the syntax right for $_REQUEST to work.
Here's what I have right now...
I've tried different uses of quotes around $_REQUEST, but all give syntax errors. hope you can help.
Daniel-
Having a small problem...
I want to send a plain text email because outlook seems to have issues with reading the headers when using the mail() function, but I can't seem to get the syntax right for $_REQUEST to work.
Here's what I have right now...
<?php
$message = "
Contact Details
Name: $_REQUEST{First_name} $_REQUEST{Last_name}
Company name: $_REQUEST{Company_name}
Street address: $_REQUEST{Address}
City: $_REQUEST{City}
State: $_REQUEST{State}
Zip code: $_REQUEST{Zip_code}
Phone: $_REQUEST{Phone}
Other Phone: $_REQUEST{Other_phone}
Fax: $_REQUEST{Fax}
Email: $_REQUEST{Email}
Preferred contact method: $_REQUEST{Preferred_contact_method}
";
$subject = "A new lead has been submitted";
$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = 'FROM: info@ineedapricequote.com' . "\r\n";
$db =& JFactory::getDBO();
$query ="
SELECT `user_email`
FROM `jos_chronoforms_email_notification`
WHERE `category` = 'Printing' ;
";
$db->setQuery($query);
$subscribers = $db->loadObjectList();
foreach ( $subscribers as $subscriber ) {
mail($subscriber->user_email, $subject, $message, $headers);
}
?>
I've tried different uses of quotes around $_REQUEST, but all give syntax errors. hope you can help.
Daniel-
Hi,
You should use brackets, not curly braces when indexing arrays such as the $_REQUEST superglobal:
I'd recommend using J!1.5 codespace though; have a look at the JRequest class (http://api.joomla.org/Joomla-Framework/Environment/JRequest.html), and it's member functions (such as getVar() ).
You don't need to use the sprintf approach, but I personally think it makes the code easier to manage, as it separates the "template" from the data retrieval.
/Fredrik
You should use brackets, not curly braces when indexing arrays such as the $_REQUEST superglobal:
<?php
$message = "
Contact Details
Name: $_REQUEST[First_name] $_REQUEST[Last_name]
Company name: $_REQUEST[Company_name]
...
I'd recommend using J!1.5 codespace though; have a look at the JRequest class (http://api.joomla.org/Joomla-Framework/Environment/JRequest.html), and it's member functions (such as getVar() ).
You don't need to use the sprintf approach, but I personally think it makes the code easier to manage, as it separates the "template" from the data retrieval.
<?php
$message = sprintf("
Contact Details
Name: %s %s
Company name: %s
...",
JRequest::getString('First_name'),
JRequest::getString('Last_name'),
JRequest::getString('Company_name'),
...);
/Fredrik
Okay, quick question...
I have some forms that were not working with arrays so max gave me this code which goes in the onsubmit after box...
Now, I'm using a code that emails people when someone submits something and that goes in the onsubmit after box, but how should I put both sets of code in there?
Thanks,
Daniel-
I have some forms that were not working with arrays so max gave me this code which goes in the onsubmit after box...
<?php
$post =& JRequest::get('post');
if ( $paramsvalues->handlepostedarrays == 'Yes' ) {
foreach ( $post as $k => $v ) {
if ( is_array($post[$k]) ) {
JRequest::setVar($k, implode(", ", $post[$k]), 'post');
}
}
}
?>
Now, I'm using a code that emails people when someone submits something and that goes in the onsubmit after box, but how should I put both sets of code in there?
Thanks,
Daniel-
This topic is locked and no more replies can be posted.