How do i turn this javascript code into php

Hello! I am using this javascript code and i wanna transfer it into php beacuse php is more secure. how do i do this? can i just put php inside the code or how do i fix it?

<!DOCTYPE html>
<html>
<head>

<center>
</head>

<body style="background-color:rgb(228, 226, 222);">

<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>

<form name="login">
Username&thinsp;<input type="text" name="userid"/>

<br>
<br>

Password&thinsp;<input type="password" name="pswrd"/>

<br>
<br>

<input type="button" onclick="check(this.form)" value="Login"/>
<input type="reset" value="Cancel"/>
</form>
<script language="javascript">
function check(form)/*function to check userid & password*/
{
 /*sätt in lösenorden här*/
 if(form.userid.value == "mocko" && form.pswrd.value == "mocko1")
   {
  if(form.userid.value == "villi" && form.pswrd.value == "villi1")
    {
   if(form.userid.value == "tv" && form.pswrd.value == "tv1")
  {
    window.open('amo.html')/*sidan som öppnas när man skriver in lösenordet*/
  }
 else
 {
   alert("Error Password or Username")/*fe*/
  }
}
</script>
</body>
</center>
</html>