Edit sql code
Posted: Wed Feb 02, 2011 9:05 am
Hi everyone,
I'm traying to make a page that allows user to edit the database data and i got this code but i can't make it workin'. Can you please have a look at it? i can't find the problem!
This should be the last page that reads the modifications and actually writes them on the DB but this page gives an error and nothing changes on DB.
Thank you all
I'm traying to make a page that allows user to edit the database data and i got this code but i can't make it workin'. Can you please have a look at it? i can't find the problem!
This should be the last page that reads the modifications and actually writes them on the DB but this page gives an error and nothing changes on DB.
Code: Select all
<?php
$id=$_POST["id"] ;
$Nome = $_POST["Nome"];
$Email = $_POST["Email"];
$NumeroCell = $_POST["NumeroCell"];
$InternoTemis = $_POST["InternoTemis"];
$Skype = $_POST["Skype"];
if($Nome=="")
{
print "Nome obbligatorio<br><a href=\"?page_id=321\">indietro</a>";
}
elseif($Email=="")
{
print "La mail obbligatoria<br><a href=\"?page_id=321\">indietro</a>";
print "Numero Cell: $NumeroCell <br>";
print "Interno Temis: $InternoTemis <br>";
print "Skype: $Skype <br>";
}
else
{
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '*********';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to
mysql');
$dbname = 'wordpress';
mysql_select_db($dbname);
mysql_query("UPDATE temis_contatti SET Nome='$Nome', Email='$Email', NumeroCell='$NumeroCell',
InternoTemis='$InternoTemis', Skype='$Skype' WHERE id=$id");
mysql_close();
?>
<html>
<head>
<title>update</title>
</head>
<body>
<table width="750" align="center">
<tr>
<td>
<?php
echo "Record modificato:<br>";
echo "Nome: $Nome<br>";
echo "Email: $Email<br>";
echo "Numero Cell: $NumeroCell<br>";
echo "InternoTemis: $InternoTemis<br>";
echo "Skype: $Skype<br>";
?>
<br>
<a href="\?page_id=311">Elenco completo</a>
</td>
</tr>
</table>
</body>
</html>
<?
}
?>