How do stop form posting to mysql if database contains a specific ID?
- by user342391
I have a form that I am using to post data to mysql.
Before submitting the form I want to check the database and see if there are any fields in the column 'customerid' that equal 'userid' and if so not to post the form.
Basically, I am trying to limit my users from posting more than once. Users will be able to login to my system and make ONE post. They will be able to delete and modify their post but are only limited to one post.
How would I do this??? Code so far:
<?php
include '../login/dbc.php';
page_protect();
$userid = $_SESSION['user_id'];
$sql="INSERT INTO content (customerid, weburl, title, description)
VALUES
('$_POST[userid]','$_POST[webaddress]','$_POST[pagetitle]','$_POST[pagedescription]')";
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
?>