PHP: Formular
Verfasst: Di Jul 13, 2010 9:17 pm
Es handelt sich um folgenden Code:
index.php: (ausschnitt)
newVid.php:
Problem: $post ist NULL. Die einzige Ausgabe die stattfindet ist "Array( ) 1". Warum wird $_POST nicht mit Inhalt gefüllt?
index.php: (ausschnitt)
Code: Alles auswählen
echo('<center><TABLE background="'.$mainbg.'" width="800px"><TR><TD valign="top">
<center><H1><U>Ein Video Hochladen</U></h1></center>
<form action="newVid.php" method="post" enctype="multipart/form-data">
<pre>
<P>Name: <BR /> <input type="text" name="name" value="Videotitel" id="name" onclick="clearVidname()" size="95"></P>
<P>Zu folgendem Spiel: <BR /> <select name="game" size="1">');
$query="SELECT id, name FROM `game` ORDER BY `name` ASC";
$abfrage=$db->query($query, MYSQLI_STORE_RESULT);
while ($res=$abfrage->fetch_assoc())
{
echo('
<option value="'.$res["id"].'">'.$res["name"].'</option>');
};
echo('</select></P>
<P>Quelle: (falls vorhanden)<BR /> <input type="text" name="quelle" value="Quelle" id="que" onclick="clearQUE()" size="95"></P>
<P>Datei: <BR /> <input type="file" name="vid" size="80"></P>
<input type="submit" value="Hochladen" name="submit">
<small>Das Hochladen von Videos kann besonders lange dauern, da Videos oft sehr groß sind. Brechen sie den Prozess keinesfalls ab.<BR />
Bitte laden sie nur .mp4 Videos hoch. Video(Bitrate: bis 1800Kbit/s; Auflösung: bis 640:480); Audio(Bitrate: 128Kbit/s).</small>
</pre></form></TD></TR></TABLE></center>');
Code: Alles auswählen
<?php
if (is_array($_POST))
{
$post=$_POST;
}
else
{
$post=$HTTP_POST_VARS;
};
if (array_key_exists("name", $post))
{
$name=$post["name"];
}
else
{
$name=NULL;
};
if (array_key_exists("quelle", $post))
{
$Vidquelle=$post["quelle"];
if ($Vidquelle=="")
{
$Vidquelle=NULL;
};
}
else
{
$Vidquelle=NULL;
};
if (array_key_exists("game", $post))
{
$game=$post["game"];
}
else
{
$game=NULL;
};
if (is_array($_FILES))
{
$files=$_FILES;
}
else
{
$files=$HTTP_FILES_VARS;
};
if (array_key_exists("vid", $files))
{
$vid=$files["vid"];
}
else
{
$vid=NULL;
};
if (is_array($_SERVER))
{
$server=$_SERVER;
}
else
{
$server=$HTTP_SERVER_VARS;
};
die (print_r($post));
if ($name!=NULL and $vid!=NULL and $game!=NULL)
{
$db=new mysqli("localhost", "naums", "letsfetz", "oettinger-games");
$query="SELECT id FROM `game` WHERE `id`=$game";
$abfrage=$db->query($query, MYSQLI_STORE_RESULT);
$a=0;
while ($res=$abfrage->fetch_assoc())
{
$a++;
};
if ($a<1)
{
echo('<script language="javascript">location.href="index.php?position=new&form=vid";</script>');
};
$query="SELECT id FROM `vid` ORDER BY `id` ASC";
$abfrage=$db->query($query, MYSQLI_STORE_RESULT);
$a=0; $b=false; $c=0;
while ($res=$abfrage->fetch_assoc())
{
$a++;
if ($a!=$res["id"] and $b==false)
{
$b=true;
$c=$a;
};
};
if ($b==false)
{
$c=$a;
$c++;
};
$quelle=$vid["tmp_name"];
$between=explode("newVid.php", $server["SCRIPT_NAME"]);
$ziel=$server["DOCUMENT_ROOT"].$between[0].'vid/'.$c.'.mp4';
$filename='vid/'.$c.'.mp4';
if (copy($quelle, $ziel))
{
$query="INSERT INTO `vid` (id, name, src, game_id, quelle, system, width, height) VALUES ($c, '$name', '$filename', $game, '$Vidquelle', 'PC', 1,1)";
}
else
{
echo('<script language="javascript">location.href="index.php?position=new&form=vid";</script>');
};
}
else
{
echo('<script language="javascript">location.href="index.php?position=new&form=vid";</script>');
};
?>