Ja det har jeg, men nu har jeg et problem:
tilfoej_nyhed.php:
-----------------
<?php require_once('../Connections/xtremegamers.php'); ?><?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 nyhed (overskrift, synopsis, tekst, forfatter) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['overskrift'], "text"),
GetSQLValueString($_POST['synopsis'], "text"),
GetSQLValueString($_POST['tekst'], "text"),
GetSQLValueString($_POST['forfatter'], "text"));
mysql_select_db($database_xtremegamers, $xtremegamers);
$Result1 = mysql_query($insertSQL, $xtremegamers) or die(mysql_error());
$insertGoTo = "ok.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_xtremegamers, $xtremegamers);
$query_add_Nyhed = "SELECT * FROM nyhed";
$add_Nyhed = mysql_query($query_add_Nyhed, $xtremegamers) or die(mysql_error());
$row_add_Nyhed = mysql_fetch_assoc($add_Nyhed);
$totalRows_add_Nyhed = mysql_num_rows($add_Nyhed);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>[Xtreme Gamers] Dansk Battlefield 2 klan</title>
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
color: #000000;
}
body {
background-color: #FFFFFF;
}
a {
font-size: 11px;
color: #000000;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
color: #ACA743;
}
a:active {
text-decoration: none;
color: #000000;
}
-->
</style></head>
<body>
<p>Her kan du tilføje en nyhed:</p>
<form name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="400" border="0" cellspacing="0" cellpadding="2">
<tr>
<td width="118">Overskrift</td>
<td width="274"><input name="overskrift" type="text" id="overskrift" size="40"></td>
</tr>
<tr>
<td>Synopsis</td>
<td><textarea name="synopsis" cols="40" rows="6" id="synopsis"></textarea></td>
</tr>
<tr>
<td>Tekst</td>
<td><textarea name="tekst" cols="40" rows="6" id="tekst"></textarea></td>
</tr>
<tr>
<td>Forfatter</td>
<td><input name="forfatter" type="text" id="forfatter" size="40"></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Udfør">
<input type="reset" name="Reset" value="Nulstil"></td>
<td> </td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($add_Nyhed);
?>
Hvordan skal jeg få den til at give nyhed_id sin værdi ?