Modifier un fichier texte depuis un php
Fermé
tenorian
Messages postés
258
Date d'inscription
lundi 13 avril 2009
Statut
Membre
Dernière intervention
3 mars 2014
-
11 mars 2013 à 01:04
astuces72 Messages postés 7717 Date d'inscription vendredi 15 janvier 2010 Statut Membre Dernière intervention 28 mars 2024 - 14 mars 2013 à 08:03
astuces72 Messages postés 7717 Date d'inscription vendredi 15 janvier 2010 Statut Membre Dernière intervention 28 mars 2024 - 14 mars 2013 à 08:03
A voir également:
- Modifier un fichier texte depuis un php
- Fichier rar - Guide
- Comment modifier un pdf - Guide
- Comment réduire la taille d'un fichier - Guide
- Fichier host - Guide
- Comment ouvrir un fichier epub ? - Guide
3 réponses
tenorian
Messages postés
258
Date d'inscription
lundi 13 avril 2009
Statut
Membre
Dernière intervention
3 mars 2014
18
11 mars 2013 à 01:10
11 mars 2013 à 01:10
pour le moment j en sui la
mon cadre texte
<form action='texte.php' method='post'><textarea name='textblock' rows='3' cols='40'></textarea><br><input type='submit' value='ajouter text'></form>
mon php qui modifi mon fichier texte
<?php
// Open the text file
$f = fopen("texte.txt", "w");
// Write text
fwrite($f, $_POST["textblock"]);
// Close the text file
fclose($f);
// Open file for reading, and read the line
$f = fopen("texte.txt", "r");
// Read text
echo fgets($f);
fclose($f);
?>
mon cadre texte
<form action='texte.php' method='post'><textarea name='textblock' rows='3' cols='40'></textarea><br><input type='submit' value='ajouter text'></form>
mon php qui modifi mon fichier texte
<?php
// Open the text file
$f = fopen("texte.txt", "w");
// Write text
fwrite($f, $_POST["textblock"]);
// Close the text file
fclose($f);
// Open file for reading, and read the line
$f = fopen("texte.txt", "r");
// Read text
echo fgets($f);
fclose($f);
?>
tenorian
Messages postés
258
Date d'inscription
lundi 13 avril 2009
Statut
Membre
Dernière intervention
3 mars 2014
18
14 mars 2013 à 02:21
14 mars 2013 à 02:21
up
astuces72
Messages postés
7717
Date d'inscription
vendredi 15 janvier 2010
Statut
Membre
Dernière intervention
28 mars 2024
1 637
Modifié par astuces72 le 14/03/2013 à 08:08
Modifié par astuces72 le 14/03/2013 à 08:08
hello
Tu te fais une page "admin.php", tu ouvres ton fichier texte dans une textarea, ensuite tu l'enregistres dans ce même ficher:
tu pourras modifier le texte et la ligne que tu veux !
Tu te fais une page "admin.php", tu ouvres ton fichier texte dans une textarea, ensuite tu l'enregistres dans ce même ficher:
<input name="BTN_envoi" type="submit" value="Enregistrement" /> </form> <textarea name="texte" cols="80" rows="8"><? if (!$fp = fopen("texte.txt","r")) { echo "Echec ouverture fichier"; exit; } else { while(!feof($fp)) { $Ligne = fgets($fp,255); echo $Ligne; $Fichier .= $Ligne; } fclose($fp); } ?> <input type="submit" name="Btn_envoi"value="Envoyer" /> </form>
<?php if (isset($_GET['BTN_envoi'])) { $texte= stripslashes($_GET['texte']); $fp = fopen("texte.txt","w"); fwrite($fp, $texte); fclose($fp); } ?>
tu pourras modifier le texte et la ligne que tu veux !