Forums

Redirect to thank you message displays form in header of page.

Canard 17 Nov, 2014
Hi ! I got a new problem with my forms (all of them, on redirect to thank you page) : on submit, the message gets printed correctly and the redirection happens 5seconds later as expected but the whole form is printed in the header op the page ! I didn't create those forms but they were working ok some time ago, I don't know what I did to get that weird behaviour...
Here is an example of the forms :

form html
<?php $editor =& JFactory::getEditor('tinymce'); 
$editor_params = array('theme' => 'simple');
?>
Les champs marqués d’une <font color="red">*</font> sont à renseigner obligatoirement. <br /> 
<table align="center">
<tr>
<td colspan="2"><br />
A quel projet avez-vous participé ? 
</td></tr>
<tr>
<td colspan="2">
 <?php $db =& JFactory::getDBO();

              $query = 'SELECT nom_court AS value, nom_court AS text FROM jos2_projet where published = 1 order by text ASC';

              $db->setQuery( $query );

              $projet = $db->loadObjectList();

              echo JHTML::_( 'select.genericlist', $projet, 'projet_id', 'class="inputbox" style="width: 22em"', 'text', 'text', $_POST[projet], 0); ?>
</td>
</tr> 

<!-- <tr>
<td colspan="2">
Pays du projet :
</td></tr>
<tr>
<td colspan="2">
<input type="text" name="pays" />
</td>
</tr> -->

<tr>
<td colspan="2">
Dates de participation :
</td></tr>
<tr>
<td colspan="2">
<input type="text" name="datepart" id="datepart" /><font color="red">*</font> (Au format "Du jj/mm/année au jj/mm/année")
</td>
</tr>

<tr>
<td colspan="2">
Nom ou Pseudo : 
</td>
</tr>
<tr>
<td colspan="2">
<input name="nom" id="nom" type="text" /><font color="red">*</font>
</td>
</tr> 

<tr>
<td colspan="2">
Email : 
</td>
</tr>
<tr>
<td colspan="2">
<input name="mail" id="mail" type="text" /><font color="red">*</font>
</td>
</tr> 

<!-- <tr>
<td colspan="2"><br />
Quand et à quel projet avec-vous participé ? 
</td></tr>
<tr>
<td colspan="2">
 <?php   echo $editor->display('whenwich', '', '100%', '100', '90', '10', 0, $editor_params); ?>
</td>
</tr> -->

<tr>
<td colspan="2"><br />
Quel était votre travail ? vos horaires ?
</td></tr>
<tr>
<td colspan="2">
<?php   echo $editor->display('work', '', '100%', '100', '70', '10', 0); ?>
</td>
</tr> 

<tr>
<td colspan="2"><br />
Avez-vous apprécié votre séjour et est-ce qu'il correspondait à vos attentes ? 
</td></tr>
<tr>
<td colspan="2">
<?php   echo $editor->display('attentes', '', '100%', '100', '70', '10', 0); ?>
</td>
</tr> 

<tr>
<td colspan="2"><br />
Si non, pourquoi ?
</td></tr>
<tr>
<td colspan="2">
<?php   echo $editor->display('why', '', '100%', '100', '70', '10', 0); ?>
</td>
</tr> 

<tr>
<td colspan="2"><br />
Avez-vous des conseils pour les futurs écovolontaires ? 
</td></tr>
<tr>
<td colspan="2">
<?php   echo $editor->display('advice', '', '100%', '100', '70', '10', 0); ?>
</td>
</tr> 

<tr>
<td colspan="2"><br />
Que vous a apporté cette mission ? 
</td></tr>
<tr>
<td colspan="2">
<?php   echo $editor->display('mission', '', '100%', '100', '70', '10', 0); ?>
</td>
</tr> 
<tr>
<td colspan="2"><br />
Quels acquis pensez-vous être transposables dans votre quotidien ?
</td></tr>
<tr>
<td colspan="2">
<?php   echo $editor->display('transpo', '', '100%', '100', '70', '10', 0); ?>
</td>
</tr>
<tr>
<td colspan="2"><br />
<input type="checkbox" name="othersite" id="othersite" value="Oui" /> j'autorise Cybelle Planète à utiliser et diffuser mon témoignage sur d'autres sites.
</td></tr> 

<tr><td colspan="2"><?php
require_once('stratageo/recaptchalib.php'); // Vérifier que l'URL relative correspond à l'emplacement du fichier (adapter si nécessaire)
$publickey = "6LfECNESAAAAAPLBcb9z3FSAE2xcieNRcMPqeXmH "; // Utiliser la clé que vous avez eu lors de l'inscription sur recaptcha.net
echo recaptcha_get_html($publickey); // Affiche le captcha
?></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="envoyer" id="envoyer" class="GoBigbutton" name="envoyer" /></td></tr>

