[RESOLU] Strftime et strtotime

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : [RESOLU] Strftime et strtotime

Re: Strftime et strtotime

par NUAGE » 14 mai 2013, 15:42

Merci beaucoup !
Encore une fois merci !

Re: Strftime et strtotime

par ghost5922 » 14 mai 2013, 14:24

voila en fr

head

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<title>Document sans titre</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
	
<script>
    $(function() {
        $( "#datepicker" ).datepicker();
    });
    </script>
    
    <script type="text/javascript">

$(document).ready(function () {
	jQuery(function($){
	$.datepicker.regional['fr'] = {
		closeText: 'Fermer',
		prevText: 'Précédent',
		nextText: 'Suivant',
		currentText: 'Aujourd\'hui',
		monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin',
		'Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
		monthNamesShort: ['Janv.','Févr.','Mars','Avril','Mai','Juin',
		'Juil.','Août','Sept.','Oct.','Nov.','Déc.'],
		dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
		dayNamesShort: ['Dim.','Lun.','Mar.','Mer.','Jeu.','Ven.','Sam.'],
		dayNamesMin: ['D','L','M','M','J','V','S'],
		weekHeader: 'Sem.',
		dateFormat: 'dd/mm/yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['fr']);
});
	
         $("#bAdd").click(function(){
                  if ($('#date2').length <= 0){//on verifie que l'input et pas deja present
                       $("#trAdd").after('<tr><td><label for="date"><strong>Date 2 :</strong></label></td><td><input type="text" name="date2" id="date2" /></td></tr>');
					   $( "#date2" ).datepicker();
                  }

          });
		  
});
</script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
	<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
	<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" />
</head>

le form
 <form name="ajout" action="formation.php" method="POST">
            <table>
            
            <tr>
            
            <td><label for="nom"><strong>Nom de la formation :</strong></label></td>
            <td><input type="text" name="nom" required title="Entrez ici le nom de la formation"/></td>
        
            </tr>         

            <tr>
            
            <td><label for="date"><strong>Date(s) de formation :</strong></label></td>
            <td><input type="date" name="date" id="datepicker"> </td>
            
            </tr>
            
            <tr id="trAdd">  
            <td> <input type="button" id="bAdd" value="Ajouter" /></td>
            
            </tr>

Re: Strftime et strtotime

par ghost5922 » 14 mai 2013, 14:08

Re: Strftime et strtotime

par ghost5922 » 14 mai 2013, 14:06

ben le 2eme input c'est date2 que vous avez déjà faut juste le déclarer a la fonction

pour la langue je ne c'est pas

Re: Strftime et strtotime

par NUAGE » 14 mai 2013, 14:03

J'ai pas tout à fait compris, désolée :?
Pourquoi créer 2 inuput ? Et puis comment le mettre en français ?

Re: Strftime et strtotime

par ghost5922 » 14 mai 2013, 13:52

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<title>Document sans titre</title>
<script type="text/javascript">

$(document).ready(function () {
         $("#bAdd").click(function(){
                  if ($('#date2').length <= 0){//on verifie que l'input et pas deja present
                       $("#trAdd").after('<tr><td><label for="date"><strong>Date 2 :</strong></label></td><td><input type="text" name="date2" id="date2" /></td></tr>');
                  }
          });
});
</script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
	<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
	<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
	<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" />
<script>
    $(function() {
        $( "#datepicker,#date2" ).datepicker();
    });
    </script>
</head>
sinon il faut juste ajouter l'id du champ ici
<script>
    $(function() {
        $( "#datepicker,#date2" ).datepicker();
    });
    </script>

Re: Strftime et strtotime

par NUAGE » 14 mai 2013, 13:51

Du coup ça marche pour date mais pas pour date2
j'ai essayé ceci en changeant le type et le id du input
[javascript]
<script type="text/javascript">

$(document).ready(function () {
$("#bAdd").click(function(){
if ($('#date2').length <= 0){//on verifie que l'input et pas deja present
$("#trAdd").after('<tr><td><label for="date"><strong>Date 2 :</strong></label></td><td><input type="date" name="date2" id="datepicker" /></td></tr>');
}
});
});
</script>[/javascript]

mais ça ne marche pas...
Et pour le mettre en français c'est comment ?

Re: Strftime et strtotime

par ghost5922 » 14 mai 2013, 13:43

j'ai oublie un bout désolé
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<title>Document sans titre</title>
<script type="text/javascript">

$(document).ready(function () {
         $("#bAdd").click(function(){
                  if ($('#date2').length <= 0){//on verifie que l'input et pas deja present
                       $("#trAdd").after('<tr><td><label for="date"><strong>Date 2 :</strong></label></td><td><input type="text" name="date2" id="date2" /></td></tr>');
                  }
          });
});
</script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
	<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
	<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
	<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css" />
<script>
    $(function() {
        $( "#datepicker" ).datepicker();
    });
    </script>
</head>
le code source : http://jqueryui.com/datepicker/
ma DEMO

Re: Strftime et strtotime

par NUAGE » 14 mai 2013, 13:04

Oui, mais il n'y a pas de calendrier...

Re: Strftime et strtotime

par ghost5922 » 14 mai 2013, 12:59

Bonjour,

voila votre code
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<title>Document sans titre</title>
<script type="text/javascript">
$(document).ready(function () {
         $("#bAdd").click(function(){
                  if ($('#date2').length <= 0){//on verifie que l'input et pas deja present
                       $("#trAdd").after('<tr><td><label for="date"><strong>Date 2 :</strong></label></td><td><input type="text" name="date2" id="date2" /></td></tr>');
                  }
          });
});
</script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />

</head>
<form name="ajout" action="formation.php" method="POST">
            <table>
            
            <tr>
            
            <td><label for="nom"><strong>Nom de la formation :</strong></label></td>
            <td><input type="text" name="nom" required title="Entrez ici le nom de la formation"/></td>
        
            </tr>         

            
            
            <td><label for="date"><strong>Date de formation :</strong></label></td>
            <td><input type="date" id="datepicker" name="date"> </td>
       <tr id="trAdd">

Re: Strftime et strtotime

par NUAGE » 14 mai 2013, 12:38

Pourtant j'ai bien mis ça.
src=" http://jquery-ui.googlecode.com/svn/tru ... javascript">
voilà ce qu'il manque mais dans mon code ça y est : trunk/ui/i18n/jquery.ui.datepicker-fr

Re: Strftime et strtotime

par ghost5922 » 14 mai 2013, 12:33

Bonjour,

il a deja un souci avec cette ligne le chemin n'ai pas complet

<script src=" http://jquery-ui.googlecode.com/svn/tru ... cker-fr.js"type="text/javascript"></script>

Re: Strftime et strtotime

par NUAGE » 14 mai 2013, 12:29

Il y a toujours le problème de la date, mon problème se situe au niveau de saisie, je pense qu'avec un calendrier, ça serait mieux... ou du moins pour l'utilisateur.

J'ai ajouté un calendrier mais celui-ci est en anglais...

Voici mon code complet :

[javascript]
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jq ... "></script>
<title>Document sans titre</title>
<script type="text/javascript">

$(document).ready(function () {
$("#bAdd").click(function(){
if ($('#date2').length <= 0){//on verifie que l'input et pas deja present
$("#trAdd").after('<tr><td><label for="date"><strong>Date 2 :</strong></label></td><td><input type="text" name="date2" id="date2" /></td></tr>');
}
});
});
</script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jq ... ery-ui.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-do ... .theme.css" type="text/css" media="all" />

<script src=" http://jquery-ui.googlecode.com/svn/tru ... "></script>
<script src="http://ajax.googleapis.com/ajax/libs/jq ... ery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jq ... -ui.min.js" type="text/javascript"></script>

</head>

<body>

<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
[/javascript]

 <form name="ajout" action="formation.php" method="POST">
            <table>
            
            <tr>
            
            <td><label for="nom"><strong>Nom de la formation :</strong></label></td>
            <td><input type="text" name="nom" required title="Entrez ici le nom de la formation"/></td>
        
            </tr>         

            
            
            <td><label for="date"><strong>Date de formation :</strong></label></td>
            <td><input type="date" id="datepicker" name="date"> </td>
        
       <tr id="trAdd">
   
            <?php 
include("connexion.php");
$req= "ALTER TABLE Formation ADD date2 DATE NOT NULL";
$result= mysql_query($req);
  
?>
<td> <input type="button" id="bAdd" value="Ajouter" /></td>
            </tr>

 

        </table>


            <table>

        <br/>
        <br/>
        <input type="submit" name="register" value="Ajouter une formation" />
              </table>

</form>

</body>

</html>

Re: Strftime et strtotime

par ghost5922 » 14 mai 2013, 11:56

voila ton code

 <form name="ajout" action="formation.php" method="POST">
            <table>
            
            <tr>
            
            <td><label for="nom"><strong>Nom de la formation :</strong></label></td>
            <td><input type="text" name="nom" required title="Entrez ici le nom de la formation"/></td>
        
            </tr>         

            <tr>
            
            <td><label for="date"><strong>Date(s) de formation :</strong></label></td>
            <td><input type="date" name="date"> </td>
            
            </tr>
            
            <tr id="trAdd">  
            <td> <input type="button" id="bAdd" value="Ajouter" /></td>
            
            </tr>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<title>Document sans titre</title>
<script type="text/javascript">

$(document).ready(function () {
         $("#bAdd").click(function(){
                  if ($('#date2').length <= 0){//on verifie que l'input et pas deja present
                       $("#trAdd").after('<tr><td><label for="date"><strong>Date 2 :</strong></label></td><td><input type="text" name="date2" id="date2" /></td></tr>'); 
                  }
          });
});
</script>
</head>


<?php 

  include("connexion.php");
$nom=isset($_POST['nom'])?$_POST['nom']:"";
$date=isset($_POST['date'])?$_POST['date']:"";
$date2=isset($_POST['date2'])?$_POST['date2']:"";

$sql= "INSERT INTO `Formation` (`idFormation`, `nom`, `date`, `date2`) VALUES (' ', '$nom', '$date', '$date2');";


       

  $requete = mysql_query($sql) or die( mysql_error() ) ;

if($requete)
  {
    echo("La formation a été créé") ;
  }
  else
  {
    echo("La formation n'a pas été créé") ;
  } 
?>

Re: Strftime et strtotime

par ghost5922 » 14 mai 2013, 11:54

normal vous modifie votre structure la premier fois mais après le champ date2 et deja présent :)

du coup il a un problème avec votre premier code

1 ) ajouter le champ date2 par default
2 ) virer le code php et l'appelle de la page via jquery

vous avez juste besoin d'ajoute un champ input et non un champ date2 a chaque formation :)