summaryrefslogtreecommitdiff
path: root/app/v1_php/api/login
diff options
context:
space:
mode:
Diffstat (limited to 'app/v1_php/api/login')
-rw-r--r--app/v1_php/api/login/form.html20
-rw-r--r--app/v1_php/api/login/index.php23
2 files changed, 43 insertions, 0 deletions
diff --git a/app/v1_php/api/login/form.html b/app/v1_php/api/login/form.html
new file mode 100644
index 0000000..d514e10
--- /dev/null
+++ b/app/v1_php/api/login/form.html
@@ -0,0 +1,20 @@
+<html>
+<head>
+</head>
+
+<body>
+<form method="POST" action="index.php">
+ <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/login/index.php b/app/v1_php/api/login/index.php
new file mode 100644
index 0000000..6cd1d77
--- /dev/null
+++ b/app/v1_php/api/login/index.php
@@ -0,0 +1,23 @@
+<?php
+
+/*
+Table User
+*/
+
+require_once("../mysql_connect.inc.php");
+
+$mail=mysql_real_escape_string($_POST['mail']);
+$password=mysql_real_escape_string($_POST['password']);
+
+$req="SELECT 1 FROM User WHERE mail='$mail' AND password='$password' LIMIT 1";
+$res=mysql_query($req);
+
+if ( mysql_num_rows($res) !== 1 ) {
+ header("erreur", true, 400);
+ exit();
+}
+
+header("OK : CREATED", true, 201);
+setcookie("session_key", rand(0, 1024*1024*1024*2-1)); //TODO unicité
+
+?>