I am working on my website which having different tabs (home, contact, etc.). Now in one of these tabs I’m using a login form, in this form I’m just validating one fixed user (Not Using database), this will understand from verification.php
code.
Below is part of .html
file code that calling verification.php
file
<div id="loginn" class="loginForm">
<form action="verfication.php" method="post">
<div class="ll">
<img src="image/avatar2.png">
</div>
<label for="name"><b>Username</b></label><br>
<input type="text" name="uname" required><br>
<label for="psw"><b>Password</b></label><br>
<input type="password" name="psw" required><br>
<button type="submit">Login</button>
</form>
</div>
Below is my verification.php
file, which is saved by me in www
directory, where all the html, css, js files are stored
<!DOCTTYPE html>
<html>
<body>
<?php
if(isset($_POST['uname']) and isset($_POST['psw']))
{
$name=$_POST['uname'];
$pass=$_POST['psw'];
if ( $name == "rrrr" and $pass="ravina@6543" )
{
?>
<script type="text/javascript">document.getElementById('veri').style.display="block";</script>
<script type="text/javascript">document.getElementById('loginn').style.display="none";</script>
<?php}
}
?>
</body>
</html>
Now the problem is, when I click on the login button, there is nothing happening on the html part. I mean, my PHP file is not getting access from my HTML part, so please can anyone help me to solve these problem?
4
Answers
in your verification.php, you can check success/not with using only
echo
I think there’s an error in the syntax: first of all there is an additional “T” in the
<!DOCTTYPE html>
and secondly there’s a curly bracket after you started the php script:<?php}
, just adding a space will fix your problem.There’s also a spelling mistake in your html code regarding the name of the php file
verification.php
.This is not how to use PHP, HTML and javascript. You should start by learning how HTTP works, then HTML, then JavaScript and finally PHP.
First of all you should correctly write the name of php file in your html form i.e. verification.php
verification.php file remove one T from DOCTTYPE html and give one space between php and { in ?php{ this line.