I want to submit values to my WordPress MySQL database table table1 from all the textboxes. But before submit data, if the textbox value of match1, match2, match3 and so on, already exist in table2 (column name ref_code) then textbox border (or shadow) should turn green individually. If value does not exist in table2 (column name ref_code) then border should turn red of that specific match textbox.
Please take a look at my current code and give me valuable suggestion. (The given code is only to insert data in table1 but I want to search in table2 column:ref_code)
<?php
if (!empty($_POST)) {
global $wpdb;
$data = array(
'order_id' => $_POST['order_id'],
'raw_data' => $_POST['raw_data']
);
for( $i=1; $i<6; $i++) :
$data['match'.$i] = $_POST['match'.$i];
$data['buy'.$i] = $_POST['buy'.$i];
$data['percent'.$i] = $_POST['percent'.$i];
endfor;
$success=$wpdb->insert( 'test1', $data, $format=NULL );
if($success){
echo "=> DATA SAVED" ;
?>
<form method="post">
<div class='mainIn'>Order ID<br>
<input type="text" name="order_id"></div>
<div class='mainIn'>Raw Data<br>
<textarea type="text" name="raw_data"></textarea></div>
<br><br><div style='display:flex;flex-wrap:wrap'>
<?php for( $i=1; $i<6; $i++) : ?>
<div id='allpeaks' style='flex:0 0 100%'>
Match<?php echo $i;?><input class='inCol' name='match<?php echo $i;?>'>
Buy<?php echo $i;?><input class='inCol' name='buy<?php echo $i;?>'>
Percent<?php echo $i;?><input class='inCol' name='percent<?php echo $i;?>'>
</div><br><br>
<?php endfor;?>
</div>
<br><input type="submit">
</form>