I have two mysql tables. One of those tables(dwg) the user will be able to fill out and it will insert a row, but I need it to check the other table(form) and make sure one of the fields does not exist.
I have a query that says:
$projnum=$_REQUEST['project'];
$check = $con->query("SELECT Project FROM form WHERE Project ='$projnum'");
if($check->num_rows==0){
$sql = "INSERT INTO dwg (DWG, Date, Client, ProjNum, Project, Assigned,
Location, Subdivision, STR)
Values ('$dwg', '$date' , '$client' , '$projnum' , '$description' ,'$assigned' ,
'$location' , '$sub' , '$str')";
}
else {
return an echoed link
}
The problem is 'project' will have a dash(-)then 2 numbers after it.
If I fill out the form without the dash and last to numbers, it accepts it when it shouldn't, and if I add the dash and last 2 numbers it returns invalid.
Is there a way to check the whole number? Getting rid of the dash is not a possibility.
Edit for clarity: So on table: form, I have a 'project' called: 8008-17 When the person fills out the form I created to add a row to the table: dwg and they type in 8008, it should return the echo. If they type in 8008-17 it should accept it and insert the row. Right now it accepts the 8008 but not the 8008-17
If the $check returns 0 rows then it should insert the information, else it returns the echo.
Hope this helps explain the issue.