Simple NoPaste

Stato
Discussione chiusa ad ulteriori risposte.

imported_opocaj

Utente Silver
18 Dicembre 2007
215
10
0
98
Ciao. È da un sacco che non posto più niente e da ancora più che non codo niente, ma mi è ripresa un pizzico di voglia e (tempo permettendo per studiare) vorrei riprendere. E quindi cosa ho fatto? Mi sono messo a creare un rudimentale NoPaste, così tanto per riprenderci la mano. Solo che non mi funziona (IE mi dice che c'è un errore nel codice, ma non lo trovo).
nopaste.php
PHP:
<html>
 <head>
 </head>
 <body>
<?php
$author=htmlentities($_POST['author']);
$title=htmlentities($_POST['title']);
$lang=htmlentities($_POST['language']);
$code=htmlentities($_POST['code']);
$name=$author+$title+(string) rand(0, 1000)+'.html';
while (file_exists($name)) {
  $name=$author+$title+(string) rand(0, 1000)+'.html';
}
$file=fopen($name, 'w');
fwrite($file, '<html>
<head>
<title>'+$title+' by '+$author+'</title>
</head>
<body>
Linguaggio: '+$lang'+'<br>
Codice: <div>'+$code+'</div>
</body>
</html>');
fclose($file);
header('Location: '+'http://localhost/'+$name);
?>
</body>
</html>
Vi chiedo aiuto (e scusatemi per la lunga assenza, ora voglio tornare a fare casino su questo forum xD).
 
RE: Problemino PHP

Azz, in VB6 (l'unico linguaggio che ricordo perché lo faccio a scuola) è +... Correggo e vedo...
EDIT: funziona... Devo proprio riprenderci la mano xD Scusatemi per la cavolata...

Senza creare altre discussioni posto direttamente qui il "lavoro" completo:
form.html
Codice:
<html>
<head>
<title>NoPaste</title>
</head>
<body>
<center>
<form action="nopaste.php" method="POST">
Autore: 
<input type="text" name="author">
<br>
<br>
Linguaggio: 
<input type="text" name="language">
<br>
<br>
Titolo:
<input type="text" name="title">
<br>
<br>
Codice:
<br>
<textarea cols=100 rows=50 name="code">
</textarea>
<br>
<br>
<input type="submit" value="Salva">
</form>
</center>
</body>
</html>
nopaste.php
PHP:
 <html>
 <head>
 </head>
 <body>
<?php
$author=htmlentities($_POST['author']);
$title=htmlentities($_POST['title']);
$lang=htmlentities($_POST['language']);
$code=htmlentities($_POST['code']);
$name=$author.$title.(string) rand(0, 1000).'.html';
while (file_exists($name)) {
  $name=$author.$title.(string) rand(0, 1000).'.html';
}
$file=fopen($name, 'w');
fwrite($file, '<html>
<head>
<title>'.$title.' by '.$author.'</title>
</head>
<body>
<center>
Autore: '.$author.'<br><br>
Titolo: '.$title.'<br><br>
Linguaggio: '.$lang.'<br><br>
Codice:<br>
<textarea cols=100 rows=50 readonly>'.$code.'</textarea>
</center>
</body>
</html>');
fclose($file);
header('Location: http://localhost/'.$name);
?>
</body>
</html>
 
Stato
Discussione chiusa ad ulteriori risposte.