html - I want to change css style of input background, depend on mysql php (form) request IF/ELSE
one text
I want to change css style of input background, depend on mysql php request IF/ELSE!!!
What I am trying to make is.
IF the value of input was already in database;
THEN the background of input will be GREEN!;
ELSE the background of input will be RED!
HTML form:
<iframe name="dummyframe" id="dummyframe" style="display: none;"></iframe>
<form action="connect.php" method="POST" target="dummyframe" class="password" id="passform">
<input type="password" id="password" placeholder="Enter your password" name="password" style="border-radius: 5px; color: #000000; padding: 5px;">
<a href="#" class="password-control"></a>
<br>
<!--<a href="#" class="button verify">Verify</a>-->
<input type="submit" class="button verify" value="Verify" name="submit">
</form>
This is my css in input tag:
style="border-radius: 5px; color: #000000; padding: 5px;"
My PHP:
<?php
$hostname = "localhost";
$username = "arti";
$password = "Arti@1239";
$db = "hackhood";
$dbconnect = new mysqli($hostname, $username, $password, $db);
$dbcheck = new mysqli($hostname, $username, $password, $db);
if ($dbconnect->connect_error) {
die("Connection failed: " . $dbconnect->connect_error);
}
$query = "INSERT INTO info (password) VALUES ('".$_POST['password']."')";
$exist = "SELECT * FROM info WHERE password = ".$_POST['password']."";
if (mysqli_query($dbconnect, $query)) {
printf("New record created successfully");
/*echo "<script>window.close();</script>";*/
} else {
printf("Error: " . $query . "" . mysqli_error($dbconnect));
/*$dbconnect->close();*/
}
if (mysqli_query($dbcheck, $exist)) {
echo "<form id='password' style='background-color: green;'>";
} else {
echo "<form id='password' style='background-color: red;'>";
}
?>
Inserting to mysql working fine. But the last if/else doesn't work. The syntax working fine, but I link it just changes the css on new BROWSER TAB and NOT CHANGES the CSS on original page. The page, where I have my input tag.
target="dummyframe"
THAT means, it "don't" open anything, so I stay on my page (won't be redirected to https://something.ex/example.php)
Source