Hi,
I am trying to update data from a column in a database using a php script. But for some reason it doesn't update the database, but i get no error feedback.
So first i select a random entry from the database and i add it as a parameter to the next page. This page contains the form and the php script to get the parameter:
<?
$server = "myserver";
$username = "myusername";
$password = "mypass";
$database = "dbname";
$con = mysql_connect($server, $username, $password);
$ok = mysql_select_db($database, $con);
' ' . htmlspecialchars($_GET["param"]) . '';
if(empty($_GET))
echo "<h2>The request is invalid</h2>";
else
$param_code = ($_GET[param]);
?>
<form name="form1" method="post" action="insert.php">
<input type="text" name="param" disabled value="<? print_r ($param_code); ?>">
<input type="submit" name="submit" id="submit" value="Submit">
</form>
here is the insert.php:
<?
$server = "myserver";
$username = "myusername";
$password = "mypass";
$database = "dbname";
$con = mysql_connect($server, $username, $password);
$ok = mysql_select_db($database, $con);
if(isset($_POST['submit']))
{
$submit = $_POST['param_code'];
}
mysql_query(" UPDATE table_name SET code_used= '0' WHERE param_code ='{$submit}' ") or die (mysql_error());
mysql_close($con);
?>
My database is very simple. It has only one table and 3 columns.
| id | param_code | code_used|
| 1 | abc2qsaa | 1 | --> This is a not used code
| 2 | safd3235 | 0 | --> This is a used code.