import React, {Component} from 'react'; import {Platform, StyleSheet, Text, View, Button, TextInput, Alert, Keyboard } from 'react-native'; import { createAppContainer, createStackNavigator, StackActions, NavigationActions } from 'react-navigation'; export default class SignUpScreen extends React.Component { //Functions constructor(props){ super(props) this.state = { confirm: '', password: '', username: '', email: '', } } UserRegistrationFunction = () =>{ Keyboard.dismiss() if (this.state.username == '' || this.state.email == '' || this.state.password == '' || this.state.confirm == '') { alert("Please fill in all fields.") return; } if (this.state.confirm != this.state.password) { alert("Passwords do not match. Please try again."); return; } fetch('http://compsci02.snc.edu/cs460/2019/khoral/mysql/user_registration.php', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify({ name: this.state.username, password: this.state.password }) }).then((response) => response.json()) .then((responseJson) => { // Showing response message coming from server after inserting records. if (responseJson == "Success!") { Alert.alert("Welcome, " + this.state.username + "!"); this.props.navigation.navigate('Main'); } else{ Alert.alert(responseJson); return; } }).catch((error) => { console.error(error); }); } render() { return ( Sign Up this.setState({username:text})} /> this.setState({email:text})} keyboardType='email-address' /> this.setState({password:text})} /> this.setState({confirm:text})} />