Questionnaire avec restriction en php
christophe.therrien
Messages postés
102
Date d'inscription
Statut
Membre
Dernière intervention
-
christophe.therrien Messages postés 102 Date d'inscription Statut Membre Dernière intervention -
christophe.therrien Messages postés 102 Date d'inscription Statut Membre Dernière intervention -
Bonjour, j'aimerais savoir comment mettre des restrictions (else,elseif, then, if,...) dans un formulaire php. voici mon fichier php si cela peut vous aider.
Merci à l'avance
Christophe
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style1 { font-size: 18px; font-weight: bold; } --> </style> </head> <body> <p>Calcul de l'impôt personnel 2009 <?php if(!preg_match("#^[0-9]+$#", $_POST['a']) || !preg_match("#^[0-9]+$#", $_POST['b']) || !preg_match("#^[0-9]+$#", $_POST['c'])|| !preg_match("#^[0-9]+$#", $_POST['d'])|| !preg_match("#^[0-9]+$#", $_POST['e'])|| !preg_match("#^[0-9]+$#", $_POST['f'])|| !preg_match("#^[0-9]+$#", $_POST['g'])|| !preg_match("#^[0-9]+$#", $_POST['h'])|| !preg_match("#^[0-9]+$#", $_POST['i'])|| !preg_match("#^[0-9]+$#", $_POST['j'])|| !preg_match("#^[0-9]+$#", $_POST['k'])|| !preg_match("#^[0-9]+$#", $_POST['l'])|| !preg_match("#^[0-9]+$#", $_POST['m'])|| !preg_match("#^[0-9]+$#", $_POST['n'])|| !preg_match("#^[0-9]+$#", $_POST['o'])|| !preg_match("#^[0-9]+$#", $_POST['p'])|| !preg_match("#^[0-9]+$#", $_POST['q'])|| !preg_match("#^[0-9]+$#", $_POST['r'])) { ?> </p> <form method="post" action=""> <table width="746" border="1"> <tr> <td width="336"><span class="style1">Revenus</span></td> <td width="194">Provincial (Québec)</td> <td width="194">Fédéral</td> </tr> <tr> <td>Revenus de salaire : </td> <td><input name="a" type="text" /></td> <td><input name="a" type="text" /></td> </tr> <tr> <td>Revenus de dividende (réel) :</td> <td><input name="c" type="text" /></td> <td><input name="d" type="text" /></td> </tr> <tr> <td>Revenus d'intérêts :</td> <td><input name="e" type="text" /></td> <td><input name="f" type="text" /></td> </tr> <tr> <td>Autres Revenus :</td> <td><label> <input type="text" name="g"/> </label></td> <td><input name="h" type="text" /></td> </tr> <tr> <td colspan="3"> </td> </tr> <tr> <td colspan="3"><span class="style1">Déductions</span></td> </tr> <tr> <td>RRQ</td> <td><input type="text" name="i"/></td> <td bgcolor="#999999"> </td> </tr> <tr> <td>REER</td> <td><input type="text" name="j"/></td> <td><input name="k" type="text" /></td> </tr> <tr> <td>Autres déductions</td> <td><input type="text" name="l"/></td> <td><input name="m" type="text" /></td> </tr> <tr> <td colspan="3"> </td> </tr> <tr> <td colspan="3"><span class="style1">CRÉDITS NON REMBOURSABLES</span></td> </tr> <tr> <td>Montant personnel de Base</td> <td><div align="right">10455</div></td> <td><div align="right">10375</div></td> </tr> <tr> <td>Montant en raison de l'age (6 658$)</td> <td colspan="2"><label> Plus de 65 ans</label></td> </tr> <tr> <td>RRQ</td> <td><input type="text" name="n"/></td> <td bgcolor="#999999"> </td> </tr> <tr> <td>Cotisation assurance emploi</td> <td><input type="text" name="o"/></td> <td><input type="text" name="p"/></td> </tr> <tr> <td>Autres Montants</td> <td><input type="text" name="q"/></td> <td><input type="text" name="r"/></td> </tr> <tr> <td colspan="3"> </td> </tr> <tr> <td colspan="3"><input type="submit" value="Calculer " /></td> </tr> </table> <p><label></label> </p> </form> <?php } else { $s=($_POST['a']+$_POST['c']+$_POST['e']+$_POST['g']); $t=($_POST['b']+$_POST['d']+$_POST['f']+$_POST['h']); $u=($_POST['i']+$_POST['j']+$_POST['l']); $v=($_POST['k']+$_POST['m']); $w=($_POST['s']-$_POST['u']); $x=($_POST['t']-$_POST['v']); $y=(($_POST['n']+$_POST['o']+$_POST['q']+10375)*0.15); $z=(($_POST['p']+$_POST['r']+10455)*0.2); $aa=(if $_POST['w']>76770 =$_POST['w']*0.24; elseif 38 385<$_POST['w']<=76770 =$_POST['w']*0.20; else =$_POST['w']*0.16); $bb=(if $_POST['w']>123264 =$_POST['w']*0.29; elseif 82399<$_POST['w']<=126264 =$_POST['w']*0.26; elseif 41200<$_POST['w']<=82399 =$_POST['w']*0.22; else =$_POST['w']*0.15); $cc=($_POST['u']*0.1); $dd=($_POST['v']*1.25*0.1333); $ee=($_POST['aa']-$_POST['y']-$_POST['cc']); $ff=($_POST['bb']-$_POST['z']-$_POST['dd']); echo 'Revenu total (Provincial) :'.$s'$'; echo 'Revenu total (Fédéral) :'.$t'$'; echo 'Déductions totales (Provincial) :'.$u'$'; echo 'Déductions totales (Fédéral) :'.$v; echo 'Revenu imposable (Provincial) :'.$w'$'; echo 'Revenu imposable (Fédéral) :'.$x'$'; echo 'Crédits d\'impôts non remboursables (Provincial) :'.$y'$'; echo 'Crédits d\'impôts non remboursables (Fédéral) :'.$z'$'; echo 'Impôt sur le revenu imposable (Provincial) :'.$aa'$'; echo 'Impôt sur le revenu imposable (Fédéral) :'.$bb'$'; echo 'Crédits d\'impôts pour dividendes (Provincial) :'.$cc'$'; echo 'Crédits d\'impôts pour dividendes (Fédéral) :'.$dd'$'; echo '______________________________________'; echo 'Impôts à payer (provincial) :'.$ee'$'; echo 'Impôts à payer (Fédéral) :'.$ff'$'; echo '______________________________________'; } ?> <form id="form1" name="form1" method="post" action=""> <input type="submit" name="button2" id="button2" value="Remise à Zéro " /> </form> </body> </html>
Merci à l'avance
Christophe
A voir également:
- Questionnaire avec restriction en php
- Restriction instagram - Guide
- Easy php - Télécharger - Divers Web & Internet
- Restriction messenger - Forum Facebook Messenger
- Expert php pinterest - Télécharger - Langages
- Code restriction ps5 oublié ✓ - Forum iPhone
5 réponses
bah mon coco tu cherches sur internet des cours PHP chapitre conditions....
ou alors tu poses des questions plus ciblées
et au lieu de non balancer ton fichier en entier sans rien nous dire, dis nous plutot où il faut regarder......
Dorian
ou alors tu poses des questions plus ciblées
et au lieu de non balancer ton fichier en entier sans rien nous dire, dis nous plutot où il faut regarder......
Dorian
En fait mon problème c'est que mon fichier ne s'affiche pas lorsque je tente de l'ouvrir. je crois que ce sont mes restrictions (if, else) car je ne sais trop comment les intégrer dans mon fichier. de plus j'ai des restrictions à l'intérieur de d'autre restrictions (if ou else). je me demandais donc qu'elle était la bonne façon pour intégrer ces dites restrictions dans un fichier php.
else { $s=($_POST['a']+$_POST['c']+$_POST['e']+$_POST['g']); $t=($_POST['b']+$_POST['d']+$_POST['f']+$_POST['h']); $u=($_POST['i']+$_POST['j']+$_POST['l']); $v=($_POST['k']+$_POST['m']); $w=($_POST['s']-$_POST['u']); $x=($_POST['t']-$_POST['v']); $y=(($_POST['n']+$_POST['o']+$_POST['q']+10375)*0.15); $z=(($_POST['p']+$_POST['r']+10455)*0.2); $aa=(if $_POST['w']>76770 =$_POST['w']*0.24; elseif 38 385<$_POST['w']<=76770 =$_POST['w']*0.20; else =$_POST['w']*0.16); $bb=(if $_POST['w']>123264 =$_POST['w']*0.29;
tu oublie la moitié des acolades et des parenthèses... je souligne 1 ou 2 exemples d'oubli...
else { $s=($_POST['a']+$_POST['c']+$_POST['e']+$_POST['g']); $t=($_POST['b']+$_POST['d']+$_POST['f']+$_POST['h']); $u=($_POST['i']+$_POST['j']+$_POST['l']); $v=($_POST['k']+$_POST['m']); $w=($_POST['s']-$_POST['u']); $x=($_POST['t']-$_POST['v']); $y=(($_POST['n']+$_POST['o']+$_POST['q']+10375)*0.15); $z=(($_POST['p']+$_POST['r']+10455)*0.2); $aa=( if ( $_POST['w']>76770 =$_POST['w']*0.24; elseif 38 385<$_POST['w']<=76770 =$_POST['w']*0.20; else { =$_POST['w']*0.16); $bb=(if $_POST['w']>123264 =$_POST['w']*0.29;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
je crois que là c'est mieux, j'ai tout réorganiser...mais je suis pas sûr où j'ai besoin de parenthèses et d'accolade!
if($_POST['w']>76770) { $aa=($_POST['w']*0.24); echo 'Impôt sur le revenu imposable (Provincial) :'.$aa'$'; } elseif(38 385<$_POST['w']<=76770) { $aa=($_POST['w']*0.20); echo 'Impôt sur le revenu imposable (Provincial) :'.$aa'$'; } else { $aa=($_POST['w']*0.16); echo 'Impôt sur le revenu imposable (Provincial) :'.$aa'$'; } if($_POST['w']>123264) { $bb=$_POST['w']*0.29; echo 'Impôt sur le revenu imposable (Fédéral) :'.$bb'$'; } elseif(82399<$_POST['w']<=126264) { $bb=$_POST(['w']*0.26); echo 'Impôt sur le revenu imposable (Fédéral) :'.$bb'$'; } elseif(41200<$_POST['w']<=82399) { $bb=($_POST['w']*0.22); echo 'Impôt sur le revenu imposable (Fédéral) :'.$bb'$'; } else { $bb=($_POST['w']*0.15); echo 'Impôt sur le revenu imposable (Fédéral) :'.$bb'$'; } $cc=($_POST['u']*0.1); echo 'Crédits d\'impôts pour dividendes (Provincial) :'.$cc'$'; $dd=($_POST['v']*1.25*0.1333); echo 'Crédits d\'impôts pour dividendes (Fédéral) :'.$dd'$'; $ee=($_POST['aa']-$_POST['y']-$_POST['cc']); echo '______________________________________'; echo 'Impôts à payer (provincial) :'.$ee'$'; $ff=($_POST['bb']-$_POST['z']-$_POST['dd']); echo 'Impôts à payer (Fédéral) :'.$ff'$'; echo '______________________________________'; }