suppose you have site that users can submit their names to participate in some classes.the users will fill a form,then hit submit,and their names and telephone numbers will go to a table in a mysql database.the thing I want to do is that I want to prevent a user to submit his/her name twice by checking if the phone numbers are the same(I know it is silly this way,but I am just saying as an example).so what should I do?I am using this method to insert the form data into the data base:
$pdo = new PDO('mysql:host=localhost;dbname=form', 'formuser', 'password');
$fname = $_REQUEST['fname']; //first name from the form
$lname = $_REQUEST['lname']; //last name from the form
$pnumber = $_REQUEST['pnumber'] //phone number from the form
$query = 'INSERT INTO list SET
firstname = "' . $fname . '",
lastname = "' . $lname . '",
phonenumber ="' . $pnumber . '",
date = CURDATE()';
$pdo->exec($query);
And I know this is not a safe way to insert data into the database.again I am trying to figure out a way and then deploy better solutions for submitting the data.