I have a form with 2 text boxes (loginid/password) On submitting the form (action = same PHP page) I check (if(isset($_POST("submit"))) and validate the fields from the records in a database. If its wrong, i need to display a error message, if not I direct the user to another page. This is my scenario.
I have a problem displaying the error message. I have 2 <div> tags right next to the 2 text boxes showing the error message but its invisible on form load (style.display = 'none') Upon validation i need to make this div tags visible using (style.display = 'block'). How do i do that in PHP?
Here is part of my code..
Instead of echoing the error message to the browser, i need to make the div tag style.display = 'block'/'none' according to conditions.... Is there a way to access the div tag's properties in PHP????<?
if(isset($_POST["submit"]))
{
require_once("config.php");
$userid = $_POST['userid'];
$password = $_POST['password'];
$query = "select * from login where userid = '$userid'";
$result = pg_query($connection, $query) or die("Error in query: $query." . pg_last_error($connection));
$rows = pg_num_rows($result);
if($rows != 1)
{
echo "<div name=\"div1\" id=\"div1\" style=\"display:block\">Invalid Username!!!</div>";
}
else
{
$row = pg_fetch_row($result);
if($password == $row[1])
{
$type = $row[2];
$company = $row[4];
echo "correct username and password";
}
else
{
echo "Invalid";
}
pg_free_result($result);
}
}
?>
In javascript I would write something like this document.getElementById('div1').style.display = 'none'; Is there a corresponding code in PHP for this?