Forums

Show data not working?

jpc0480 04 Jul, 2008
I made a form earlier that was storing everything in the Show Data field. Recently I revised my form and made a new one from scratch. Now I've noticed that it is not posting this to the Show Data section. I have it set to email the results so it's not a big loss, just something I would like to see. Is there a setting that maybe I turned off? Or something I didn't set up?
GreyHead 04 Jul, 2008
Hi jpc0480,

You need to click the 'Create Data Table' link in the forms manager to create the code to save the form data in the database. If you don't see this but have 'Show Data' instead then something is wrong with your form . . .

Bob
jpc0480 04 Jul, 2008
You are right... Something must be wrong with the form. I clicked on Create Table up at the top, and it said that a table was already created for this form. When I click on Show Data I get nothing. Is there maybe a problem with MySQL or is there something I can edit? It seems as if this may be a database problem, although I'm not quite sure.
GreyHead 05 Jul, 2008
Hi jpc0480,

What is in the Autogenerated code box for this form? You did say that you created it from scratch - not by copying another form or restoring a backup?

Bob
jpc0480 05 Jul, 2008
Nothing... Might this be the problem?
GreyHead 05 Jul, 2008
Hi jpc0480,

Yes, check out the form id - the second column in the Forms Manager and see if you have a ..._chronoforms_... table in the database that ends with the id. If so, and it's not needed, you can delete the table and the 'Create Table' link should show up again for the form.

Bob
jpc0480 05 Jul, 2008
OK... I backed up the form, deleted it, and then restored. When I restored the form I had an option to create the table. I selected it and confirmed my fields. Now I have some code in the auto generated tab. However I'm still not showing anything in the show data field. Here is the auto generated code. Hopefully we can figure this out. Thanks for your help.
<?php 
	$database =& JFactory::getDBO();
	srand((double)microtime()*10000);
	$inum	=	"I" . substr(base64_encode(md5(rand())), 0, 16);
	
$database->setQuery( "INSERT INTO #__chronoforms_2 
VALUES  (
'' ,
 '".$inum."',
'". date('Y-m-d')." - ".date("H:i:s")."',
 '".$_SERVER['REMOTE_ADDR']."' ,
 '".JRequest::getVar('name','', 'post', 'string', '' )."' 
, '".JRequest::getVar('company','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('email','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('phone','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('website','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('url','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('complete','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('em_svc','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('hosting','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('other','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('redesign','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('maintenance','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('ecommerce','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('time','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('method','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('description','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('reset','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('submit','', 'post', 'string', '' )."');" 
);
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); 
window.history.go(-1); </script>
";
}
?>
jpc0480 05 Jul, 2008
Ok... I went back and checked the database and removed the table and went back to chronoforms and then created the table and I'm still not receiving anything in the show data...
jpc0480 05 Jul, 2008
Ok here is the new code... My database now has a table labled jos_chronoforms_1. I'm still not getting anything to show up in the show data field...
<?php 
	$database =& JFactory::getDBO();
	srand((double)microtime()*10000);
	$inum	=	"I" . substr(base64_encode(md5(rand())), 0, 16);
	
$database->setQuery( "INSERT INTO #__chronoforms_1 
VALUES  (
'' ,
 '".$inum."',
'". date('Y-m-d')." - ".date("H:i:s")."',
 '".$_SERVER['REMOTE_ADDR']."' ,
 '".JRequest::getVar('name','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('company','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('email','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('phone','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('website','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('url','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('complete','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('em_svc','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('hosting','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('other','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('redesign','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('maintenance','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('ecommerce','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('time','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('method','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('description','', 'post', 'string', '' )."' ,
 '".JRequest::getVarif (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); 
window.history.go(-1); </script>
";
}
?>
GreyHead 05 Jul, 2008
Hi jpc0480,

There's a bit missing here
'".JRequest::getVarif (!$database->query())
is that just a cut and paste slip?

The rest looks OK, please take a Form Backup and psot it here or mail it to the address in my sig and I'll take a closer look.

Bob
jpc0480 05 Jul, 2008
No that wasn't a slip... That code isn't there. Here is the backup. [file name=Quote.cfbak size=10558]http://www.chronoengine.com/images/fbfiles/files/Quote.cfbak[/file]
GreyHead 06 Jul, 2008
Hi jpc0480,

Your form appears to work OK for me. I did have to add 'addslashes' to the textarea input, mainly because I typed some junk in there. Here's the Autogenerated code I ended up with - including some debug code.
 <?php 
$database =& JFactory::getDBO();
srand((double)microtime()*10000);
$inum = "I" . substr(base64_encode(md5(rand())), 0, 16);
$sql = "INSERT INTO #__chronoforms_67
 VALUES  (
 '' ,
  '".$inum."',
 '". date('Y-m-d')." - ".date("H:i:s")."', '".$_SERVER['REMOTE_ADDR']."' ,
 '".JRequest::getVar('name','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('company','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('email','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('phone','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('website','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('url','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('complete','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('em_svc','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('hosting','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('other','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('redesign','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('maintenance','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('ecommerce','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('time','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('method','', 'post', 'string', '' )."' ,
 '".addslashes(JRequest::getVar('description','', 'post', 'string', '' ))."');";
if ( $debug ) {
  echo "sql: ";print_r($sql); echo"<br />";
}
$database->setQuery( $sql );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}
?>
Bob
jpc0480 06 Jul, 2008

Hi jpc0480,

Your form appears to work OK for me. I did have to add 'addslashes' to the textarea input, mainly because I typed some junk in there. Here's the Autogenerated code I ended up with - including some debug code.

 <?php 
$database =& JFactory::getDBO();
srand((double)microtime()*10000);
$inum = "I" . substr(base64_encode(md5(rand())), 0, 16);
$sql = "INSERT INTO #__chronoforms_67
 VALUES  (
 '' ,
  '".$inum."',
 '". date('Y-m-d')." - ".date("H:i:s")."', '".$_SERVER['REMOTE_ADDR']."' ,
 '".JRequest::getVar('name','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('company','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('email','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('phone','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('website','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('url','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('complete','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('em_svc','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('hosting','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('other','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('redesign','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('maintenance','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('ecommerce','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('time','', 'post', 'string', '' )."' ,
 '".JRequest::getVar('method','', 'post', 'string', '' )."' ,
 '".addslashes(JRequest::getVar('description','', 'post', 'string', '' ))."');";
if ( $debug ) {
  echo "sql: ";print_r($sql); echo"<br />";
}
$database->setQuery( $sql );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}
?>
Bob



Thank you! At first it didn't work and I checked the code and had to change the table it was posting to. Once I did that, everything worked fine. Thanks again!
GreyHead 07 Jul, 2008
Hi jpc0484,

Glad it worked for you - I should have remembered to point out the table name - you probably haven't got 67 forms yet.

Bob
jpc0480 07 Jul, 2008
No problems. It was an easy fix.
This topic is locked and no more replies can be posted.