</table> 
<br />
<br />
<input type="hidden" name="sujet" id="sujet" />
<input type="hidden" name="titre" id="titre" />
<script>
show_data();
</script>

Form JavaScript:
$(document).ready(function() { 
		
		$('#envoyer').click(function() {  
				
				$(".error").hide();
				var hasError = false;
				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
				var emailblockReg =  /^([\w-\.]+@(?!aol.com)([\w-]+\.)+[\w-]{2,4})?$/;

				/* var emailaddressVal = $("#mail").val();
				if(emailaddressVal == '') {
					$("#mail").after('<span class="error">Entrez votre email.</span>');
					hasError = true;
				} else if(!emailReg.test(emailaddressVal)) {	
					$("#mail").after('<span class="error">Entrer une adresse email valide.</span>');
					hasError = true;
				} else if(!emailblockReg.test(emailaddressVal)) {	
					$("#mail").after('<span class="error">No aol.</span>');
					hasError = true;
				} 
		
				if(hasError == true) { 
alert('Veuillez indiquer ou modifier votre email');
return false; }
				else {
					$("#mail").after('<span class="error">Email accepted.</span>');
					
				}*/
	});	
});


function show_data() {
var projet_id = document.getElementById('projet_id');
var projet_ids = document.getElementById('projet_ids');  
projet_id.value = projet_ids.value;
var nom = document.getElementById('nom');
var noms = document.getElementById('noms');
nom.value = noms.value;
var datepart = document.getElementById('datepart');
var dateparts = document.getElementById('dateparts');
datepart.value = dateparts.value;
var mail = document.getElementById('mail');
var mails = document.getElementById('mails');
mail.value = mails.value;
var work = document.getElementById('work');
var works = document.getElementById('works');
work.value = works.value;
var attentes = document.getElementById('attentes');
var attentess = document.getElementById('attentess');
attentes.value = attentess.value;
var advice = document.getElementById('advice');
var advices = document.getElementById('advices');
advice.value = advices.value;
var why = document.getElementById('why');
var whys = document.getElementById('whys');
why.value = whys.value;
var mission = document.getElementById('mission');
var missions = document.getElementById('missions');
mission.value = missions.value;
var transpo = document.getElementById('transpo');
var transpos = document.getElementById('transpos');
transpo.value = transpos.value;
}

On Submit code - before sending email:
<?php
$nom1 = JRequest::getVar('nom', '', 'post');
$titre1 = JRequest::getVar('titre', '', 'post');
$sujet = "Nouveau témoignage : ". $titre1. " par ". $nom1;
JRequest::setVar('sujet', $sujet, 'post');

$projet_id1 = JRequest::getVar('projet_id', '', 'post');
// $pays1 = JRequest::getVar('pays', '', 'post');
$datepart1 = JRequest::getVar('datepart', '', 'post');
$titre1 = $projet_id1." | ".$datepart1;
JRequest::setVar('titre', $titre1, 'post');

?>

On Submit code - after sending email:
<?php
global $mainframe;

$custom_tag = '<meta http-equiv="refresh" content="5; url=http://www.cybelle-planete.org/asso" >';
$mainframe->addCustomHeadTag($custom_tag);
?>
<p>Merci pour votre témoignage. L'équipe de Cybelle Planète</p>
<p>Vous allez être redirigé automatiquement dans quelques instants, si rien ne se passe dans les 10 secondes, <a href="http://www.cybelle-planete.org/asso">cliquez ici</a></p>


here's a capture (after submit with wrong captcha, in order to be able to take the capture) as you can see the form get re-printed in the page as expected with the wrong captcha message, but it is also printed on top of the page)
[attachment=0]Capture.JPG[/attachment]
Canard 17 Nov, 2014
edit : I forgot to mention the form is displayed in place of my laguage form (same location and the language form is not displayed). The same occurs with all forms using a redirect to thank you.
Canard 17 Nov, 2014
edit2: it appears to be SEF related as this form url is
index.php?option=com_chronocontact&chronoformname=temoigner
whereas my form's page is
nous-aider/temoigner
Canard 17 Nov, 2014
edit 3 : after further investigating not related to SEF at all !
Actually I have another form on page top to select language, when I submit the main (in article) form, it gets printed in place of the language form which disappear... If I remove language form from template's index.php all is OK. If I just disable the language form not OK. I'm really stuck.
This topic is locked and no more replies can be posted.