what can I do to make the script validate username and password without use databases?
8/16/2017 11:59:37 AM
Trapido027 Answers
New AnswerOne way of looking at it- <form> <input type="text" placeholder="Username" id="text1" /><br /> <input type="password" placeholder="Password" id="text2" /><br /> <input type="button" value="Login" onclick="javascript:validate()" /> </form> <script type="text/javascript"> function validate() { if( document.getElementById("text1").value == "workshop" && document.getElementById("text2").value == "workshop" ) { alert( "validation succeeded" ); location.href="run.html"; } else { alert( "validation failed" ); location.href="fail.html"; } } </script>
Database is not a program, it can't validate data for us, it just for storing data. You use Javascript or PHP program to validate the form data.
Javascript can only store client local data using local storage or cookies. Means the stored data is only available for that local pc/phone only, each clients store their own individual data.
thats my contact form in js hope it helps :) https://code.sololearn.com/W73uL5j0oPBd/?ref=app
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message