verdeutliche doch bitte an einem beispiel, was du meinst.
[Variablen] Datenbank Änderung
Collapse
X
-
sorry, ich habe glaube ich den fehler..
edit
doch nciht. aqlso hier das script:
update1.php
PHP Code:<html>
<head>
<?php
error_reporting(E_ALL);
include "config.php";
@mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) OR die(mysql_error());
mysql_select_db(MYSQL_DATABASE) OR die(mysql_error());
?>
<title>
<?php
$sql = "SELECT Titel, Beschreibung FROM Info";
$result = mysql_query($sql) OR die(mysql_error());
if(mysql_num_rows($result)) {
while($row = mysql_fetch_assoc($result)) {
echo $row['Titel'];
echo " - ";
echo $row['Beschreibung'];
}} else {
echo "Kein Titel Vorhanden";
}
?>
</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
<div id="place" ></div>
<div id="pagewidth" >
<div id="header" >Admin Testscript</div>
<div id="maincol" >
<br>
Homepage Name:
<form name="titel_form" action="update.php" method="post">
<input type="text" name="title" size="40" value="
<?php
$sql = "SELECT Titel FROM Info";
$result = mysql_query($sql) OR die(mysql_error());
if(mysql_num_rows($result)) {
while($row = mysql_fetch_assoc($result)) {
echo $row['Titel'];}}
?>
" />
<input type="submit" name="set_title" value="Ändern" />
</form>
Homepage Beschreibung:
<form name="beschreibung_form" action="update.php" method="post">
<input type="text" name="beschreibung" size="100" value="
<?php
$sql = "SELECT Beschreibung FROM Info";
$result = mysql_query($sql) OR die(mysql_error());
if(mysql_num_rows($result)) {
while($row = mysql_fetch_assoc($result)) {
echo $row['Beschreibung'];}}
?>
" />
<input type="submit" name="set_bes" value="Ändern" />
</form>
</div>
</div>
</body>
</html>
PHP Code:<?php
error_reporting(E_ALL);
include "config.php";
@mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) OR die(mysql_error());
mysql_select_db(MYSQL_DATABASE) OR die(mysql_error());
$sql = 'UPDATE `Info` SET `Titel` = \'$_POST[\'set_title\']\', `Beschreibung`
= \'$_POST[\'set_beschreibung\']\'
WHERE `ID` = 1 LIMIT 1;';
mysql_query($sql);
echo "Die Einstellungen wurden geändert";
?>
aber trotzdem wird bei der startseite immernoch der vorige titel angezeigt.Last edited by Lennie; 03-06-2006, 17:15.Webdesign und Webentwicklung - Plunix.de
Comment
-
stimmt.
hab das alles nochmal überdacht:
Die Aktuelle Version:
PHP Code:<html>
<head>
<?php
error_reporting(E_ALL);
include "config.php";
@mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) OR die(mysql_error());
mysql_select_db(MYSQL_DATABASE) OR die(mysql_error());
?>
<title>
<?php
$sql = "SELECT Titel, Beschreibung FROM Info";
$result = mysql_query($sql) OR die(mysql_error());
if(mysql_num_rows($result)) {
while($row = mysql_fetch_assoc($result)) {
echo $row['Titel'];
echo " - ";
echo $row['Beschreibung'];
}} else {
echo "Kein Titel Vorhanden";
}
?>
</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
<div id="place" ></div>
<div id="pagewidth" >
<div id="header" >Admin Testscript</div>
<div id="maincol" >
<br>
Homepage Name:<br>
<input type="hidden" id="form1" name="titel_form">
<input type="text" name="title" id="title" size="40" value="
<?php
$sql = "SELECT Titel FROM Info";
$result = mysql_query($sql) OR die(mysql_error());
if(mysql_num_rows($result)) {
while($row = mysql_fetch_assoc($result)) {
echo $row['Titel'];}}
?>
" />
<input type="hidden" name="Set_title" id="Set_title" value="Ändern"><br>
Homepage Beschreibung:
<form name="beschreibung_form" action="update.php?title="+title.value+"&Set_title="
+Set_title.value method="post">
<input type="text" name="beschreibung" size="100" value="
<?php
$sql = "SELECT Beschreibung FROM Info";
$result = mysql_query($sql) OR die(mysql_error());
if(mysql_num_rows($result)) {
while($row = mysql_fetch_assoc($result)) {
echo $row['Beschreibung'];}}
?>
" /><br>
<input OnClick="form1.submit" type="submit" name="set_bes" value="Ändern" />
</form>
</div>
</div>
</body>
</html>PHP Code:<?php
error_reporting(E_ALL);
include "config.php";
@mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) OR die(mysql_error());
mysql_select_db(MYSQL_DATABASE) OR die(mysql_error());
$sql = "UPDATE `Info` Set `Titel` = '".$_GET['Set_title']."',
`Beschreibung` = '".$_GET['set_bes']."'
WHERE ID = '1' LIMIT 1";
mysql_query($sql) or die (mysql_error());
echo "Die Einstellungen wurden geändert ";
?>
Notice: Undefined index: set_title in /home/www/p1340/html/cms/update.php on line 11
jetzt kommt auch ein notice... hab es so geamcht das der ysql query funktioniert ohne das man ein if trennen müsste leider ist eben der notice da.Last edited by Lennie; 04-06-2006, 19:44.Webdesign und Webentwicklung - Plunix.de
Comment
-
1. ok wird gemacht.
2. jo hab das mit nen anderne programmierer überarbeitet und das war sein vorschlag.
3. mhh weis net wieso der meinte ich sollte dann get einbauen. naja beim 2. bekomm ich ja auch was zugesendet, sonst würde ein notice erschenen. wieso aber dann nicht das gesendete sondern "ändern" in der variavle steht, kapier ich nicht. da muss ich aj ein value verwechselt haben.Webdesign und Webentwicklung - Plunix.de
Comment
Comment