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
tonguim
Forum Newbie
Posts: 21 Joined: Mon Jun 30, 2003 12:53 pm
Location: Ouagadougou, BURKINA FASO
Contact:
Post
by tonguim » Mon Jul 11, 2005 10:34 am
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 = "e;ageControleSexe.php"e;>
<?php
//initialisation des variables
//$_POSTї'nomHtml'] = $_POSTї'prenomHtml'] = $_POSTї'anneeHtml'] = $_POSTї'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 = "e;nomHtml"e; size = 20 type = text></td></tr>
<tr><td>Prenom:</td><td><input name = "e;prenomHtml"e; size = 20 type = text></td></tr>
<tr><td>Sexe:</td><td>Masculin<input name = "e;sexeHtml"e; type = radio checked value = "e;m"e;>Feminin<input name = "e;sexeHtml"e; type = radio value = "e;f"e;></td></tr>
<tr><td colspan = 2><u><p>Date de naissance</p></u></td></tr>
<tr><td>Jour:</td><td><input name = "e;jourHtml"e; size = 20 type = text></td></tr>
<tr><td>Mois:</td><td><input name = "e;moisHtml"e; size = 20 type = text></td></tr>
<tr><td>Annee:</td><td><input name = "e;anneeHtml"e; size = 20 type = text></td></tr>
<tr><td><input name = "e;btonEnvoyer"e; type = submit value = "e;Envoyer"e;></td></tr>
<tr><td>
<?php
if (isset($_POSTї'sexeHtml']) == 'm')
echo 'Mr '.isset($_POSTї'nomHtml']).' '.isset($_POSTї'prenomHtml']).' vous avez '.(2005 - isset($_POSTї'anneeHtml']));
else
echo 'Mme '.isset($_POSTї'nomHtml']).' '.isset($_POSTї'prenomHtml']).' vous avez '.(2005 - isset($_POSTї'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 » Mon Jul 11, 2005 11:08 am
what are the results that are expected and what results do you get?
IceMetalPunk
Forum Commoner
Posts: 71 Joined: Thu Jul 07, 2005 11:45 am
Post
by IceMetalPunk » Mon Jul 11, 2005 11:40 am
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 » Tue Jul 12, 2005 2:40 pm
Thank you IceMetalPunk and Deemo
. This is my code; it is works well now:
Code: Select all
<html>
<head>
</head>
<body>
<form method = "e;POST"e; action = "e;ageControleSexe5.php"e;>
<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 = "e;nomHtml"e; size = 20 type = text></td></tr>
<tr><td>Prenom:</td><td><input name = "e;prenomHtml"e; size = 20 type = text></td></tr>
<tr><td>Sexe:</td><td>Masculin<input name = "e;sexeHtml"e; type = radio checked value = "e;m"e;>Feminin<input name = "e;sexeHtml"e; type = radio value = "e;f"e;></td></tr>
<tr><td colspan = 2><u><p>Date de naissance</p></u></td></tr>
<tr><td>Jour:</td><td><input name = "e;jourHtml"e; size = 20 type = text></td></tr>
<tr><td>Mois:</td><td><input name = "e;moisHtml"e; size = 20 type = text></td></tr>
<tr><td>Annee:</td><td><input name = "e;anneeHtml"e; size = 20 type = text></td></tr>
<tr><td><input name = "e;btonEnvoyer"e; type = submit value = "e;Envoyer"e;></td></tr>
<tr><td>
<?php
if(isset($_POSTї'nomHtml'])&& isset($_POSTї'prenomHtml']) && isset($_POSTї'anneeHtml']))
{
if (isset($_POSTї'sexeHtml']) && $_POSTї'sexeHtml']=="e;m"e;)
echo 'Mr '.$_POSTї'nomHtml'].' '.$_POSTї'prenomHtml'].' vous avez '.(2005 - $_POSTї'anneeHtml']);
else
echo 'Mme '.$_POSTї'nomHtml'].' '.$_POSTї'prenomHtml'].' vous avez '.(2005 - $_POSTї'anneeHtml']);
}
?>
</td></tr>
</table>
</form>
</body>
</html>