Simpelt spørgsmål
Hvis jeg har et script hvilket som helst, og har hentet f.eks. en bruger som jeg nu kan se info på, hvordan kan jeg så komme til at rette i hans info med MySQL (Update). Jeg har lavet noget her, men jeg kan ikke helt finde ud af at sende hans "navn" med så jeg kan rette ham i databasen..?visprivatperson.php---------------------------------------------
<html>
<head>
<LINK href="../default.css" type="text/css" rel="stylesheet">
</head>
<body class = "body">
<?
include ("../connect.php");
if (isset($_GET['navn']))
{
$username = mysql_real_escape_string($_GET['navn']);
$result = mysql_query("SELECT * FROM privatpersondatabase_db WHERE navn = '".$username."' LIMIT 1") or die(mysql_error());
if(mysql_num_rows($result) == 0)
{
echo "Fejl";
}
else
{
$row = mysql_fetch_array($result);
}
}
?>
<p><span class="blue2">Person Info</span></p>
<table border="0">
<tr>
<td><span class="blue">Att:</td><td class="bottomtext"><?php echo $row['att']?></td>
</tr>
<tr>
<td><span class="blue">Navn:</td><td class="bottomtext"><?php echo $row['navn']?></td>
</tr>
<tr>
<td><span class="blue">Adresse:</td><td class="bottomtext"><?php echo $row['adresse']?></td>
</tr>
<tr>
<td><span class="blue">Postnr:</td><td class="bottomtext"><?php echo $row['postnr']?></td>
</tr>
<tr>
<td><span class="blue">By:</td><td class="bottomtext"><?php echo $row['by']?></td>
</tr>
<tr>
<td><span class="blue">Telefon:</td><td class="bottomtext"><?php echo $row['telefon']?></td>
</tr>
<tr>
<td><span class="blue">Fax:</td><td class="bottomtext"><?php echo $row['fax']?></td>
</tr>
<tr>
<td><span class="blue">E-mail:</td><td class="bottomtext"><?php echo $row['email']?></td>
</tr>
<tr>
<td><span class="blue">Web:</td><td class="bottomtext"><?php echo $row['web']?></td>
</tr>
</table>
<br><br><br>
<?
if (isset($_POST['update']))
{
$username = mysql_real_escape_string($_GET['navn']);
$delete = mysql_query("DELETE FROM privatpersondatabase_db WHERE navn = '".$username."'");
if($delete) {
echo "Succes: Brugeren er slettet!";
} else {
echo "Fiasko: Brugeren kunne <b>ikke</b> slettes!";
}
}
?>
<a href="retinfoprivatperson.php"><span class="blue">Ret Info</span></a>
<span class="blue"><a href="visprivatperson.php" name="update">Slet</a></span>
</body>
</html>
retinfoprivatperson.php------------------------------------------
<html>
<head>
<LINK href="../default.css" type="text/css" rel="stylesheet">
</head>
<body class = "body">
<?
if (isset($_GET['navn']))
{
$username = mysql_real_escape_string($_GET['navn']);
$result = mysql_query("SELECT * FROM privatpersondatabase_db WHERE navn = '".$username."' LIMIT 1") or die(mysql_error());
if(mysql_num_rows($result) == 0)
{
echo "Fejl";
}
else
{
$row = mysql_fetch_array($result);
}
}
?>
<p><span class="blue2">Ret Person Info</span></p>
<table border="0">
<tr>
<td class="blue">Att:</td><td><input type ="text" class="userinput" size="20" name="att"></td>
</tr>
<tr>
<td class="blue">Navn:</td><td><input type ="text" class="userinput" size="20" name="navn"></td>
</tr>
<tr>
<td class="blue">Adresse:</td><td><input type ="text" class="userinput" size="20" name="adresse"></td>
</tr>
<tr>
<td class="blue">Postnr:</td><td><input type ="text" class="userinput" size="20" name="postnr"></td>
</tr>
<tr>
<td class="blue">By:</td><td><input type ="text" class="userinput" size="20" name="by"></td>
</tr>
<tr>
<td class="blue">Telefon:</td><td><input type ="text" class="userinput" size="20" name="telefon"></td>
</tr>
<tr>
<td class="blue">Fax:</td><td><input type ="text" class="userinput" size="20" name="fax"></td>
</tr>
<tr>
<td class="blue">E-mail:</td><td><input type ="text" class="userinput" size="20" name="email"></td>
</tr>
<tr>
<td class="blue">Web:</td><td><input type ="text" class="userinput" size="20" name="web"></td>
</tr>
</table>
</body>
</html>