File e query sql per un sondaggio create in automatico
Salve, untente di AV.
ho appena finito l' area sondaggi nel mio sito, ora sto facendo uno script che mi aggiunge al db mysql la tabella relativa al sondaggio e che mi aggiorna la tabella predefinita del sondaggio e che mi crea il file php del sondaggio, ma mi da un errore nella funzione fopen, ora vi scrivo qui sotto il codice della pagina:
Codice PHP:
<?
if ($_POST["title"] == "") {
echo " " ;
echo "<script type=\"text/javascript\">alert('Tutti i campi devono avere un valore');</script>";
exit();
}
if ($_POST["file_s"] == "") {
echo " " ;
echo "<script type=\"text/javascript\">alert('Tutti i campi devono avere un valore');</script>";
exit();
}
if ($_POST["desc"] == "") {
echo " " ;
echo "<script type=\"text/javascript\">alert('Tutti i campi devono avere un valore');</script>";
exit();
}
$dsc = $_POST["desc"] ;
$files = $_POST["file_s"] ;
$titles = $_POST["title"] ;
$ext = "sondaggio_" ;
$nome = $_POST["file_s"] ;
$nameC = $ext.$nome ;
$nomeFile = $nome.'.php' ;
$query = "INSERT INTO sondaggio (Id, Stato, Titolo, Descrizione, Visibile, File) VALUE ('', '1', '$titles', '$dsc', '', '$nomeFile')" ;
$rs = mysql_query($query) ;
$mysql = "CREATE TABLE ".$nameC ;
$mysql .= " (id INT (5) UNSIGNED not null AUTO_INCREMENT, Ip LONGTEXT not null , PRIMARY KEY (id))";
$result = mysql_query($mysql) ;
$fp = fopen("sondaggi/$nomeFile", "w+") ;
fwrite($fp, "<?...?>");
fclose($fp) ;
?>
dov' è l' errore?
ah, quasi dimenticavo, ecco la pagina dov' è ho inserito il form:
Codice PHP:
<?
if ($_SESSION["username"] != "Jeak") {
echo "<div style='text-align:center; width:98%'><br><strong>Impossibile visualizare la pagina</strong><br />La pagina che si sta tentanto di aprire è riservata agli utenti del sito, effettuare il login per visualizare la pagina<br><a href='index.php?Dir=accedi' style='text-decoration:underline'>Vai al login</a><br> </div>" ;
} else {
?>
<style type="text/css">
<!--
.style3 {color: green}
-->
</style>
<table align="center" width="99%" cellpadding="1" cellspacing="1">
<tr>
<td style="border-bottom:groove #000022 1px">Sondaggi - <strong>Aggiungi sondaggio</strong> </td>
</tr>
<tr>
<td>
<center><form action="index.php?Dir=add_sondaggio1" method="post">
Titolo sondaggio : <input type="text" name="title" /><br />
Stato sondaggio : <input type="radio" checked="checked" disabled="disabled" />
<font color="green"><b>In corso... </b></font><em>( Da defoult )</em><br />
nome file sondaggio :
<input type="text" name="file_s" width="90" />
.php<br />
Descrizioni sondaggio<br />
<textarea name="desc"></textarea>
<br />
<input type="submit" value="Continua" />
</form>
</center>
</td>
</tr>
</table>
<? } ?>