opdatere forsiden.
Hej eksperter. jeg er igang med at leje med php også skal jeg havde et adminsystem. så man kan opdatere alle sine sidder via adminmodule. kan ikke rigtig få det til at virke.test-opret.php det er den side hvor jeg kan ændre min forside.
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"] == "gemt")) {
$insertSQL = sprintf("INSERT INTO bruger (brugernavn, password) VALUES (%s, %s)",
GetSQLValueString($_POST['overskrift'], "text"),
GetSQLValueString($_POST['indhold'], "text"));
mysql_select_db($database_db, $db);
$Result1 = mysql_query($insertSQL, $db) or die(mysql_error());
$insertGoTo = "test-opret.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_db, $db);
$query_tjek = "SELECT * FROM forside ORDER BY fid DESC";
$tjek = mysql_query($query_tjek, $db) or die(mysql_error());
$row_tjek = mysql_fetch_assoc($tjek);
$totalRows_tjek = mysql_num_rows($tjek);
?><!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=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form id="gemt" name="gemt" method="POST" action="<?php echo $editFormAction; ?>">
<table width="503" border="0">
<tr>
<td width="69" valign="top">overskrift:</td>
<td width="424"><label>
<input name="overskrift" type="text" id="overskrift" value="<?php echo $row_tjek['overskrift']; ?>" size="60" />
</label></td>
</tr>
<tr>
<td valign="top">Indhold:</td>
<td><label>
<textarea name="indhold" cols="60" rows="20" id="indhold"><?php echo $row_tjek['indhold']; ?></textarea>
</label></td>
</tr>
<tr>
<td valign="top"> </td>
<td><label>
<input name="gemt" type="submit" id="gemt" value="Gemt" />
</label></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="gemt">
</form>
</body>
</html>
<?php
mysql_free_result($tjek);
?>
forside.php det her så her at den bliver postede.
<?php require_once('../Connections/db.php'); ?>
<?php
mysql_select_db($database_db, $db);
$query_forside = "SELECT * FROM forside ORDER BY fid DESC";
$forside = mysql_query($query_forside, $db) or die(mysql_error());
$row_forside = mysql_fetch_assoc($forside);
$totalRows_forside = mysql_num_rows($forside);
?><!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=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table width="394" border="0">
<tr>
<td width="354"><strong><?php echo $row_forside['overskrift']; ?></strong></td>
</tr>
<tr>
<td><?php echo $row_forside['indhold']; ?></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($forside);
?>
jeg laver det her i dreamweaver.
men jeg har ikke oprettet nogen tabller i min database i nu fordi jeg ikke lige ved hvordan tabllen skal laves. kan i hjælpe mig det vil være perfekt.
test.php den side skal jeg kunne opdatere min forside hele tiden hvis jeg vil skrive noget nyt på den.
Mvh Martin