Nu går jeg igen med et lille problem,
Når jeg gerne vil tilføje data til mit system via php forms, så sker der det at den ikke genkender ny linje, min indsæt kode er som følgende:
<?php require_once('../Connections/cms.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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"] == "new_submenu")) {
$insertSQL = sprintf("INSERT INTO Cms_indhold (overskrift, tekst1, billede, tekst2, navn, mainid) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['overskrift'], "text"),
GetSQLValueString($_POST['tekst1'], "text"),
GetSQLValueString($_POST['billede'], "text"),
GetSQLValueString($_POST['tekst2'], "text"),
GetSQLValueString($_POST['navn'], "text"),
GetSQLValueString($_POST['mainid'], "int"));
mysql_select_db($database_cms, $cms);
$Result1 = mysql_query($insertSQL, $cms) or die(mysql_error());
$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$colname_rsnew = "-1";
if (isset($_GET['id'])) {
$colname_rsnew = $_GET['id'];
}
mysql_select_db($database_cms, $cms);
$query_rsnew = sprintf("SELECT id FROM Cms_indhold WHERE id = %s", GetSQLValueString($colname_rsnew, "int"));
$rsnew = mysql_query($query_rsnew, $cms) or die(mysql_error());
$row_rsnew = mysql_fetch_assoc($rsnew);
$totalRows_rsnew = mysql_num_rows($rsnew);
mysql_select_db($database_cms, $cms);
$query_rsbilledmenu = "SELECT * FROM Cms_billeder";
$rsbilledmenu = mysql_query($query_rsbilledmenu, $cms) or die(mysql_error());
$row_rsbilledmenu = mysql_fetch_assoc($rsbilledmenu);
$totalRows_rsbilledmenu = mysql_num_rows($rsbilledmenu);
?><!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>Untitled Document</title>
<link href="../css/styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {font-size: 10px}
-->
</style>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="layout">
<tr>
<td colspan="2" class="top"><h1>Administrationsområde</h1></td>
</tr>
<tr>
<td class="top1"> </td>
<td class="top1"> </td>
</tr>
<tr>
<td class="left"><h1 align="center"> </h1>
<p align="center" class="left"><span class="style1"><strong>Tilføj undermenu</strong><br />
</span></p>
<p align="center" class="left"><a href="index.php">tilbage admin-forsiden</a></p></td>
<td class="middle"><p> </p>
<p>Tilføj Undermenu</p>
<form id="new_submenu" name="new_submenu" method="POST" action="<?php echo $editFormAction; ?>">
<table width="95%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td>Navn på menu:</td>
<td><label>
<input name="navn" type="text" id="navn" size="70" />
</label></td>
</tr>
<tr>
<td>Overskrift:</td>
<td><input name="overskrift" type="text" id="overskrift" size="70" /></td>
</tr>
<tr>
<td>Tekst 1:</td>
<td><textarea name="tekst1" id="tekst1" cols="70" rows="6"></textarea></td>
</tr>
<tr>
<td>Billede:</td>
<td><label>
<select name="billede" id="billede">
<option value=" ">----Intet billede----</option>
<?php
do {
?>
<option value="<?php echo $row_rsbilledmenu['billednavn']?>"><?php echo $row_rsbilledmenu['billednavn']?></option>
<?php
} while ($row_rsbilledmenu = mysql_fetch_assoc($rsbilledmenu));
$rows = mysql_num_rows($rsbilledmenu);
if($rows > 0) {
mysql_data_seek($rsbilledmenu, 0);
$row_rsbilledmenu = mysql_fetch_assoc($rsbilledmenu);
}
?>
</select>
</label></td>
</tr>
<tr>
<td>Tekst 2:</td>
<td><label>
<textarea name="tekst2" id="tekst2" cols="70" rows="6"></textarea>
</label></td>
</tr>
<tr>
<td> </td>
<td><label>
<input name="button" type="submit" id="button" value="Gem data" />
</label></td>
</tr>
</table>
<input name="mainid" type="hidden" id="mainid" value="<?php echo $row_rsnew['id']; ?>" />
<input type="hidden" name="MM_insert" value="new_submenu" />
</form> <p> </p></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($rsnew);
mysql_free_result($rsbilledmenu);
?>