no error in the code, but it doesn't give the right result

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tonguim
Forum Newbie
Posts: 21
Joined: Mon Jun 30, 2003 12:53 pm
Location: Ouagadougou, BURKINA FASO
Contact:

no error in the code, but it doesn't give the right result

Post by tonguim »

Hi,

Below is my code; there is no error in the code, but it doesn't give the results i expected. Please what is going wrong in my code? How can i fix it? Thank you.

Code: Select all

<html>
         <head>
         </head>
         <body>
         	<form method = POST action = &quote;ageControleSexe.php&quote;>
         		<?php
         			//initialisation des variables
	         		//$_POST&#1111;'nomHtml'] = $_POST&#1111;'prenomHtml'] = $_POST&#1111;'anneeHtml'] = $_POST&#1111;'sexeHtml'] = '0';
        	 	?>
         		<table align = center border = 1 cellpadding = 0 cellspacing = 0>
         			<tr><td><table align = center><tr align = center><td colspan = 2><font size = 4><b>Programme identité</b></font></td></tr>
         			<tr><td colspan = 2><u><p>Identite</p></u></td></tr>
         			<tr><td>Nom:</td><td><input name = &quote;nomHtml&quote; size = 20 type = text></td></tr>
		 			<tr><td>Prenom:</td><td><input name = &quote;prenomHtml&quote; size = 20 type = text></td></tr>
		 			<tr><td>Sexe:</td><td>Masculin<input name = &quote;sexeHtml&quote; type = radio checked value = &quote;m&quote;>Feminin<input name = &quote;sexeHtml&quote; type = radio value = &quote;f&quote;></td></tr>
         			<tr><td colspan = 2><u><p>Date de naissance</p></u></td></tr>
         			<tr><td>Jour:</td><td><input name = &quote;jourHtml&quote; size = 20 type = text></td></tr>
         			<tr><td>Mois:</td><td><input name = &quote;moisHtml&quote; size = 20 type = text></td></tr>
         			<tr><td>Annee:</td><td><input name = &quote;anneeHtml&quote; size = 20 type = text></td></tr>
         			<tr><td><input name = &quote;btonEnvoyer&quote; type = submit value = &quote;Envoyer&quote;></td></tr>
	         		<tr><td>
					<?php
						if (isset($_POST&#1111;'sexeHtml']) == 'm')				 	         			
    	     				echo 'Mr '.isset($_POST&#1111;'nomHtml']).' '.isset($_POST&#1111;'prenomHtml']).' vous avez '.(2005 - isset($_POST&#1111;'anneeHtml']));
						else
        	 				echo 'Mme '.isset($_POST&#1111;'nomHtml']).' '.isset($_POST&#1111;'prenomHtml']).' vous avez '.(2005 - isset($_POST&#1111;'anneeHtml']));
        	 		?>	
		 			</td></tr>
         		</table>
         	</form>
         </body>
         </html>
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

what are the results that are expected and what results do you get?
User avatar
IceMetalPunk
Forum Commoner
Posts: 71
Joined: Thu Jul 07, 2005 11:45 am

Post by IceMetalPunk »

You are using isset wrong. It returns true if it's set and false if not, but it DOES NOT return the value Therefore, this part:

Code: Select all

if (isset($_POST['sexeHTML'])=="m")
Should be changed to this:

Code: Select all

if (isset("$_POST['sexeHTML']) && $_POST['sexeHTML']=="m")
And do that for every time you tried to compare iseet to a value other than true/false (1/0).

-IMP ;) :)
tonguim
Forum Newbie
Posts: 21
Joined: Mon Jun 30, 2003 12:53 pm
Location: Ouagadougou, BURKINA FASO
Contact:

Post by tonguim »

Thank you IceMetalPunk and Deemo :D. This is my code; it is works well now:

Code: Select all

<html>
         <head>
         </head>
         <body>
         	<form method = &quote;POST&quote; action = &quote;ageControleSexe5.php&quote;>
           		<table align = center border = 1 cellpadding = 0 cellspacing = 0>
         			<tr><td><table align = center><tr align = center><td colspan = 2><font size = 4><b>Programme identité</b></font></td></tr>
         			<tr><td colspan = 2><u><p>Identite</p></u></td></tr>
         			<tr><td>Nom:</td><td><input name = &quote;nomHtml&quote; size = 20 type = text></td></tr>
		 			<tr><td>Prenom:</td><td><input name = &quote;prenomHtml&quote; size = 20 type = text></td></tr>
		 			<tr><td>Sexe:</td><td>Masculin<input name = &quote;sexeHtml&quote; type = radio checked value = &quote;m&quote;>Feminin<input name = &quote;sexeHtml&quote; type = radio value = &quote;f&quote;></td></tr>
         			<tr><td colspan = 2><u><p>Date de naissance</p></u></td></tr>
         			<tr><td>Jour:</td><td><input name = &quote;jourHtml&quote; size = 20 type = text></td></tr>
         			<tr><td>Mois:</td><td><input name = &quote;moisHtml&quote; size = 20 type = text></td></tr>
         			<tr><td>Annee:</td><td><input name = &quote;anneeHtml&quote; size = 20 type = text></td></tr>
         			<tr><td><input name = &quote;btonEnvoyer&quote; type = submit value = &quote;Envoyer&quote;></td></tr>
	         		<tr><td>
					<?php						
						if(isset($_POST&#1111;'nomHtml'])&& isset($_POST&#1111;'prenomHtml']) && isset($_POST&#1111;'anneeHtml']))
						{ 
							if (isset($_POST&#1111;'sexeHtml']) && $_POST&#1111;'sexeHtml']==&quote;m&quote;)									 	         			
    	     					echo 'Mr '.$_POST&#1111;'nomHtml'].' '.$_POST&#1111;'prenomHtml'].' vous avez '.(2005 - $_POST&#1111;'anneeHtml']);
							else
        	 					echo 'Mme '.$_POST&#1111;'nomHtml'].' '.$_POST&#1111;'prenomHtml'].' vous avez '.(2005 - $_POST&#1111;'anneeHtml']);
						}
        	 		?>	
		 			</td></tr>
         		</table>
         	</form>
         </body>
         </html>
Post Reply