Jump to content

Editing Something in a Database Through a Form


jonoc33

Recommended Posts

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

Link to comment
Share on other sites

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 :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.