Salut à tous,
mon pb est le suivant : j'ai une page php qui contient des formulaires que je traite avec la methode POST et l'action $_SERVER[PHP_SELF] aprés avoir envoyer les données avec un boutton submit je traite les données normalement mais si je rafraichis la page les donner sont traités une 2 fois comment faire pourque cela n'arrive pas
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
 
?php
  if(!is_null($_POST['Clicks']))
  {
    $file=fopen("count","a+");
    fwrite($file,$_POST['Click']);
    fclose($file);
    $_POST['Clicks']=0;
  }
?>
<html>
<head>
<title></title>
</head>
<body    bgcolor="#000000">
<div align="center">
    <table border="1" cellspacing="1" cellpadding="1">
        <tr>
 
            <td    valign="top">
                <table    width=150 border="1"    cellspacing="1"    cellpadding="1">
                    <tr>
                        <td></td>
                    </tr>
                </table>
            </td>
 
            <td    valign="top">
                <table    width=650 border="1"    cellspacing="1"    cellpadding="1">
                    <tr>
                        <td></td>
                    </tr>
                </table>
            </td>
 
            <td    valign="top">
                <table    width=100 border="1"    cellspacing="1"    cellpadding="1">
                <form method="POST" action="<?php $_SERVER[PHP_SELF] ?>">
                    <tr>
                        <td    valign="top">
                            <table width="100%"    border="1" cellspacing="1" cellpadding="1">
                                <tr    height=20>
                                    <td    bgcolor="#0000FF"    align="center">
                                        <p style="font-family:verdana;color:#E5F2FF;font-size:11px;font-weight:bold;vertical-align:middle">
                                            Sondage
                                        </p>
                                    </td>
                                </tr>
                                <tr    height=20>
                                    <td    bgcolor="#E5F2FF">
                                        <p style="font-family:verdana;color:#0000FF;font-size:11px;font-weight:bold;vertical-align:middle">    
                                            <input type="radio"     name="Click"    id="Click" value="1" style="vertical-align:middle;"    align="left">
                                            1
                                        </p>
                                    </td>
                                </tr>
                                <tr    height=20>
                                    <td    bgcolor="#E5F2FF"    height=19>
                                        <p style="font-family:verdana;color:#0000FF;font-size:11px;font-weight:bold;vertical-align:middle">
                                            <input type="radio"     name="Click"    id="Click" value="2" style="vertical-align:middle;"    align="left">
                                            2
                                        </p>
                                    </td>
                                </tr>
                                <tr    height=20>
                                    <td    bgcolor="#E5F2FF">
                                        <p style="font-family:verdana;color:#0000FF;font-size:11px;font-weight:bold;vertical-align:middle">
                                            <input type="radio"     name="Click"    id="Click" value="3" style="vertical-align:middle;"    align="left" checked>
                                            3
                                        </p>
                                    </td>
                                </tr>
                                <tr    height=20>
                                    <td    bgcolor="#E5F2FF">
                                        <p style="font-family:verdana;color:#0000FF;font-size:11px;font-weight:bold;vertical-align:middle">
                                            <input type="radio"     name="Click"    id="Click" value="4" style="vertical-align:middle;"    align="left">
                                            4
                                        </p>
                                    </td>
                                </tr>
                                    <tr    height=20>
                                    <td    bgcolor="#E5F2FF">
                                        <p style="font-family:verdana;color:#0000FF;font-size:11px;font-weight:bold;vertical-align:middle">
                                            <input type="radio"     name="Click"    id="Click" value="5" style="vertical-align:middle;"    align="left">
                                            5
                                        </p>
                                    </td>
                                </tr>
                                <tr    height=20>
                                    <td    bgcolor="#0000FF"    align=center>
                                        <input type=submit value=voter style="border-width:0px;border-color:#0000FF;color=#0000FF;background-color=#E5F2FF;font-family:verdana;font-size:11px;vertical-align:middle;">
                                        <input type="hidden" name="Clicks" value="1"> 
                                    </td>
                                </tr>
                                <tr    height=20>
                                    <td    bgcolor="#0000FF"    align=center>
                                        <p style="font-family:verdana;color:#E5F2FF;font-size:11px;font-weight:bold;vertical-align:middle;">
                                            <a href="">Résultat</a>
                                        </p>
                                    </td>
                                </tr>
                                <tr    height=20>
                                    <td    bgcolor="#0000FF"    align=center>
                                        <p style="font-family:verdana;color:#E5F2FF;font-size:11px;font-weight:bold;vertical-align:middle">
                                            <?php
                                                print"$_SERVER[REMOTE_ADDR]";
                                            ?>
                                        </p>
                                    </td>
                                </tr>
                                <tr    height=20>
                                    <td    bgcolor="#0000FF"    align=center>
                                        <p style="font-family:verdana;color:#E5F2FF;font-size:11px;font-weight:bold;vertical-align:middle">
                                            <?php
                                                print"$_SERVER[REMOTE_PORT]";
                                            ?>
                                        </p>
                                </td>
                            </tr>
                            </form> 
                         </table>
                        </td>
                    </tr>
                </table>
            </td>
 
        </tr>
    </table>
</div>
</body>
</html>