jonoc33 Posted November 15, 2007 Share Posted November 15, 2007 Hi guys, I have a form with a bunch of text boxes, with writing in it that has been taken out of a database. eg: In the database: servername: Jono ipaddress: 129.124 etc time: 11:00 date: 18th march password: pass In the form it has the same thing. What I need is a code for a page, that you are taken to after you hit submit, that updates a record with what you put in, and it will know what record to edit through hidden inputs that are also taken from the database. Many thanks, Jono Quote Link to comment Share on other sites More sharing options...
jonoc33 Posted November 15, 2007 Author Share Posted November 15, 2007 Edited. Quote Link to comment Share on other sites More sharing options...
jonoc33 Posted November 15, 2007 Author Share Posted November 15, 2007 EDIT AGAIN: Ok what i've tried is to delete it off the database, and if that works, then add the edited version of it. <?php error_reporting(E_ALL); $con = mysql_connect("localhost","jonoc33","******") or die('Could not connect: '.mysql_error()); mysql_select_db("revolutiongamerz_net_-_squads", $con); mysql_query("DELETE FROM alpha_scrims WHERE servername='$_POST[servername]' ") or die(mysql_error()); $sql="INSERT INTO alpha_scrims (servername, ipaddress, time, date, password) VALUES ('" . $_POST["servername"] . "','" . $_POST["ipaddress"] . "','" . $_POST["time"] . "','" . $_POST["date"] . "','" . $_POST["password"] . "')"; $rs = mysql_query($sql) or die ("Problem with the query: $sql <br>" . mysql_error); echo "<center>Record edited."; echo "<center><a href=admin.php>Back</a>"; ?> That only seems to add it to the database, but doesn't delete it. AHA! Spotted an error in the code.. Checking now EDIT: Lol, did it all myself.. Sorry for posting Quote Link to comment Share on other sites More sharing options...
tippy_102 Posted November 15, 2007 Share Posted November 15, 2007 You don't need to delete it, use UPDATE Here's a tutorial: http://www.tizag.com/mysqlTutorial/mysqlupdate.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.