I am developing login form In PHP
The form is as follows
<form method="post" action="Login.php" id="Log">
<select id="Login" name="Type">
<option value="Sel" selected="selected">Select Login type</option>
<option value="Student">Student</option>
<option value="Faculity">Faculity</option>
</select>
<div id="type">
<p id="Ch">Group Id: <input id="l" name="log" type="text"/></p>
<p id="Pass">Password: <input id="p" name="Pass" type="password" /></p>
<input id="Cond" type="Text" />
<input type="submit" value="Login" />
<p id="Invalid" style="padding-top:.75em; color:#FF0000;">Invalid Login Or Password</p>
</form>
In post.php I connect with database and check login and passwords.
I want to show the <p id="invalid"> tag when password or login don’t match in the same form below it without any delay.
The <p id="invalid"> is hidden at the beginning and only be shown when login or pasword is incorrect
How can I achieve this/ connect with database through PHP?
I agree with Galen’s answer. You should put the login procession stuff on the same page. If you don’t know how to do that, you should do this:
All you need to do in your form is move it to under
// Move your form in here, changethis:
to this:
and also change the values in the SQL query to suit your needs. Then it would work. I want you to move the form under
// Move your form in here, because then if the form is not submitted, it will show.EDIT: Also change the title of your form,
From this:
To this:
That will make the page just post the data to itself, making my code on top possible.
I do not suggest ajax, as it is WAY harder for hackers to hack into PHP then JavaScript-related technology, as JavaScript is client-side and PHP is server-side.
Please notify me if you still have problems.
Lucas