[Dates] conversion d'une entrée de formulaire en date
bonjour,
excusez mon ignorance, mais j'ai parcouru tous les tutoriels et les forums et je ne trouve pas de réponse satisfaisante
j'ai créé un formulaire qui doit transmettre une date à mysql
or je souhaiterais saisir la date sous un format dd-mm-yyyy ou dd-mm-yy au lieu du format date obligatoire yyyy-mm-dd
je pense qu'il faut manipuler la chaine de caractères saisis, mais je ne sais pas ou insérer le code necessaire
voici le code de la page:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| <?php
require_once('Connections/connexionnoso.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
//$datesaisie='datesaisie';
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO essai (valeur) VALUES (%s)",
GetSQLValueString($_POST["datesaisie"], "text"));
mysql_select_db($database_connexionnoso, $connexionnoso);
$Result1 = mysql_query($insertSQL, $connexionnoso) or die(mysql_error());
}
mysql_select_db($database_connexionnoso, $connexionnoso);
$query_essai = "SELECT * FROM essai";
$essai = mysql_query($query_essai, $connexionnoso) or die(mysql_error());
$row_essai = mysql_fetch_assoc($essai);
$totalRows_essai = mysql_num_rows($essai);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Document sans titre</title>
</head>
<body>
<div align="center">
<form name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="500" border="2" cellspacing="0" cellpadding="0">
<tr>
<th scope="col"> </th>
<th scope="col"><input name="datesaisie" type="text" id="datesaisie" size="10" maxlength="10"></th>
</tr>
<tr>
<th scope="row"> </th>
<td><input type="submit" name="Submit" value="Envoyer"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
<?php do { ?>
<table width="500" border="2" cellspacing="0" cellpadding="0">
<tr>
<th scope="col"> <?php echo $row_essai['valeur']; ?></th>
</tr>
</table>
<p> </p>
<?php } while ($row_essai = mysql_fetch_assoc($essai)); ?>
</div>
</body>
</html>
<?php
mysql_free_result($essai);
?> |
merci de m'aider, soit en modifiant le code soit en m'expliquant de manuière compréhensible par un novice comment faire