I'm new to programming and PHP. I'd like to use onclick from HTML to log in to PHP.
This is my code:
<script type="text/javascript">
function Log(){
<!-- This is Log in script -->
<?php
$Logged = 0
$pass = $_GET["pass"];
$uid = $_GET["uid"];
$click = $_GET["con"]
if($pass=123 && $uid=xxx| && $click=1){
$Logged=1
break
} else {
$Logged=0
}
?>
}
</script>
And there HTML button:
<input type="button" onclick="$Logged++" value="Log in"
style="color: #000000; background-color: #7200E3;
width: 80px; height: 40px; border-style: solid;
border-color: #00E372; border-width: 0.1cm"
/>
Please help me :)
$Loggedwould be incremented every time the button is clicked, if the script was valid. Better strategy is to send the data to a PHP, do the login process, return the data (either via json or xml or any other means) and process it on the client-side. Try searching for "login flow in php ajax", anything like that, and you'll get a better idea.