Scrivere in un file php aperto dal codice php!

crealatualista

Nuovo Utente
27 Feb 2017
19
0
1
29
Buonasera a tutti!
Sto riscontrando un problema nel scrivere nel file aperto da comando!
Questo è il codice:
PHP:
$file = "Utenti/$username.php";
$codice = "<html><head><title>Prova</title></head>
<body>benvenuto prova</body></html>";
$fo = fopen($file, "w");
fwrite($fo, $codice);
fclose($fo);
session_start();
if($fo){
    header("Location: Utenti/$username.php");
}

Il codice della pagina nuova, per non metterlo nella variabile $codice e di conseguenza nelle " " , come lo inserisco? Anche perché quello che devo inserire è abbastanza lungo!
Grazie spero che avete capito!
 
Ultima modifica di un moderatore:
Si scusami! Devo scrivere nella pagina creata questo:

<php>
<!DOCTYPE html>
<html>
<head>
<title>Visualizza</title>
<style>
.button {
display: inline-block;
border-radius: 4px;
background-color: #f4511e;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 28px;
padding: 20px;
width: 200px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}

.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}

.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}

.button:hover span {
padding-right: 25px;
}

.button:hover span:after {
opacity: 1;
right: 0;
}
input[type=text] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
div {
border-radius: 5px;
background-color: #f2f2f2;
padding: 20px;
font-family: verdana;
font-size: 20px;
}
</style>
</head>
<body>
<div>
<?php
if(!(isset($_POST['invio']))){
?>
<form action = "" method = "POST">
Iserisci il nome dell'evento:<p></p>
<input type = "text" name = "table"/><p></p>
<button class="button" style="vertical-align:middle" name = "invio"><span>Visualizza </span></button>
<?php
} else{
$vis_eve = $_POST['table'];
if($vis_eve == ""){
echo "Devi compilare il campo";
} else {
mysql_connect("localhost", "bootpi", "") or die(mysql_error());
mysql_select_db("my_bootpi") or die(mysql_error());
$result = mysql_query("SELECT * FROM $vis_eve") or die(mysql_error());
echo "<table>";
echo "<tr><th>Nome</th> <th>Cognome</th> <th>Partecipa</th></tr>";
while($row = mysql_fetch_array( $result )) {
echo "<tr>";
echo '<td>' . $row['nome'] . '</td>';
echo '<td>' . $row['cognome'] . '</td>';
echo '<td>' . $row['partecipa'] . '</td>';
echo "</tr>";
}
echo "</table>";
}
}
?>
</form>
</div>
</body>
</html>
<php>

però mi continua a dare errore! E quindi volevo trovare un modo per non scrivere tutto questo "sketch" nella variabile $codice...
si è capito?
 
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /membri/crealatualista/prova.php on line 132

questa è a la riga
:
if(!(isset($_POST['invio']))){
 
Ciao, è un problema di apici, utilizza i doppi nel codice e apri la variabile con i singoli
PHP:
$codice = '<input class="class"/> etc etc ';
 
Si Grazie dovevo togliere gli apici....
adesso mi da quest'altro errore:

Parse error: syntax error, unexpected end of file in /membri/crealatualista/prova.php on line 194
 

Discussioni simili