I am trying to save the entire form and data into a file. I am currently using the following code to save the file but would like to either save the entire form or save data to a template form and save it local. I have tried using a email template however the template is emailed to me but there is no data in the template.
<?PHP
###################### Set up the following variables ######################
# #
$filename = "registration_forms/$date.txt"; #CHMOD to 666
$forward = 0; # redirect? 1 : yes || 0 : no
$location = "thankyou.htm"; #set page to redirect to, if 1 is above
$now = date("H-i-s_m-d-y");
# #
##################### No need to edit below this line ######################
## set time up ##
$date = date ("l, F jS, Y");
$time = date ("h:i A");
## mail message ##
$msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n";
foreach ($_POST as $key => $value)
{
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
$msg .= "-----------\n\n";
$fp = fopen ("registration_forms/$now.txt", "a"); # w = write to the file only, create file if it does not exist, discard existing contents
if ($fp) {
fwrite ($fp, $msg);
fclose ($fp);
}
else {
$forward = 2;
}
if ($forward == 1) {
header ("Location:$location");
}
else if ($forward == 0) {
echo ("Thank you for submitting our form. We will get back to you as soon as possible.");
}
else {
"Error processing form. Please contact the webmaster";
}
?>
Hi,
Please put here your template code with your HTML code so we can see it
Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Hi jbourque, Bob,
If you are looking about the place where the new body of the email is generated then its just as Bob referenced, but you will have somethings added like the IP if you turned it on, If you need the original fresh code "just" made, its at line 114
$html_message = preg_replace($pattern, $replace, $emailbodytemplate);
but you must access it at line 117 so its complete!
all this at file chronocontact.php :side:
Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Bob and Max,
I tried to add a fopen to open a new text file then put in $html_message then close it but that did not work.
Do either of you have a thought about how I would take the template and even save it as a htm file just like the email that is being sent to me.
Max,
On line 117 I added the following:
$now = date("H-i-s_m-d-y");
$fp = fopen (registration_forms/$now.htm, "a");
if ($fp) {
fwrite ($fp, $html_message);
fclose ($fp);
}
However it's not doing anything. I would appreciate some help if anyone knows how to take $html_message and put it into a file
jbourque,
Yes, Bob is right, you have to include full physical path at these situations, did you try Bob's approach ?
Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Bob and Max you guys ROCK it is working pefectly. I removed the email submit code so it only saves the form.
Thanks for all the help. Now I am trying to retreive the lastname variable so I can have the forms saved in a name that makes since and is easy to retreive.
I will get a license from you guys thanks again for the help.
Try $_POST[$lastname] - that should give it to you. Bob
Later: yes, that should be $_POST['lastname'], sorry. I copied it from the wrong part of the code.<br><br>Post edited by: GreyHead, at: 2007/06/05 19:09
Thanks I had just got it I used
$lname = $_POST['lastname'];
Thanks again.
Joe
Bob,
Hope all is well.
I need your help again I have updated to the latest version to be able to use the authorize.net pluggin and now I have undone my changes which saves my files local instead of having them emailed.
I have gone through the new chronocontact.php but it appears to have been completely rewritten can you give me some advice to get the new version worked out.
Thanks
Joe
Bob,
I found it now I need to figure out why the authorize.net is not working😟
Joe
Hi Joe,
As you saw Max has completely re-written ChronoForms a couple of times now.
I've no idea why the authorise.net plugin isn't working - what problem are you seeing?
Bob
Bob,
If your still around could really use some help. I recently upgraded my client to Joomla 1.5 and upgraded Chronoform only to find out that I forgot about this problem and requirement. I am trying to do that same exact thing in the latest chronoform where I write the form to a flat file instead of emailing the form.
Any help with this would be awesome
Joe
Hi Joe,
What was your old code ? there should not be big differences
Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max,
I am looking to add the following but I see the info in the new chronocontact.php file
As you can see I replaced the email submit to generate a file instead of emailing the form.
* E-mail the results - 'Yes' custom
*/
if ( $debug) { echo "E-mail: 'Yes' custom<br />"; }
$body = $html_message;
}
}
if(!empty($rows[0]->onsubmitcode)){
eval( "?>".$rows[0]->onsubmitcode );
}
if(!empty($rows[0]->autogenerated)){
eval( "?>".$rows[0]->autogenerated );
}
$now = date("H-i-s_m-d-y");
$lname = $_POST['lastname'];
$fname = $_POST['firstname'];
$fp = fopen ("registration_forms/$lname+$fname+$formname.htm", "a");
if ( $fp ) {
// echo "File exists"; /* debug code to check we are inside the 'if' */
fwrite ($fp, $body);
fclose ($fp);
Thanks for you help
Joe
Hi Joe,
I see, you can place the same code in the "on submit after email" code box to do the same task but remove this block of code:
if(!empty($rows[0]->onsubmitcode)){
eval( "?>".$rows[0]->onsubmitcode );
}
if(!empty($rows[0]->autogenerated)){
eval( "?>".$rows[0]->autogenerated );
}
Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max,
Are you saying put the following code in the box within the form?
if ( $debug) { echo "E-mail: 'Yes' custom<br />"; }
$body = $html_message;
}
}
if(!empty($rows[0]->onsubmitcode)){
eval( "?>".$rows[0]->onsubmitcode );
}
if(!empty($rows[0]->autogenerated)){
eval( "?>".$rows[0]->autogenerated );
}
$now = date("H-i-s_m-d-y");
$lname = $_POST['lastname'];
$fname = $_POST['firstname'];
$fp = fopen ("registration_forms/$lname+$fname+$formname.htm", "a");
if ( $fp ) {
// echo "File exists"; /* debug code to check we are inside the 'if' */
fwrite ($fp, $body);
fclose ($fp);
Which file is the code you said I need to remove?
Joe
Max,
I am putting the following in the On Submit Code after sending email
<?PHP
$now = date("H-i-s_m-d-y");
$lname = $_POST['lastname'];
$fname = $_POST['firstname'];
$fp = fopen ("registration_forms/$lname+$fname+$formname.htm", "a");
if ( $fp ) {
// echo "File exists"; /* debug code to check we are inside the 'if' */
fwrite ($fp, $body);
fclose ($fp);
###################### Set up the following variables ######################
# #
$filename = "registration/output.txt"; #CHMOD to 666
$forward = 0; # redirect? 1 : yes || 0 : no
$location = "thankyou.htm"; #set page to redirect to, if 1 is above
$now = date("H-i-s_m-d-y");
# #
##################### No need to edit below this line ######################
## set time up ##
$date = date ("l, F jS, Y");
$time = date ("h:i A");
## mail message ##
$msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n";
foreach ($_POST as $key => $value)
{
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
$msg .= "-----------\n\n";
$fp = fopen (registration_forms/$now.txt, "a"); # w = write to the file only, create file if it does not exist, discard existing contents
if ($fp) {
fwrite ($fp, $msg);
fclose ($fp);
}
else {
$forward = 2;
}
if ($forward == 1) {
header ("Location:$location");
}
else if ($forward == 0) {
echo ("Thank you for submitting our form. ALL COACHES, please make sure online Background Check is also filled out. Link is on the Coaches Corner page.");
}
else {
"Error processing form. Please contact the webmaster";
}
?>
However I am getting an error unexpected end
Joe
Max,
I believe I got it I could not add it to the on submit box I had to add it to the mails.php. I added the following
if ( $email->enabled == "1" )
$body = $email_body;
$regtype = $formname;
$now = date("H-i-s_m-d-y");
$lname = $_POST['lastname'];
$fname = $_POST['firstname'];
$fp = fopen ("registration_forms/$lname+$fname+$subject.htm", "a");
if ( $fp ) {
// echo "File exists"; /* debug code to check we are inside the 'if' */
fwrite ($fp, $body);
fclose ($fp);
}
And remarked out the /* $email_sent = JUtility::sendMail($from, $fromname, $recipients, $subject, $email_body, $mode, $ccemails, $bccemails, $this_attachments, $replyto_email, $replyto_name ); */
It appears to be working.
Joe
Bob,
The problem I was facing was I could not get the $email_body variable to populate the file will this solve that problem?
Joe
Hi Joe,
No, my fixes are more general than that.
I'm not sure that ChronoForms keeps the email body any more. I have to take a look for someone else. If I find a better answer I'll report back.
Bob