I have read a few threads on this forum as to how to check for duplicate records before inserting, but I am a little confused.
Here is my code:
<HTML>
<HEAD>
<TITLE>Insert survey results into database</TITLE>
</head>
<BODY bgcolor="#cccccc">
<?php
// Trim the incoming data
$wo=$REQUEST['wo'];
$question1=$REQUEST['question1'];
$comments1=$REQUEST['comments1'];
$question2=$REQUEST['question2'];
$comments2=$REQUEST['comments2'];
$question3=$REQUEST['question3'];
$comments3=$REQUEST['comments3'];
$technician=$REQUEST['technician'];
// Set the variables for database access
$User = "root";
$Password = "******";
$DBName = "surveys";
$TableName = "helpdesk";
$Link=mysql_connect (localhost, $User, $Password);
$Query="INSERT into $TableName values
('$wo','$question1','$comments1','$question2','$comments2','$question3','$comments3','$technician')";
if (mysql_db_query ($DBName, $Query, $Link)){
print ("<BR><BR>\n");
print ("<center>\n");
print ("<h3>Thank you!</h3> Your survey has been successfully
submitted.<BR>\n");
print ("This information will enable us to provide more effective
support to our end users.<br><br><br><br>\n");
print ("<form method=\"post\">\n");
print ("<INPUT TYPE=\"button\" VALUE=\"Close Window\" onClick=\"window.close()\">\n");
print ("</center>\n");
}else{
print ("<center>\n");
print ("<BR><BR><BR><BR>\n");
print ("<img src='images/bang.gif'>\n");
print ("There was an error when tring to process your survey. Please contact the Help Desk at ext. 2999. Thank
you.<br><br><br><br><br>\n");
print ("<form method=\"post\">\n");
print ("<input type=\"button\" value=\"Close Window\" onClick=\"window.close()\">\n");
print ("</center>\n");
}
mysql_close ($Link);
?>
</BODY>
</HTML>
I would like to check for a duplicate number in the wo (work order) variable. Can someone please provide code (or even a resource where I might be able to find help with this) and a brief explanation of how the code works?
I hate just plugging in code, provided by someone else, without having any idea of how it works with the rest of my code.
Thanks so much,
Vinny