diff --git a/app.db b/app.db index 4197499..1f0450b 100644 Binary files a/app.db and b/app.db differ diff --git a/s1/src/routes/faculty/login/+page.server.ts b/s1/src/routes/faculty/login/+page.server.ts new file mode 100644 index 0000000..0b858af --- /dev/null +++ b/s1/src/routes/faculty/login/+page.server.ts @@ -0,0 +1,32 @@ +import type { Actions } from "@sveltejs/kit"; +import { redirect } from '@sveltejs/kit'; + +export const actions: Actions = { + default: async ({ request }) => { + // console.log(request.json()); + + var endpoint = "http://localhost:8082/controller/faculty"; + var data = await request.formData(); + + var res = await fetch(endpoint.concat("?em=", String(data.get('em')), "&pw=", String(data.get('pw'))), { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + // body: JSON.stringify(data), + }) + console.log(res); + var data1 = await res.json(); + console.log(data1); + + if (res.ok) { + // Successful fetch + throw redirect(303, '/'); // Redirect to success page + } else { + // Handle error + return { + error: data1.msg, + }; + } + }, +} \ No newline at end of file