Forums

Error onsubmit

ilmagowalter 09 Feb, 2016
Hi,
in event onsubmit i have the custom code below

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}
mysql_select_db('ecopm');

$sql = "DELETE FROM sede_installazione_video WHERE ID_SEDE = " . $form->data['ID_SEDE'];
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not get data: ' . mysql_error());
}
//echo "Records cancellati-> " . mysql_affected_rows();
foreach ($form->data['ID_VIDEO_ASSOCIATI'] as $d) {
	$sql = "INSERT INTO sede_installazione_video( ID_SEDE, ID_VIDEO) VALUES ( " . $form->data['ID_SEDE'] . ", " . $d . ")";
	$retval = mysql_query( $sql, $conn );
	if(! $retval )
	{
	  die('Could not get data: ' . mysql_error());
	}
}
//echo "Records inseriti";
mysql_close($conn);
header("location: /index.php?option=com_chronoforms5&chronoform=Gestione_Video");
?>


when i push the button submit, this code is executed and data saved on database but when reload webpage i receive the error

Can someone help me ?
ilmagowalter 09 Feb, 2016
http://www.screencast.com/t/TjyDU4xZs

this is the image
GreyHead 09 Feb, 2016
Hi ilmagowalter,

I'm guessing that there is a problem with the Header URL in your code - maybe it needs to be an absolute URL?

ChronoForms has a ReDirect action if that is what you need to do.

Bob
ilmagowalter 09 Feb, 2016
i don't set any URL manually
i can say that the url that i see in error page is the same of the form with the add of "&submit"
ilmagowalter 09 Feb, 2016
"header("location: /index.php?option=com_chronoforms5&chronoform=Gestione_Video");"
this is only a test
i don't have in custom code
ilmagowalter 09 Feb, 2016
with the add of "&event=submit"
sorry
GreyHead 09 Feb, 2016
Hi ilmagowalter,

I can see that isn't there. I'm just suggesting what might cause a problem. The URL appears valid but it's giving you a 404 error. You've also got a couple of 'die' statements in your code - they might be killing the form process before it gets there.

Bob
ilmagowalter 09 Feb, 2016
also eliminating the "die" and using the absolute path in the header command, I always have the same problem
There is the correct address in the browser (with the addition of &event=submit) and that mistake
strange...there is some other parameters that can help me ?
GreyHead 09 Feb, 2016
Hi ilmagowalter,

Nothing obvious that I can see - but you have written some custom PHP there and something in that may be causing a problem - as you aren't using the ChronoForms actions, or the Joomla! DB methods that I'm familiar with there is little that I can do to help you debug it.

Bob
ilmagowalter 10 Feb, 2016
i solved with php header and put the correct link
This topic is locked and no more replies can be posted.