use Illuminate\Http\Request; use App\Models\User; //User model public function store(Request $request) { $user = new User; $user->name = $request->name; $user->email = $request->email; $user->password = $request->password; $user->saveInto('users'); //Saves the user values into the 'users' table in the database return redirect()->back()->with('success','User added successfully.'); }
$file = fopen("records.txt", "a"); //Opens the file in 'append' mode $txt = "Name: ".$_POST['name']."\nEmail: ".$_POST['email']."\nPhone: ".$_POST['phone']."\n"; fwrite($file, $txt); //Writes the form values into the file fclose($file); //Closes the fileIn this example, the form values are collected using the $_POST superglobal and written into a text file named "records.txt". The saveInto method is not used in this case as it is not required for file handling.