I have to connect a user registration by post method in php for a subject and the teacher gave us the php code to do it but it doesn't work. Iḿ using Linux.
Here is the form, registro.html
:
<form action="registro.php" method="POST">
<h1>Registro</h1>
<label for="name">Nombre</label>
<div><input type="text" name="nombre" id="nombre" placeholder="Nombre"></div>
<label for="name">Apellido Paterno</label>
<div><input type="text" name="name" id="" placeholder="Apellido Paterno"></div>
<label for="name">Apellido Materno</label>
<div><input type="text" name="name" id="" placeholder="Apellido Materno"></div>
<label for="name">Edad</label>
<div><input type="text" name="name" id="" placeholder="Edad"></div>
<label for="name">Numero de telefono</label>
<div><input type="text" name="name" id="" placeholder="Ej.33 1234 5678"></div>
<label for="name">Codigo Postal</label>
<div><input type="text" name="name" id="" placeholder="Ej. 12344"></div>
<label for="name">Correo electronico</label>
<div><input type="text" name="correo" id="" placeholder="Ej. [email protected]"</div>
<label for="name">Contraseña</label>
<div><input type="password" name="contrasena" id="" placeholder="*********"></div>
<button>REGISTRAR</button>
</form>
But I get Error 405 after submitting it.
For a simple HTML form, error 405 Method not allowed most likely means that you don't have PHP installed, so your server don't know how to handle POST requests.
The simplest way to install PHP on Windows would be
.zip
version from the current stable PHP sectionC:\PHP
)cmd.exe
and hit Entercd "C:\Users\User\Documents\PHP"
or whatever the folder is and hit Enter)C:\PHP\php.exe -S localhost:8080
(using exact folder name where you unzipped PHP)http://localhost:8080/script.php
Or you can use one of prebuilt servers such as XAMPP and such.
On Linux you can install PHP from the packet manager, such as sudo apt install php