Jump to content
php.lv forumi

Faila automātiska izveide


Cibiņš

Recommended Posts

Kā pie operācijas var padot lai izveido failu ar specifisku saturu?

 

Piemēram pie formas posta lai no lauka "name" paņem ierakstīto vērtību un attiecīgi tā arī failu izveido un nosauc - name.php un ievieto automātiski lapā skriptu kaukādu vai teikumu?

 

Cik nu sanāk lai izveido failu tā jau vispār sanāk, bet vienīgi ka kā lai dabon automātiski iekšā saturu kaukādu - piem tekstu "kaamis"?

 

$fails = "fails.php";
$failsHandle = fopen($fails, 'w') or die("ej kakaat");
fclose($failsHandle);

Edited by Cibiņš
Link to comment
Share on other sites

Bet kā panākt lai šis skrpts failā ievieto $content = "<?php....tipa no kveerija skriptu lai ieliek nevis veic kaukaadas mistiskas operaacijasa bet lai nedara neko un vienkarshi ieliek to skriptu tur?? Visu laiku balta lapa :(

 

$filename = $path_page.$pgname.".php";
$failsHandle = fopen($filename, 'w, r') or die("ej kakaat");

fclose($failsHandle);
$content = "
<?php $result = mysql_query('SELECT * FROM pg_pages WHERE pg=".$pg.");
while($row = mysql_fetch_array($result)){echo $row['data_$lang'];}
?>
";

if (is_writable($filename)) {
   if (!$handle = fopen($filename, 'a')) {
        echo "Nevar atveert failu ($filename)";
        exit;
   }

   if (fwrite($handle, $content) === false) {
       echo "Nevar ierakstiit informaaciju failaa ($filename)";
       exit;
   }
   fclose($handle);

} else {
   echo "Fails $filename nav rakstaams";
}

Edited by Cibiņš
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...