Script formular add
Scris: Lun Mar 28, 2011
Salut am facut un formular de adaugare referate si nu gasesc solutia greselii, adica imi merge totul bine dar nu imi adauga in baza de date "nivel, uploader, descriere" si nu imi dau seama de ce? In rest merge totul bine Daca ma poate ajuta cineva sa-mi arate unde am gresit!!!
Cod: Selectaţi tot
<?php
if(isset($_POST['submit']))
{
$titlu=$_POST['titlu'];
$categorie=$_POST['categorie'];
$nivel==$_POST['nivel'];
$uploader==$_POST['uploader'];
$descriere==$_POST['descriere'];
if($HTTP_POST_FILES['ufile']['type'] == ""){$eroare .="Adauga referatul";}else{
if($HTTP_POST_FILES['ufile']['type'] == "text/plain"){
$nume_digital=rand(000000,999999);
$link="www.Site-ulmeu.net_".$nume_digital.".txt";}else{
if($HTTP_POST_FILES['ufile']['type'] == "application/msword"){
$nume_digital=rand(000000,999999);
$link="www.Site-ulmeu.net_".$nume_digital.".doc";}else{
$eroare .="Extensie nepermisa";}}}
echo "<table class='informatii'>
<tr>
<td class='stanga'><img src='/imagini/icon_eroare.png' alt='eroare' /></td>
<td class='dreapta'>".$eroare."</td></tr></table>";
if($eroare==""){
$path= "../referate/".$link;
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
$sql="INSERT INTO referate (titlu, categorie, nivel, data_ad, link, uploader, descriere) VALUES ('" . $_POST['titlu'] . "','" . $categorie . "','" . $nivel . "',NOW(),'" . $link . "','" . $uploader . "','" . $descriere . "')";
$rezultat=mysql_query($sql)or die(mysql_Error());
if($rezultat){
echo "<table class='informatii'>
<tr>
<td class='stanga'><img src='/imagini/icon_ok.png' alt='ok' /></td>
<td class='dreapta'>Referat adaugat cu succes!</td></tr></table>";
}
}
else
{
echo "Eroare";
}
}} }
?>
<form action="/admin/" method="POST" enctype="multipart/form-data" name="form1" id="form1">
<table>
<tr><td><h2>Adauga:</h2></td></tr>
<input type="hidden" name="uploader" value="<? if($form->value("username") == ""){echo $session->userinfo['username'];}else{ echo $form->value("username");}?>">
<tr><td>Titlu:</td><td><input type="text" name="titlu" /></td></tr>
<tr><td>Categorie:</td><td><select name="categorie">
<option value=""></option>
<option value="albume">albume</option>
<option value="manele">manele</option>
<option value="romaneasca">romaneasca</option>
<option value="straina">straina</option>
<option value="house">house</option>
<option value="veche">veche</option>
<option value="petrecere">petrecere</option>
<option value="other">other</option>
<option value="copii">copii</option>
<option value="videoclipuri">videoclipuri</option>
</select></td></tr>
<tr><td>Nivel:</td><td><select name="nivel">
<option value=""></option>
<option value="gimnaziu">gimnaziu</option>
<option value="liceu">liceu</option>
<option value="facultate">facultate</option>
</select></td></tr>
<tr><td>Descriere:</td><td><textarea name="descriere" rows="10" cols="40"></textarea></td></tr>
<tr><td>Upload:</td><td><input type="file" name="ufile" id="ufile" /></td></tr>
<tr><td></td><td><br /><input type="submit" name="submit" value="Adauga" class="button" /></td></tr>
</table>
</form>