Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

import React, { Component, useEffect, useState } from 'react';

import axios from 'axios';


import Stat from './Stat';

export default function App() {

const [data,setData]=useState({
username:'',
password:''
})

const {username,password}=data

const onChange=e=>{
setData({...data,[e.target.name]:[e.target.value]})
}

const onSubmit=e=>
{
e.preventDefault()
if(username=="sai" && password==123)
{
alert("Login Success")
}
else{
alert("Login Failed")
}

}
return (

<div>
<form onSubmit={onSubmit}>
<input type='text' placeholder="username" value={username} name="username"
onChange={onChange} />

<input type='password' placeholder="password" value={password} name="password"


onChange={onChange}/>
<button type='submit' name='submit'>submit</button>

</form>
</div>
)
}

You might also like