[php] Schrijven naar txt file

Pagina: 1
Acties:

  • mark_gl
  • Registratie: September 2001
  • Laatst online: 23:18
Ik heb dit maar het werkt niet, hij schrijft niks naar de file weet iemand waarom?
PHP:
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?
if ($submit == "Verstuur") {

$LogBestand = "mail.txt"; 

$file_open = fopen($LogBestand, "w"); 
$file_write = fwrite($file_open, "Geslacht: $geslacht\nNaam: $Naam\n Adres: $adres\n Postcode: $postcode Woonplaats: $Woonplaats\n Prive: $Prive GSM: $GSM\nE-mail: $Email\n\n"); 
fclose($file_open);
}
?>


<html>
<head>
<title>Drop Inn</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<style type="text/css">
<!--
A {  text-decoration: none}
a:hover {  text-decoration: underline}
-->
</style>
</head>

<body bgcolor="#FFFFFF" background="bg.jpg"
bgProperties=fixed leftMargin=0 topMargin=0 marginwidth="0" marginheight="0">

<table cellspacing="0" cellpadding="0" border="0">
  <tr>
    <td width="116" height="16" valign="top"></td>
    <td width="532" height="16" valign="top"></td>
  </tr>
  <tr>
    <td width="116" height="541" valign="top"></td>
    <td width="532" height="541" valign="top"> 
      <form method="post" enctype="multipart/form-data" method="post" action="mail.php">
        <table width="514" border="0" cellspacing="0" cellpadding="0">
      <tr> 
        <td width="157" bgcolor="#CC0000" height="20"><b>UW GEGEVENS </b></td>
        <td colspan="2" bgcolor="#CC0000" height="20"></td>
        <td width="24" bgcolor="#CC0000" height="20"></td>
      </tr>
      <tr> 
        <td width="157" bgcolor="#FF6666" height="27"><b>Geslacht</b></td>
        <td width="93" valign="middle" bgcolor="#FF9999" height="27"><b>Man</b> 
          <input type="radio" value="man" name="geslacht">
          </td>
        <td width="240" valign="middle" bgcolor="#FF9999" height="27"><b>Vrouw</b> 
          <input type="radio" value="vrouw" name="geslacht">
          </td>
        <td width="24" bgcolor="#FF9999" height="27"></td>
      </tr>
      <tr> 
        <td width="157" bgcolor="#FF6666"><b></b></td>
        <td colspan="2" bgcolor="#FF9999">&amp;nbsp;</td>
        <td width="24" bgcolor="#FF9999">&amp;nbsp;</td>
      </tr>
      <tr> 
        <td width="157" bgcolor="#FF6666"><b>Naam</b></td>
        <td colspan="2" bgcolor="#FF9999">  
              <input type="text" name="Naam" size="50">
          </td>
        <td width="24" bgcolor="#FF9999"></td>
      </tr>
      <tr> 
        <td width="157" bgcolor="#FF6666"><b>Adres</b></td>
        <td colspan="2" bgcolor="#FF9999"> 
              <input type="text" name="Adres" size="50">
          </td>
        <td width="24" bgcolor="#FF9999"></td>
      </tr>
      <tr> 
        <td width="157" bgcolor="#FF6666"><b>Postcode</b></td>
        <td colspan="2" bgcolor="#FF9999"> 
              <input type="text" name="Postcode" size="50">
          </td>
        <td width="24" bgcolor="#FF9999"></td>
      </tr>
      <tr> 
        <td width="157" bgcolor="#FF6666"><b>Woonplaats</b></td>
        <td colspan="2" bgcolor="#FF9999"> 
              <input type="text" name="Woonplaats" size="50">
          </td>
        <td width="24" bgcolor="#FF9999"></td>
      </tr>
      <tr> 
        <td width="157" bgcolor="#FF6666"><b>Telefoon 
          priv&amp;eacute; </b></td>
        <td colspan="2" bgcolor="#FF9999"> 
              <input type="text" name="Prive" size="10" maxlength="10">
          </td>
        <td width="24" bgcolor="#FF9999"></td>
      </tr>
      <tr> 
        <td width="157" bgcolor="#FF6666"><b>Gsm</b></td>
        <td colspan="2" bgcolor="#FF9999"> 
              <input type="text" name="GSM" size="10" maxlength="10">
          <i>(nodig voor SMS-dienst)</i></td>
        <td width="24" bgcolor="#FF9999"></td>
      </tr>
      <tr> 
        <td width="157" bgcolor="#FF6666"><b></b></td>
        <td colspan="2" bgcolor="#FF9999"></td>
        <td width="24" bgcolor="#FF9999"></td>
      </tr>
      <tr> 
        <td width="157" bgcolor="#FF6666"><b>Email</b></td>
        <td colspan="2" bgcolor="#FF9999"> 
              <input type="text" name="email" size="50">
          </td>
        <td width="24" bgcolor="#FF9999"></td>
      </tr>
      <tr> 
        <td width="157" bgcolor="#FF6666"><b>AS</b></td>
        <td colspan="2" bgcolor="#FF9999"></td>
        <td width="24" bgcolor="#FF9999"></td>
      </tr>
      <tr> 
        <td width="157" bgcolor="#FF6666"><b></b></td>
        <td colspan="2" bgcolor="#FF9999"></td>
        <td width="24" bgcolor="#FF9999"></td>
      </tr>
      <tr> 
        <td width="157" bgcolor="#FF6666"><b></b></td>
        <td colspan="2" bgcolor="#FF9999"></td>
        <td width="24" bgcolor="#FF9999"></td>
      </tr>
      <tr>
        <td width="157">&amp;nbsp;</td>
        <td colspan="2">&amp;nbsp;</td>
        <td width="24">&amp;nbsp;</td>
      </tr>
      <tr> 
        <td width="157"></td>
        <td colspan="2">  
          <input type="submit" name="submit" value="Verstuur">
          <input type="reset" name="reset" value="Wissen">
          </td>
        <td width="24"></td>
      </tr>
    </table>
  </form>
</td>
  </tr>
  <tr>
    <td width="116" height="1" valign="top">[img]"transparent.gif"></td>
[/img][img]"transparent.gif"></td>
[/img]
</table>
</body>
</html>
?>

  • _-= Erikje =-_
  • Registratie: Maart 2000
  • Laatst online: 09-09 15:42
en met echo ipv fwrite?

(geen foutmeldingen? php in safe mode?)

Verwijderd

wat doet ie dan wel?
Maybe ff chmodden :P

  • D2k
  • Registratie: Januari 2001
  • Laatst online: 31-08 10:19

D2k

en ajb [ php] en [ /php] om je code heen :)

Doet iets met Cloud (MS/IBM)


  • mark_gl
  • Registratie: September 2001
  • Laatst online: 23:18
chmodden is niet nodig, want ik heb alle rechten
fwrite is juist nodig om in een file te schrijven, maar hij maakt geen file aan en schrijft er ook niks in

  • _-= Erikje =-_
  • Registratie: Maart 2000
  • Laatst online: 09-09 15:42
[knip van php.net]
$fp = fopen ("php.txt", "aw");
$fwrite ("$name, $date, $title, $news);
fclose ($fp);
[/knip]

[nog een knipje]
int fwrite (int fp, string string, int [length])

Note: On systems which differentiate between binary and text files (i.e. Windows) the file must be opened with 'b' included in fopen() mode parameter.
[/knip]

  • Limhes
  • Registratie: Oktober 2001
  • Laatst online: 19-08 19:06
PHP:
1
2
3
<?
if ($submit == "Verstuur") {
?>

volgens mij gaat ie hier fout; zet er es een echo na zodat je wel ziet of hij deze expressie juist evalueert

  • _-= Erikje =-_
  • Registratie: Maart 2000
  • Laatst online: 09-09 15:42
je kan ook gewoon ff tjekke op $naam oid

ifset($naam)
{}

  • elnino
  • Registratie: Augustus 2001
  • Laatst online: 03-09 05:13
Op dinsdag 30 oktober 2001 18:50 schreef _-= Erikje =-_ het volgende:
[knip van php.net]
$fp = fopen ("php.txt", "aw");
$fwrite ("$name, $date, $title, $news);
fclose ($fp);
[/knip]
Let vooral op de volgende regel:
code:
1
$fwrite ("$name, $date, $title, $news);

er mist een " (achter $news)... gaat dus niet werken...

(Ik zeg het maar even voor de n00bs onder ons...)

  • _-= Erikje =-_
  • Registratie: Maart 2000
  • Laatst online: 09-09 15:42
idd, ik zie het, is toch echt c&p van php.net...

  • Erik Jan
  • Registratie: Juni 1999
  • Niet online

Erik Jan

Langzaam en zeker

De tijd dat POST/GET variabelen standaard als normale variabelen werden aangemaakt is al voorbij, waarschijnlijk gebruik je PHP4 waar dit standaard uit staat. Verander daarom je PHP in dit stukje:
PHP:
1
2
3
4
5
6
7
8
<?
if ($HTTP_POST_VARS["submit"] == "Verstuur") {
  $LogBestand = "mail.txt";
  $file_open = fopen($LogBestand, "w");
  $file_write = fwrite($file_open, "Geslacht: $HTTP_POST_VARS[geslacht]\nNaam: $HTTP_POST_VARS[Naam]\n Adres: $HTTP_POST_VARS[adres]\n Postcode: $HTTP_POST_VARS[postcode] Woonplaats: $HTTP_POST_VARS[Woonplaats]\n Prive: $HTTP_POST_VARS[Prive] GSM: $HTTP_POST_VARS[GSM]\nE-mail: $HTTP_POST_VARS[Email]\n\n");
  fclose($file_open);
}
?>

ps. sorry voor de opgeFOKte layout :'(
EJ

This can no longer be ignored.


  • mark_gl
  • Registratie: September 2001
  • Laatst online: 23:18
Scripte werkte wel, ik moest alleen de txt file ch modden, toch bedankt

  • flat
  • Registratie: Mei 2000
  • Niet online
Op dinsdag 30 oktober 2001 18:37 schreef mark_gl het volgende:
chmodden is niet nodig, want ik heb alle rechten
fwrite is juist nodig om in een file te schrijven, maar hij maakt geen file aan en schrijft er ook niks in
Op woensdag 31 oktober 2001 10:48 schreef mark_gl het volgende:
Scripte werkte wel, ik moest alleen de txt file ch modden, toch bedankt
goed bezig jij! :P

"Happiness is a way of travel, not a destination."
--Roy Goodman

Pagina: 1