datum-uit-form-naar-mysql

Gesponsorde koppelingen

PHP script bestanden

  1. datum-uit-form-naar-mysql

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?php
    function DateSelector($inName, $useDate=0)
    {

        /* create array so we can name months */
        $monthName = array(1=> "januari", "februari", "maart",
            "april", "mei", "juni", "Juli", "augustus",
            "september", "oktober", "november", "december");
      
        /* if date invalid or not supplied, use current time */
        if($useDate == 0)
        {

            $useDate = Time();
        }


        /* make day selector */
        echo "<SELECT NAME=" . $inName . "Day>\n";
        for($currentDay=1; $currentDay <= 31; $currentDay++)
        {

            echo "<OPTION VALUE=\"$currentDay\"";
            if(intval(date( "d", $useDate))==$currentDay)
            {

                echo " SELECTED";
            }

            echo ">$currentDay\n";
        }

        echo "</SELECT>";

        /* make month selector */
        echo "<SELECT NAME=" . $inName . "Month>\n";
        for($currentMonth = 1; $currentMonth <= 12; $currentMonth++)
        {

            echo "<OPTION VALUE=\"";
            echo intval($currentMonth);
            echo "\"";
            if(intval(date( "m", $useDate))==$currentMonth)
            {

                echo " SELECTED";
            }

            echo ">" . $monthName[$currentMonth] . "\n";
        }

        echo "</SELECT>";

        /* make year selector */
        echo "<SELECT NAME=" . $inName . "Year>\n";
        $startYear = date( "Y", $useDate);
        for($currentYear = $startYear - 5; $currentYear <= $startYear+5;$currentYear++)
        {

            echo "<OPTION VALUE=\"$currentYear\"";
            if(date( "Y", $useDate)==$currentYear)
            {

                echo " SELECTED";
            }

            echo ">$currentYear\n";
        }

        echo "</SELECT>";
    
    }

?>



form.php

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?php include("dateselect.php"); ?>
<html>
<head>
</head>
<body>
<form method="post" action="add.php">
<TABLE>
<TR>
<TD>TEST:
<TD>
<input type=TEXT Name=TEST width=20>
</TD>
</TR>
<TR>
   <TD>datum:</TD>
   <TD>
      <!-- You can use PHP functions to automatically get the value of date -->
<?php DateSelector('day','month','year'); ?>
   </TD>
</TR>
<TR>
   <TD></TD><br>
   <TD><INPUT TYPE="submit" name="submit" value="submit"></TD>
</TR>
</TABLE>
</form>

<body>
<html>


add.php

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
//initilize PHP
{
   //convert all the posts to variables:
   $message = $_POST['message'];
   $TEST = $_POST['TEST'];
   $tijd = $_POST['tijd'];
   $Dag = $_POST['dayDay'];
   $Maand = $_POST['dayMonth'];
   $Jaar = $_POST['dayYear'];
   // Dit is date VELD in je tabel
   $Datum = $Jaar."-".$Maand."-".$Dag;
}

?>

  
<table width=50%>
<tr><td>Jaar: </td><td> <?php echo $Jaar; ?> </td></tr>
<tr><td>Dag: </td><td> <?php echo $Dag; ?> </td></tr>
<tr><td>Maand: </td><td> <?php echo $Maand; ?> </td></tr>
<tr><td>Datum: </td><td> <?php echo $Datum; ?> </td></tr>
<tr><td>Test: </td><td> <?php echo $TEST; ?> </td></tr>
</table>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.