Forums

Search form / mail to ref

fmejia 14 Mar, 2009
First of all I want to thank you Bob and Max for all your assistance in my previous posts I am having an issue that I can't figure out how to resolve and I was wondering if you can give me a hand or point me to the right direction.

I have submited my form and saved it's information on a table... this information includes (in the same table) a "session ID" a "DPS number" and "approved", the "approved" field is a Yes/No value and the other two are numeric.

What I basically need is two things:

1. have the user enter the DPS number so that it will show the record found (a search form)... (I found another post about it but when I hit search it doesn't do anything)

2. with the record found I need to have a "mail to" link that creates an automatic email with the information from the table ("session ID","DPS number", etc). I don't want to use the phpmailer I need to use the "mail to" link so that the email opens in the user's default browser.

is this even possible with CC?
GreyHead 14 Mar, 2009
Hi fmejia,

If I understand this correclty the DPS number is unique so there will only be one result returned from the search?

If so you cna do this easily in ChronoForms (even with a short list it wuld be straightforward).

Create a form with just an input box for the DPS number and a submit button.

Write code in the OnSubmit after box to retrieve the other two values from the database and construct the mailto link something like this:
<?php
$db =& JFactory::getDBO();
$query = "
  SELECT * 
    FROM `#__some_table` 
    WHERE `psd` = ".$db->quote(JRequest::getString('psd', '', 'post');
$db->setQuery($query);
$data = $db->loadObject();
$mailto = "mailto:user@example.com?subject=some_subject&body=".$data->psd." ".$data->session_id." ".$data->approved;
echo "<a href=".$mailto." >Click here</a>";

Bob
fmejia 14 Mar, 2009
Thank you very much Bob... you totally got my point, I did what you told me to but when I hit the button to search it shows me the following error

Parse error: parse error in C:\xampp\htdocs\joomla15\components\com_chronocontact\chronocontact.php(533) : eval()'d code on line 6
GreyHead 14 Mar, 2009
Hi fmejia,

I missed a quote in here JRequest::getString('psd', '', 'post')

Corrected my original post

Bob
fmejia 14 Mar, 2009
that worked great, it gives me an option to click and creates the email🙂.... but when it creates the email the body is empty, I have a question in this line tough, the field in my table is called DSP not psd is psd part of the syntaxis or it should be DSP as my table field name?

WHERE `psd` = ".$db->quote(JRequest::getString('psd', '', 'post'));



if so, should I change it in this line too?

$mailto = "mailto:user@example.com?subject=some_subject&body=".$data->psd." ".$data->session_id." ".$data->approved;



I changed both and all psd to dsp and left it also the way you had it and none of them worked
GreyHead 14 Mar, 2009
Hi fmejia,

It should be your field name - I'm just getting my eyes and fingers crossed

Bob
fmejia 14 Mar, 2009
hahaha I was crossing them too🙂 but it didn't work Bob... is still empty like if its not finding the DPS in the table (which I made sure is there and tried several different DPS numbers). 😢
GreyHead 14 Mar, 2009
Hi fmejia,

[sendfb][/sendfb]
and a few sample db records would be useful.
Bob
fmejia 15 Mar, 2009
I sent the files on a PM can you confirm if you got them?🙂 than you :mrgreen:
GreyHead 15 Mar, 2009
Hi Fmejia,

Sorry, it was night time here - I received them this morning and have replied to you.

Bob
This topic is locked and no more replies can be posted.