summaryrefslogtreecommitdiff
path: root/app/v1_php/api/user
diff options
context:
space:
mode:
Diffstat (limited to 'app/v1_php/api/user')
-rw-r--r--app/v1_php/api/user/form.html2
-rw-r--r--app/v1_php/api/user/index.php10
2 files changed, 5 insertions, 7 deletions
diff --git a/app/v1_php/api/user/form.html b/app/v1_php/api/user/form.html
index a01d2dd..fb2fc67 100644
--- a/app/v1_php/api/user/form.html
+++ b/app/v1_php/api/user/form.html
@@ -3,7 +3,7 @@
</head>
<body>
-<form method="POST">
+<form method="POST" action="index.php">
<div class="form_line">
<label name="firstname">firstname</label>
<input type="text" name="firstname"></input>
diff --git a/app/v1_php/api/user/index.php b/app/v1_php/api/user/index.php
index 495bd2a..3b27b03 100644
--- a/app/v1_php/api/user/index.php
+++ b/app/v1_php/api/user/index.php
@@ -12,14 +12,12 @@ $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')";
+$req="INSERT INTO User VALUES (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";
+if ( $res===true && mysql_affected_rows() === 1 ) {
+ header("OK : CREATED", true, 201);
} else {
- // header 400, "Erreur"
- echo "header 400, Erreur\n";
+ header("erreur", true, 400);
}
?>