I have a little script on my site that allows people to save their notes on the page.
The code for saving the notes is the following:
Code: Select all
<?php
$notes = $_REQUEST['notes'];
$uname = $user->data['username_clean'];
$con = mysql_connect("***","***","***");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db_kitchentube", $con);
mysql_query ("UPDATE notes SET notes = \"$notes\" WHERE username = \"$uname\"");
mysql_close($con);
header( 'Location: index.php' );
?>How to check if the record with the username is present and if not, how to add it instead of updating it? (The adding I can manage, but how to check it first?)
Thanks in advance!