| Neuer Benutzer
Registriert seit: 05.11.2010
Beiträge: 3
PHP-Kenntnisse: Anfänger
| PHP-Datei Upload und pfad Eintrag in Datenbank Hallo allerseids,
ich bin neu hier und darum stelle ich mich ersteinmal vor!
Also mein Name ist Danny, ich bin 29Jahre alt (bald 30 :-s) und versuche gerade eine Datenbank + dazugehoeriges webinterface zu basteln. Zu meinen php und mysql Kenntnissen ist mein als "Anfaenger" geposteter Status noch total uebertrieben.
Also wie gesagt ich habe eine MySQL Datenbank und hierfuer haenge ich gerade (seid 3Tagen) an einer Stelle fest. Ich versuche in ein Aktualisierungsformular ein Dateifeld einzufuegen, so das die darin befindliche Datei auf den Server hochgeladen wird (in den Ordner uploads z.B.), dabei so umbenannt wird, das sie wirklich nur einmal vorhanden ist und der link zu dieser Datei anschliessend in der Tabelle "antibodies", in der richtigen Zeile (Schluessel ist hier die ID, wie bei den anderen Daten auch, die durch das Formular aktualisiert werden) in der Spalte "ImgA" geschrieben wird.
Ich habe schon soviel gelesen und gesucht...aber ich werde aus alle dem nicht schlau.
Also wenn mir einer von euch Profi php'lern da draussen damit helfen koennte waehre das echt super. Ich poste hier mal den ganzen code der Aktualisierungsseite, weil ich nicht genau weiss, was wichtig ist und was nicht!
Das Daeifeld heisst ebenfalls ImGA... PHP-Code: <?php require_once('../Connections/ab_stock.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "admin";
$MM_donotCheckaccess = "false";
$target = "./ab-stock/uploads/";
$target = $target . basename( $_FILES['ImgA']['name']);
$ImgA=($_FILES['ImgA']['name']);
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "adminonly.html";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?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_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE antibody SET TargetAG=%s, TargetSpecies=%s, `Host`=%s, Isotype=%s, StainIndex=%s, Dilution=%s, Conjugate=%s, MolW=%s, UnitsInStock=%s, SupplierID=%s, OrderID=%s, Price=%s, ImgA=%s, Rating=%s, Description_1=%s, Description_2=%s, Description_3=%s, Description_1Header=%s, Description_2Header=%s, Description_3Header=%s, Notes=%s, Clone=%s, `References`=%s WHERE ID=%s",
GetSQLValueString($_POST['TargetAG'], "text"),
GetSQLValueString($_POST['TargetSpecies'], "text"),
GetSQLValueString($_POST['Host'], "text"),
GetSQLValueString($_POST['Isotype'], "text"),
GetSQLValueString($_POST['StainIndex'], "text"),
GetSQLValueString($_POST['Dilution'], "text"),
GetSQLValueString($_POST['Conjugate'], "text"),
GetSQLValueString($_POST['MolW'], "text"),
GetSQLValueString($_POST['UnitsInStock'], "text"),
GetSQLValueString($_POST['SupplierID'], "text"),
GetSQLValueString($_POST['OrderID'], "text"),
GetSQLValueString($_POST['Price'], "text"),
GetSQLValueString($_POST['$ImgA'], "text"),
GetSQLValueString($_POST['Rating'], "text"),
GetSQLValueString($_POST['Description_1'], "text"),
GetSQLValueString($_POST['Description_2'], "text"),
GetSQLValueString($_POST['Description_3'], "text"),
GetSQLValueString($_POST['Description_1Header'], "text"),
GetSQLValueString($_POST['Description_2Header'], "text"),
GetSQLValueString($_POST['Description_3Header'], "text"),
GetSQLValueString($_POST['Notes'], "text"),
GetSQLValueString($_POST['Clone'], "text"),
GetSQLValueString($_POST['References'], "text"),
GetSQLValueString($_POST['ID'], "int"));
mysql_select_db($database_ab_stock, $ab_stock);
$Result1 = mysql_query($updateSQL, $ab_stock) or die(mysql_error());
$updateGoTo = "works(test).html";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$maxRows_DetailRS1 = 1;
$pageNum_DetailRS1 = 0;
if (isset($_GET['pageNum_DetailRS1'])) {
$pageNum_DetailRS1 = $_GET['pageNum_DetailRS1'];
}
$startRow_DetailRS1 = $pageNum_DetailRS1 * $maxRows_DetailRS1;
$colname_DetailRS1 = "-1";
if (isset($_GET['recordID'])) {
$colname_DetailRS1 = $_GET['recordID'];
}
mysql_select_db($database_ab_stock, $ab_stock);
$query_DetailRS1 = sprintf("SELECT * FROM antibody WHERE ID = %s", GetSQLValueString($colname_DetailRS1, "int"));
$query_limit_DetailRS1 = sprintf("%s LIMIT %d, %d", $query_DetailRS1, $startRow_DetailRS1, $maxRows_DetailRS1);
$DetailRS1 = mysql_query($query_limit_DetailRS1, $ab_stock) or die(mysql_error());
$row_DetailRS1 = mysql_fetch_assoc($DetailRS1);
if (isset($_GET['totalRows_DetailRS1'])) {
$totalRows_DetailRS1 = $_GET['totalRows_DetailRS1'];
} else {
$all_DetailRS1 = mysql_query($query_DetailRS1);
$totalRows_DetailRS1 = mysql_num_rows($all_DetailRS1);
}
$totalPages_DetailRS1 = ceil($totalRows_DetailRS1/$maxRows_DetailRS1)-1;
mysql_select_db($database_ab_stock, $ab_stock);
$query_rslogin = "SELECT * FROM login";
$rslogin = mysql_query($query_rslogin, $ab_stock) or die(mysql_error());
$row_rslogin = mysql_fetch_assoc($rslogin);
$totalRows_rslogin = mysql_num_rows($rslogin);
mysql_select_db($database_ab_stock, $ab_stock);
$query_rsDyes = "SELECT * FROM dyes";
$rsDyes = mysql_query($query_rsDyes, $ab_stock) or die(mysql_error());
$row_rsDyes = mysql_fetch_assoc($rsDyes);
$totalRows_rsDyes = mysql_num_rows($rsDyes);
mysql_select_db($database_ab_stock, $ab_stock);
$query_rsSupplier = "SELECT SupplierName FROM supplier";
$rsSupplier = mysql_query($query_rsSupplier, $ab_stock) or die(mysql_error());
$row_rsSupplier = mysql_fetch_assoc($rsSupplier);
$totalRows_rsSupplier = mysql_num_rows($rsSupplier);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><!-- InstanceBegin template="/Templates/theme_01_design.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="Titel" -->
<title>Update</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Designed and developed by Codify Design Studio - codifydesign.com"/>
<link rel="stylesheet" type="text/css" href="Publish/stylesheet.css" />
<script src="Publish/SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="Publish/SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<!-- InstanceParam name="RightSidebar" type="boolean" value="false" -->
</head>
<body>
<div class="bannerArea">
<div class="container">
<div class="bannernav"><a href="#" >Privacy Policy</a> • <a href="#" >Contact Us</a> • <a href="#" >Site Map</a></div>
<div class="toplogo"><a href="#"><img src="Publish/images/banner_logo.gif" border="0"/></a></div>
<div style="clear:both;"></div>
</div>
</div>
<div class="topnavigationArea">
<div class="container">
<div class="topnavigationgroup">
<ul id="MenuBar1" class="MenuBarHorizontal">
<li><a class="MenuBarItemSubmenu" href="#">Praesent vitae ligula</a>
<ul>
<li><a href="#">Item 1.1</a></li>
<li><a href="#">Item 1.2</a></li>
<li><a href="#">Item 1.3</a></li>
</ul>
</li>
<li><a href="#">Nec orci pretium</a></li>
<li><a class="MenuBarItemSubmenu" href="#">Vestibulum aecenas</a>
<ul>
<li><a class="MenuBarItemSubmenu" href="#">Item 3.1</a>
<ul>
<li><a href="#">Item 3.1.1</a></li>
<li><a href="#">Item 3.1.2</a></li>
</ul>
</li>
<li><a href="#">Item 3.2</a></li>
<li><a href="#">Item 3.3</a></li>
</ul>
</li>
<li style="border-right-style: solid;"><a href="#">Tmpus dictum</a></li>
</ul>
</div>
<div style="clear:both;"></div>
</div>
</div>
<div class="contentArea">
<div class="container"><!-- InstanceBeginEditable name="MainContent" -->
<div class="contentleftonly">
<table width="100%" border="0" align="left" cellpadding="2" cellspacing="5">
<tr class="bannernav">
<th width="57%" scope="col"><p> </p>
<table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td>
<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">ID:</td>
<td><?php echo $row_DetailRS1['ID']; ?></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">TargetAG:</td>
<td><input name="TargetAG" type="text" id="TargetAG" value="<?php echo $row_DetailRS1['TargetAG']; ?>" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">TargetSpecies:</td>
<td><input type="text" name="TargetSpecies" value="<?php echo htmlentities($row_DetailRS1['TargetSpecies'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Host:</td>
<td><input type="text" name="Host" value="<?php echo htmlentities($row_DetailRS1['Host'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Isotype:</td>
<td><input type="text" name="Isotype" value="<?php echo htmlentities($row_DetailRS1['Isotype'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">StainIndex:</td>
<td><input type="text" name="StainIndex" value="<?php echo htmlentities($row_DetailRS1['StainIndex'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Dilution:</td>
<td><input type="text" name="Dilution" value="<?php echo htmlentities($row_DetailRS1['Dilution'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Conjugate:</td>
<td><select name="Conjugate">
<?php
do {
?>
<option value="<?php echo $row_rsDyes['Fluoro']?>"<?php if (!(strcmp($row_rsDyes['Fluoro'], htmlentities($row_DetailRS1['Conjugate'], ENT_COMPAT, 'UTF-8')))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsDyes['Fluoro']?></option>
<?php
} while ($row_rsDyes = mysql_fetch_assoc($rsDyes));
$rows = mysql_num_rows($rsDyes);
if($rows > 0) {
mysql_data_seek($rsDyes, 0);
$row_rsDyes = mysql_fetch_assoc($rsDyes);
}
?>
</select></td>
</tr>
<tr> </tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">MolW:</td>
<td><input type="text" name="MolW" value="<?php echo htmlentities($row_DetailRS1['MolW'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">UnitsInStock:</td>
<td><input type="text" name="UnitsInStock" value="<?php echo htmlentities($row_DetailRS1['UnitsInStock'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">SupplierID:</td>
<td><select name="SupplierID">
<?php
do {
?>
<option value="<?php echo $row_rsSupplier['SupplierName']?>" <?php if (!(strcmp($row_rsSupplier['SupplierName'], htmlentities($row_DetailRS1['SupplierID'], ENT_COMPAT, 'UTF-8')))) {echo "SELECTED";} ?>><?php echo $row_rsSupplier['SupplierName']?></option>
<?php
} while ($row_rsSupplier = mysql_fetch_assoc($rsSupplier));
?>
</select></td>
</tr>
<tr> </tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">OrderID:</td>
<td><input type="text" name="OrderID" value="<?php echo htmlentities($row_DetailRS1['OrderID'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Price:</td>
<td><input type="text" name="Price" value="<?php echo htmlentities($row_DetailRS1['Price'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Rating:</td>
<td valign="baseline"><table>
<tr>
<td><input type="radio" name="Rating" value="0" <?php if (!(strcmp(htmlentities($row_DetailRS1['Rating'], ENT_COMPAT, 'UTF-8'),0))) {echo "checked=\"checked\"";} ?> />
Schaltfläche1</td>
</tr>
<tr>
<td><input type="radio" name="Rating" value="1" <?php if (!(strcmp(htmlentities($row_DetailRS1['Rating'], ENT_COMPAT, 'UTF-8'),1))) {echo "checked=\"checked\"";} ?> />
Schaltfläche2</td>
</tr>
<tr>
<td><input type="radio" name="Rating" value="2" <?php if (!(strcmp(htmlentities($row_DetailRS1['Rating'], ENT_COMPAT, 'UTF-8'),2))) {echo "checked=\"checked\"";} ?> />
Schaltfläche3</td>
</tr>
<tr>
<td><input type="radio" name="Rating" value="3" <?php if (!(strcmp(htmlentities($row_DetailRS1['Rating'], ENT_COMPAT, 'UTF-8'),3))) {echo "checked=\"checked\"";} ?> />
Schaltfläche4</td>
</tr>
<tr>
<td><input type="radio" name="Rating" value="4" <?php if (!(strcmp(htmlentities($row_DetailRS1['Rating'], ENT_COMPAT, 'UTF-8'),4))) {echo "checked=\"checked\"";} ?> />
Schaltfläche5</td>
</tr>
<tr>
<td><input type="radio" name="Rating" value="5" <?php if (!(strcmp(htmlentities($row_DetailRS1['Rating'], ENT_COMPAT, 'UTF-8'),5))) {echo "checked=\"checked\"";} ?> />
Schaltfläche6</td>
</tr>
</table></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right" valign="top">Description_1:</td>
<td><textarea name="Description_1" cols="50" rows="5"><?php echo htmlentities($row_DetailRS1['Description_1'], ENT_COMPAT, 'UTF-8'); ?></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right" valign="top">Description_2:</td>
<td><textarea name="Description_2" cols="50" rows="5"><?php echo htmlentities($row_DetailRS1['Description_2'], ENT_COMPAT, 'UTF-8'); ?></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right" valign="top">Description_3:</td>
<td><textarea name="Description_3" cols="50" rows="5"><?php echo htmlentities($row_DetailRS1['Description_3'], ENT_COMPAT, 'UTF-8'); ?></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Description_1Header:</td>
<td><input type="text" name="Description_1Header" value="<?php echo htmlentities($row_DetailRS1['Description_1Header'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Description_2Header:</td>
<td><input type="text" name="Description_2Header" value="<?php echo htmlentities($row_DetailRS1['Description_2Header'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Description_3Header:</td>
<td><input type="text" name="Description_3Header" value="<?php echo htmlentities($row_DetailRS1['Description_3Header'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right" valign="top">Notes:</td>
<td><textarea name="Notes" cols="50" rows="5"><?php echo htmlentities($row_DetailRS1['Notes'], ENT_COMPAT, 'UTF-8'); ?></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Clone:</td>
<td><input type="text" name="Clone" value="<?php echo htmlentities($row_DetailRS1['Clone'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right" valign="top">References:</td>
<td><textarea name="References" cols="50" rows="5"><?php echo htmlentities($row_DetailRS1['References'], ENT_COMPAT, 'UTF-8'); ?></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><p>
<label for="FileA"></label>
</p>
<p>
<label for="ImgB"></label>
<label for="ImgA2"></label>
</p>
<p>
<label for="ImgC"></label>
<input name="ImgA" type="file" id="ImgA" value="<?php echo $row_DetailRS1['ImgA']; ?>" />
</p>
<p>
<label for="ImgD"></label>
</p>
<p>
<label for="ImgD"></label>
</p>
<p></p>
<p> </p>
<p>
<input type="submit" value="Datensatz aktualisieren" />
</p></td>
</tr>
</table>
<input type="hidden" name="ID" value="<?php echo $row_DetailRS1['ID']; ?>" />
<input type="hidden" name="MM_update" value="form1" />
</form>
<p> </p></td>
<td> </td>
</tr>
</table>
<p></th>
</tr>
</table>
</div>
<!-- InstanceEndEditable -->
<div style="clear:both;"></div>
</div>
</div>
<div class="footerArea">
<div class="container">
<div class="copyright">© 2010 FlowCytometryEpalinges. All rights reserved.</div>
</div>
</div>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
<!-- InstanceEnd --></html><?php
mysql_free_result($DetailRS1);
mysql_free_result($rslogin);
mysql_free_result($rsDyes);
mysql_free_result($rsSupplier);
?>
Geändert von Danny2005 (05.11.2010 um 19:26 Uhr).
Grund: falscher Code :-S
|