Hi Max,
Not sure about the plugin debug, this code was devised to work with ChronoForms. I'll add a couple of other useful debug additions here too.
1)
The RedirectURL<?php
if ( $debug && isset($rows[0]->redirecturl ) ) {
echo "Redirect url: ".print_r($rows[0]->redirecturl, true)."<br />";
echo "<a href='$rows[0]->redirecturl'>Click to continue</a><br />";
// prevent the redirect
$rows[0]->redirecturl = "";
}
I had this at the end of the Autogenerated code box but it would be better in the main code. (Note I've amended this a bit to post it here so it may need de-bugging but the principle works OK.)
2)
Debugging SQLThe Autogenerated code needs to be written in a slightly different syntax to make this easier. Here's an example from a form I debugged today:
<?php
$database =& JFactory::getDBO();
srand((double)microtime()*10000);
$inum = "I" . substr(base64_encode(md5(rand())), 0, 16);
// show $sql as a separate variable and use the SET syntax
// to make clear the variable + values combinations in the debug
$sql = "
INSERT
INTO #__chronoforms_4
SET uid = '$inum',
recordtime = '". date('Y-m-d')." - ".date("H:i:s")."',
ipaddress = '".$_SERVER['REMOTE_ADDR']."' ,
entryname = '".JRequest::getVar('entryname','', 'post', 'string', '' )."' ,
email = '".JRequest::getVar('email','', 'post', 'string', '' )."' ,
joinmailinglist = '".JRequest::getVar('joinmailinglist','', 'post', 'string', '' )."' ,
submit = '".JRequest::getVar('submit','', 'post', 'string', '' )."';";
if ( $debug ) {
echo "sql: ".print_r($sql, true)."<br />";
}
$database->setQuery( $sql );
if ( !$database->query() ) {
// I think this might be better for displaying these messages in Joomla 1.5
$mainframe->enqueuemessage($database->getErrorMsg(), 'error');
}
?>
3) $_FILES
The $_POST debug message around line 194 of the old chronocontact.php should also include $_FILES if it's in use.
<?php
/**
* if $debug is true then ChronoForms will show diagnostic output
*/
$debug = $paramsvalues->debug;
if ( $debug ) {
echo "_POST: ".print_r( $_POST, true )."<br />";
if ( isset( $_FILES ) {
echo "_FILES: ".print_r( $_FILES, true )."<br />";
}
}
?>
Bob