Guest User

Untitled

a guest
Jan 10th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. <?php
  2. $con=mysqli_connect("localhost","root","","flutterapp");
  3. $username=$_POST["username"];
  4. $password=$_POST["password"];
  5. $status=$_POST["status"];
  6. $qry=mysqli_query($con,"insert into user (username,password,status)
  7. values ('$username','$password','$status')");
  8. $response = array();
  9. echo json_encode($response); ?>
  10.  
  11. import 'dart:convert';
  12. import 'package:flutter/material.dart';
  13. import 'package:http/http.dart' as http;
  14.  
  15. class Register extends StatefulWidget {
  16. @override
  17. _RegisterForm createState() => _RegisterForm();
  18. }
  19.  
  20. class _RegisterForm extends State<Register> {
  21. String _radioValue;
  22. TextEditingController user = new TextEditingController();
  23. TextEditingController pass = new TextEditingController();
  24.  
  25. Future<List> register() async {
  26. final response =
  27. await http.post("http://myurl/flutterApp/register.php", body: {
  28. "username": user.text,
  29. "password": pass.text,
  30.  
  31. });
  32. var datauser = json.decode(response.body);
  33. if (datauser.length == 0) {
  34. setState(() {
  35. msg = "Register Fail";
  36. });
  37. } else {
  38. Navigator.pushReplacementNamed(context, '/MyHomePage');
  39. }
  40. return datauser;
  41. }
  42. @override
  43. Widget build(BuildContext context) {
  44. return Scaffold(
  45. appBar: AppBar(
  46. title: Text("Create New Account"),
  47. ),
  48. body: Container(
  49. margin: const EdgeInsets.only(left: 20.0,top:70.0, right: 20.0),
  50. child: Column(
  51. children: <Widget>[
  52. TextField(
  53. controller: user,
  54. decoration: InputDecoration(hintText: 'Username'),
  55. ),
  56. TextField(
  57. controller: pass,
  58. obscureText: true,
  59. decoration: InputDecoration(hintText: 'Password'),
  60. ),
  61. RaisedButton(
  62. child: Text("Sign Up"),
  63. onPressed: () {
  64. register();
  65. },
  66. ),
  67. ],),),);} }
Add Comment
Please, Sign In to add comment