Un petit problème en PHP

catrina -  
carbon3 Messages postés 471 Statut Membre -
Bonjour,
Je suis en tant de
Créer un programme PHP permettant de saisir un caractère dans un formulaire HTML, puis d'afficher sa majuscule s'il s'agit d'un caractère en miniscule, sa miniscule s'il s'agit d'un caractère en majuscule, son code ASCII s'il s'agit d'un chiffre, et caractère non traité dans le reste des cas.
Le problème c est que mon programme n a pas fonctionner comme il peut faire m’aider SVP pour qu il fonctionne, voila le scripte du programme



<!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=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form name="f" method="get" action="exp.php">
<table width="500" border="0">
<tr>
<td>SVP unsaisir caractère</td>
<td><input name="t1" type="text" maxlength="1"></td>
<td><input name="t2" type="text" readonly >
</tr>
</table>
</form>



</body>
</html>





<? php
$t=$_GET['t1'];
if{((ord($t)>=ord(a))|| ((ord($t)<=ord(z))
echo strtoupper($t);}
else
if {((ord($t)>=ord(A))|| ((ord($t)<=ord(Z))
echo strtolower($t);}
else if {((ord($t)>=ord(1))|| ((ord($t)<=ord(9))
echo ord($t);}
else {echo "caractère non traité";}
?>

1 réponse

carbon3 Messages postés 471 Statut Membre 73
 
salut,
fichier catrina.php :
<html>
<head>
<title>Convert Catrina</title>
<?php 
$get_input=$_SERVER['PHP_SELF'];

include_once('exp.php');
?>

</head>

<body>

<form name="f" method="POST" action="<?php echo $get_input ?>">
<table border="1">
<tr>
<th colspan="2">Saisir un caractère S.V.P.</th>
</tr><tr>
<td align="center" width="250"><input name="t1" type="text" maxlength="1"size="1" style="font-size:14pt;"/></td>
<td id="t2" style="width:250px;font-size:16pt; font-family:courier new; text-align:center"/></td>
</tr>

</table>
<?php
if(isset($_POST['t1'])) {
	daillo();
}
?>
</form>

</body>
</html>

et fichier exp.php :
<?php
function daillo() {
	$t=$_POST['t1'];
	if (ord($t)>=ord(a) && ord($t)<=ord(z)) {
		echo '<script language="javascript">document.getElementById(\'t2\').innerHTML="'.$t.' --> '.strtoupper($t).'";</script>';
	}
	else if (ord($t)>=ord(A) && ord($t)<=ord(Z)) {
		echo '<script language="javascript">document.getElementById(\'t2\').innerHTML="'.$t.' --> '.strtolower($t).'";</script>';
	}
	else if (ord($t)>=ord(1) && ord($t)<=ord(9)) {
		echo '<script language="javascript">document.getElementById(\'t2\').innerHTML="'.$t.' --> '.ord($t).'";</script>';
	}
	else { echo '<script language="javascript">document.getElementById(\'t2\').innerHTML="caractère non traité";</script>'; }
}
?>
1