diff options
Diffstat (limited to 'app/v1_php/api/user')
-rw-r--r-- | app/v1_php/api/user/form.html | 28 | ||||
-rw-r--r-- | app/v1_php/api/user/index.php | 25 |
2 files changed, 53 insertions, 0 deletions
diff --git a/app/v1_php/api/user/form.html b/app/v1_php/api/user/form.html new file mode 100644 index 0000000..a01d2dd --- /dev/null +++ b/app/v1_php/api/user/form.html @@ -0,0 +1,28 @@ +<html> +<head> +</head> + +<body> +<form method="POST"> + <div class="form_line"> + <label name="firstname">firstname</label> + <input type="text" name="firstname"></input> + </div> + <div class="form_line"> + <label name="lastname">lastname</label> + <input type="text" name="lastname"></input> + </div> + <div class="form_line"> + <label name="mail">mail</label> + <input type="text" name="mail"></input> + </div> + <div class="form_line"> + <label name="password">password</label> + <input type="text" name="password"></input> + </div> + <div class="form_line"> + <input type="submit" /> + </div> +</form> +</body> +</html> diff --git a/app/v1_php/api/user/index.php b/app/v1_php/api/user/index.php new file mode 100644 index 0000000..495bd2a --- /dev/null +++ b/app/v1_php/api/user/index.php @@ -0,0 +1,25 @@ +<?php + +/* +Table User : id, firstname, lastname, mail, password +Unique key : mail +*/ + +require_once("../mysql_connect.inc.php"); + +$firstname=mysql_real_escape_string($_POST['firstname']); +$lastname=mysql_real_escape_string($_POST['lastname']); +$mail=mysql_real_escape_string($_POST['mail']); +$password=mysql_real_escape_string($_POST['password']); + +$req="INSERT INTO User (NULL,'$firstname', '$lastname', '$mail', '$password')"; +$res=mysql_query($req); + +if ( mysql_num_rows() === 1 ) { + //TODO header 201, "OK : CREATED" + echo "header 201, OK : CREATED\n"; +} else { + // header 400, "Erreur" + echo "header 400, Erreur\n"; +} +?> |