RTS Posted August 27, 2006 Share Posted August 27, 2006 I have a page which has several textboxes which add text to different places in my mysql datatbase. thne strange thing is that every time I type in the textbox, and submit it it goes in the database, but later, when I go back to the page with the textboxes, it automatically deletes the info in the database. is there something extra i need to do? heren is my code for the page with textboxes.edit.php:[code=php:0]<?phpsession_start();?><html><body bgcolor="336699"><title>YaddaYay!</title><link rel="shortcut icon" href="logo.ico" type="image/x-icon" /><div align="center"><a href=home.html><img src="YaddaYay_Banner.jpg" border="0"></embed></a><img src="home.jpg" width="728" hight="30" usemap="#barmap" border="0"></embed><map id="barmap" name="barmap"><area shape="rect"coords="0,30,59,0" alt="Home"href="home.php"><area shape="rect"coords="60,30,104,0"alt="join"href="register.php"><area shape="rect"coords="105,30,262,0"alt="music"href="music.html"><area shape="rect"coords="263,30,336,0"alt="concerts"href="concerts.html"><area shape="rect"coords="337,30,452,0"alt="search"href="profile search.html"><area shape="rect"coords="453,30,513,0"alt="games"href="games.php"><area shape="rect"coords="514,30,619,0"alt="blogs"href="blogs.php"><area shape="rect"coords="615,30,730,0"alt="radio"href="radio.html"><br><br><div style=" top: 150; left: 100; position: absolute; z-index: 1; visibility: show;"><table width=350 cellpadding=0 cellspacing=3><tr><td bgcolor=336699style="border-top:6px gray solid;border-bottom:6px graysolid;border-right:6px gray solid;border-left:6px gray solid;"><h3 align='center'>Change background to:</h3><form action="<?phpsession_start();$con = mysql_connect("localhost","ZackBabtkis","");$color = mysql_real_escape_string($_POST[bgcolor]);$user = $_SESSION['username'];if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("test", $con);mysql_query("UPDATE users SET bgcolor = '$color'WHERE username = '$user'");mysql_close($con);?>" method="post">Color<select name="bgcolor" size="1"><option value="336699">WaterBlue [Default]</option><option value="white">White</option><option value="red">Red</option><option value="orange">Orange</option><option value="green">Green</option><option value="blue">Blue</option><option value="black">Black</option></select>Selected: <?php $user = $_SESSION['username'];$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT bgcolor FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print(ucfirst($row[bgcolor]));}mysql_close($con);?><br><form action="<?phpsession_start();$con = mysql_connect("localhost","ZackBabtkis","");$img = mysql_real_escape_string($_POST[bgimg]);$user = $_SESSION['username'];if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("test", $con);mysql_query("UPDATE users SET bgimg = '$img'WHERE username = '$user'");mysql_close($con);?>" method="post">Image<input name="bgimg"><input type="submit" value="Update!"/></form></td></tr></table></div><div style=" top: 150; left: 550; position: absolute; z-index: 1; visibility: show;"><table width=370 cellpadding=0 cellspacing=3><tr><td bgcolor=336699style="border-top:6px gray solid;border-bottom:6px graysolid;border-right:6px gray solid;border-left:6px gray solid;"><form action="<?php$con = mysql_connect("localhost","ZackBabtkis","");$about = mysql_real_escape_string($_POST[about]);$user = $_SESSION['username'];if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("test", $con);mysql_query("UPDATE users SET about = '$about'WHERE username = '$user'");mysql_close($con);?>" method="post"><textarea name=about rows=10 cols=30><?php $user = $_SESSION['username'];$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT about FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print(ucfirst($row[about]));}mysql_close($con);?></textarea><input type="submit" value="Update!"/></form></td></tr></table></div></body></html>[/code] Link to comment https://forums.phpfreaks.com/topic/18767-going-back-to-page-erases-mysql-data/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.