Forums

Custom Code not working

davideiandoli75 09 Jun, 2017
I set up a form in which the only part not working is the Custom Code box I put at the end, as I need different messages;

The same code is actually working in a similar Cfv5 form. Any suggestions?

Here below the snippet:
<?php

/* preparazione stringhe */
$comune ="<h1>Riceverai a breve una mail di benvenuto: ti invitiamo a controllare anche la cartella SPAM o Posta indesiderata. <br /><br />

Se hai ancora dubbi, prima di reinoltrare la richiesta d'iscrizione ti suggeriamo di contattarci all'indirizzo <u>info@progettistisociali.it</u>. Grazie. <br /><br /></h1>";

$messaggio ="<strong>Facendo click sul pulsante potrai pagare la quota prevista con Paypal o carta di credito</strong><br /><br />";

/* paypal + pulsante soci */
$paypalsoci = "<p style=\"text-align: center; font-size: 150%; color: #840000;\"><strong>Stai effettuando l'iscrizione come socio/a A.P.I.S.</strong></p>";
$pulsantesoci = "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" target=\"_top\">
<input type=\"hidden\" name=\"cmd\" value=\"_s-xclick\">
<input type=\"hidden\" name=\"hosted_button_id\" value=\"UQXMCJL7L6R8N\">
<input type=\"image\" src=\"https://www.paypalobjects.com/it_IT/IT/i/btn/btn_buynowCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal è il metodo rapido e sicuro per pagare e farsi pagare online.\">
<img alt=\"\" border=\"0\" src=\"https://www.paypalobjects.com/it_IT/i/scr/pixel.gif\" width=\"1\" height=\"1\">
</form>";

/*paypal + pulsante non soci */
$paypal_nonsoci = "<p style=\"text-align: center; font-size: 150%; color: #840000;\"><strong>Stai effettuando l'iscrizione all'A.P.I.S. per partecipare al corso</strong></p>";
$pulsante_nonsoci = "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" target=\"_top\">
<input type=\"hidden\" name=\"cmd\" value=\"_s-xclick\">
<input type=\"hidden\" name=\"hosted_button_id\" value=\"MY8SW3A4SG4EW\">
<input type=\"image\" src=\"https://www.paypalobjects.com/it_IT/IT/i/btn/btn_buynowCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal è il metodo rapido e sicuro per pagare e farsi pagare online.\">
<img alt=\"\" border=\"0\" src=\"https://www.paypalobjects.com/it_IT/i/scr/pixel.gif\" width=\"1\" height=\"1\">
</form>";

/* bonifici */
$bonifico = "<p style=\"text-align: center; font-size: 150%; color: #840000;\"><strong>Pagamento via bonifico bancario</strong></p>";

$bonifico_nonsoci = "<div style=\"border: 2px solid; border-radius: 5px; padding: 5px;\"><strong>Effettua un bonifico di € 340,00 intestato a A.P.I.S., IBAN IT36E0501803200000000129727 presso Banca Etica, indicando come Causale: <br />Iscrizione Corso Base 7a Edizione «tuo nome e cognome».<br /> N.B. Per rendere più celere l'iscrizione invia copia della contabile bancaria a corsi@progettistisociali.it</strong></div><br />";
$bonifico_soci = "<div style=\"border: 2px solid; border-radius: 5px; padding: 5px;\"><strong>Effettua un bonifico di € 240,00 intestato a A.P.I.S., IBAN IT36E0501803200000000129727 presso Banca Etica, indicando come Causale: <br />Iscrizione Corso Base 7a Edizione «tuo nome e cognome».<br /> N.B. Per rendere più celere l'iscrizione invia copia della contabile bancaria a corsi@progettistisociali.it</strong></div><br />";

$iscrizione = $this->data['iscrizione'];
$pagamento = $this->data['pagamento'];


/* il messaggio visualizzato cambia in base alle selezioni */
switch ($iscrizione) {

case "socio":

    if ($pagamento == "paypal") { 
    
    echo $comune . $paypalsoci . $messaggio . $pulsantesoci;
    
    } else {
    
    echo $comune . $bonifico . $bonifico_soci;
    
    }
    break;
         

case "nonsocio":

    if ($pagamento == "paypal") { 
    
    echo $comune . $paypal_nonsoci . $messaggio . $pulsante_nonsoci;
    
    } else {
    
    echo $comune . $bonifico. $bonifico_nonsoci;
    
    }
    break;
    }
   

?>
davideiandoli75 09 Jun, 2017
ps: in the new CFv6 there isn't the 'diagnostics' column, so you can easily forget to enable actions like DB Save or Email
GreyHead 09 Jun, 2017
Hi davideiandoli75 ,

I think that in CFv6 you may need to leave out the <?php ?> tags - though I'm not certain.

How exactly does this fail?

Bob
davideiandoli75 09 Jun, 2017
It is just a blank screen without any indication.

edit: if I leave out the <?php ?> tags the message is displayed but not in the right way. I see comments and variables assignation, as you can see in the example below:

$messaggio ="Facendo click sul pulsante potrai pagare la quota prevista con Paypal o carta di credito

"; /* paypal + pulsante soci */ $paypalsoci = "

Stai effettuando l'iscrizione come socio/a A.P.I.S.



Thanks fon any suggestion
GreyHead 09 Jun, 2017
Hi davideiandoli75 ,

Please try setting the Site Error Reporting temporarily to Maximum and see if you get a more helpful Error Message.

Bob
GreyHead 09 Jun, 2017
Hi davideiandoli75 ,

By all means PM me the site URL, the form name, and a SuperAdmin login and I'll take a quick look.

Bob
GreyHead 10 Jun, 2017
Answer
Hi davideiandoli75 ,

I think it is OK now- your custom code was checking for values socie and nonsocie but the radio buttons are set to soci and nonsoci.

Bob
davideiandoli75 10 Jun, 2017
What a stupid miss! I really apologise of not realising that mistake!
However, now it works as expected. Thank you very much Bob
This topic is locked and no more replies can be posted.