PHP-Code:
<?php require_once('Connections/test.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO test (id, name, vorname, datum, ip, bild, upload1, upload2) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['vorname'], "text"),
GetSQLValueString($_POST['datum'], "text"),
GetSQLValueString($_POST['ip'], "text"),
GetSQLValueString($_FILES['bild']['name'], "text"),
GetSQLValueString($_FILES['upload1']['name'], "text"),
GetSQLValueString($_FILES['upload2']['name'], "text"));
mysql_select_db($database_test, $test);
$Result1 = mysql_query($insertSQL, $test) or die(mysql_error());
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Unbenanntes Dokument</title>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Name:</td>
<td><input type="text" name="name" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Vorname:</td>
<td><input type="text" name="vorname" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Bild:</td>
<td>
<input type="file" name="bild" id="fileField" /></td>
<?php // Configuration - Your Options
$allowed_filetypes = array('.jpg','.gif','.bmp','.png','.pdf'); // These will be the types of file that will pass the validation.
$max_filesize = 5242880; // Maximum filesize in BYTES (currently 5.0 MB).
$upload_path = ''; // The place the files will be uploaded to (currently a 'files' directory).
$filename = $_FILES['bild']['name']; // Get the name of the file (including file extension).
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename.
// Upload the file to your specified path.
if(move_uploaded_file($_FILES['bild']['tmp_name'],$upload_path . $filename))?>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Upload1:</td>
<td><label>
<input type="file" name="upload1" id="fileField2" />
<?php // Configuration - Your Options
$allowed_filetypes = array('.jpg','.gif','.bmp','.png','.pdf'); // These will be the types of file that will pass the validation.
$max_filesize = 5242880; // Maximum filesize in BYTES (currently 5.0 MB).
$upload_path = ''; // The place the files will be uploaded to (currently a 'files' directory).
$filename = $_FILES['upload1']['name']; // Get the name of the file (including file extension).
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename.
// Upload the file to your specified path.
if(move_uploaded_file($_FILES['upload1']['tmp_name'],$upload_path . $filename))?>
</label></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Upload2:</td>
<td><input type="file" name="upload2" id="fileField3" /></td>
<?php // Configuration - Your Options
$allowed_filetypes = array('.jpg','.gif','.bmp','.png','.pdf'); // These will be the types of file that will pass the validation.
$max_filesize = 5242880; // Maximum filesize in BYTES (currently 5.0 MB).
$upload_path = ''; // The place the files will be uploaded to (currently a 'files' directory).
$filename = $_FILES['upload2']['name']; // Get the name of the file (including file extension).
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename.
// Upload the file to your specified path.
if(move_uploaded_file($_FILES['upload2']['tmp_name'],$upload_path . $filename))?>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Datensatz einfügen" /></td>
</tr>
</table>
<input type="hidden" name="id" value="" />
<input type="hidden" name="datum" value="<?PHP=time(); ?>" />
<input type="hidden" name="ip" value="<?PHP=$_SERVER["REMOTE_ADDR"];?>" />
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</body>
</html>
Die IP - Adresse <input type="hidden" name="ip" value="<?PHP=$_SERVER["REMOTE_ADDR"];?>" />