How do i turn this javascript code into php

How do i turn this javascript code into php
0

#1

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>

#2

Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at https://freecodecamp.org.

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

Happy coding :slight_smile: