Can someone help me fix my php code so that it does not delete any data in the mysql

yogibear7

New member
database when entered? What I'm doing here is having a first page, where the user selects a checkbox. They then hit the submit button and the value of the box is processed on another page where it is added to the mysql database. A user can select a checkbox and hit submit and then the value is entered, but the problem becomes that if another user selects the second checkbox, the data in the "camera" row is deleted. My question is, how can I make it so that entering the data does not delete any data that is already in the database. I have included the code below:

Code from first page
<?php

$username = $_COOKIE['ID_my_site'];

echo '<div align="left"><br>';
echo '<input type="checkbox" name="camera" value="' . $username . '" >Camera<br>';
echo '<input type="checkbox" name="commentator" value="' . $username . '">Commentator<br>';
echo '</div>';
echo '<br>';
echo '<input type="submit" value="Sign up" >';
echo '</form>';
?>

Then, the data from the form is processed on another page:

<?php
$con = mysql_connect("--","--","--");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("--", $con);

mysql_query("UPDATE shoots SET camera = ('$_POST[camera]')
WHERE shoot = ('$_POST[shoot]')
");

mysql_query("UPDATE shoots SET commentator = ('$_POST[commentator]')
WHERE shoot = ('$_POST[shoot]')
");

mysql_close($con)
?>
 
Back
Top