Ok, new here and new to php and mysql so been web browsing to figure out a database i would like to create.
The database is to keep track of my pc's, their mac id etc.
from google i have come up with the following, bear with me;
I have 5 pages thus far, I know security on them is weak, but they are for local server only, i know to add the mysql connect info to another page, but this is a work in process
the ones i am having difficulty with are edit_form.php and edit_data.php
edit_form.php as follows;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Form Edit Data</title>
</head>
<body>
<table border=1>
<tr>
<td align=center>Edit Computer Data</td>
</tr>
<tr>
<td>
<table>
<?
$database="computer";
mysql_connect ("localhost", "michael", "michaelpass");
@mysql_select_db($database) or die( "Unable to select database");
$id=$_GET['id'];
$order = "SELECT * FROM information WHERE id='$id'";
$result = mysql_query($order);
$row = mysql_fetch_array($result);
?>
<form method="post" action="edit_data.php">
<input type="hidden" name="id" value="<? echo $row['id'];?>">
<tr>
<td>Name</td>
<td>
<input type="text" name="name"
size="20" value="<? echo $row['name'];?>">
</td>
</tr>
<tr>
<td>Workgroup</td>
<td>
<input type="text" name="workgroup" size="40"
value="<? echo $row['workgroup'];?>">
</td>
</tr>
<tr>
<td>IP Address</td>
<td>
<input type="text" name="ip" size="40"
value="<? echo $row['ip'];?>">
</td>
</tr>
<tr>
<td>MAC Address</td>
<td>
<input type="text" name="mac" size="40"
value="<? echo $row['mac'];?>">
</td>
</tr>
<tr>
<td>Location</td>
<td>
<input type="text" name="location" size="40"
value="<? echo $row['location'];?>">
</td>
</tr>
<tr>
<td>Use</td>
<td>
<input type="text" name="use" size="40"
value="<? echo $row['use'];?>">
</td>
</tr>
<tr>
<td align="right">
<input type="submit"
name="submit value" value="Edit">
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</body>
</html>
edit_data.php.. with this I was using the e.g. &database="computer"; as a test to see if the edit form data was carrying over as you can see in my else statement which would echo $name.. which would write what $name is. but this always gives me my error statement, and it does return the updated information regarding that row in the specific table represented by id.. but like i said it give me my error, and doesn't update the database... I hope thats clear, but will answer questions regarding my questions regarding all of this
<?
$database="computer";
$id=$_POST['id'];
$name=$_POST['name'];
$workgroup=$_POST['workgroup'];
$ip=$_POST['ip'];
$mac=$_POST['mac'];
$location=$_POST['location'];
$use=$_POST['use'];
mysql_connect ("localhost", "michael", "michaelpass");
@mysql_select_db($database) or die( "Unable to select database");
$order = "UPDATE information
SET name='$name', workgroup='$workgroup', ip='$ip', mac='$mac', location='$location', use='$use' WHERE id='$id'";
$result=mysql_query($order);
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='information.php'>Back to Records</a>";
}
else {
echo "ERROR";
echo $name;
}
?>
Any and all help is apreciated, this is a personal project, and would like to see it work