Media playback is unsupported on your device Media caption Fred Guttenberg said he couldn't remember if he had told his daughter Jaime that he loved her

The teenager accused of killing 17 people at a Florida high school on Wednesday has confessed to the shooting, police say.

Nikolas Cruz, 19, said he arrived on campus and began shooting students before abandoning his weapon and escaping, according to a court document.

He has appeared in court charged with 17 counts of premeditated murder.

The FBI has admitted it received a tip-off about him last year.

The attack, at Marjory Stoneman Douglas High School in Parkland, Florida, is the deadliest US school shooting since 2012.

"Cruz stated that he was the gunman who entered the school campus armed with a AR-15 and began shooting students that he saw in the hallways and on the school grounds," according to the court document.

He said he was carrying extra ammunition in a black duffel bag and backpack, it said.

Mr Cruz then discarded his weapon in an attempt to blend in and escape, the documents showed.

He was reportedly able to flee the scene undetected before entering a Walmart and then a McDonald's, and was eventually spotted by police and arrested one hour after the attack.

What do we know about the suspect?

Mr Cruz had been expelled from the school he has confessed to attacking and some students said they had joked "he's the one to shoot up the school".

Media playback is unsupported on your device Media caption Inside the classroom: 'We watched gunman shoot our friends'

One former schoolmate, Chad Williams, told Reuters Mr Cruz was an "outcast" who was "crazy about guns".

His interest in weapons was apparent on his social media profiles, which Broward County Sheriff Scott Israel said were "very, very disturbing".

Two separate Instagram accounts, now deleted, purport to show Mr Cruz posing with guns and knives.

What were the warnings?

After seeing a comment on a YouTube post last year by Mr Cruz, user Ben Bennight contacted the FBI and spoke to representatives for about 20 minutes.

Mr Bennight said the FBI contacted him again following the school shooting in Parkland.

Media playback is unsupported on your device Media caption Florida shooting suspect appears in court

The FBI confirmed on Thursday that they were made aware of the comment, adding that they had conducted "checks" but were unable to identify the person behind it.

Meanwhile, maths teacher Jim Gard told the Miami Herald that school authorities had emailed teachers about Mr Cruz's behavioural problems.

"There were problems with him last year threatening students, and I guess he was asked to leave campus," he said.

Media playback is unsupported on your device Media caption Footage posted on social media captures the moment Nikolas Cruz opened fire

Who were the victims?

Three staff members and 14 students died in the attack.

The school's assistant football coach, Aaron Feis, was shot after jumping in front of students to shield them from bullets. His team tweeted that he had "died a hero".

Chris Hixon, who was the athletic director at the school, was also confirmed dead by local media. In 2007 Mr Hixon, 49, served as a US Naval Reservist in Iraq.

Teacher Scott Beigel died while trying to lock the door, a student told Good Morning America.

The students who died were:

Alyssa Alhadeff , 14

, 14 Martin Duque , 14

, 14 Alaina Petty , 14

, 14 Alex Schachter, 14

14 Jaime Guttenberg , 14

, 14 Cara Loughran , 14

, 14 Gina Montalto , 14

, 14 Luke Hoyer , 15

, 15 Peter Wang , 15

, 15 Carmen Schentrup , 16

, 16 Nicholas Dworet , 17

, 17 Joaquin Oliver , 17

, 17 Helena Ramsey , 17

, 17 Meadow Pollack, 18

On Thursday, thousands of people attended a candlelit vigil to honour the victims. There were chants of "no more guns" as speakers demanded tougher gun laws.

What's the reaction been?

In the wake of the shooting, politicians across the ideological spectrum were quick to offer their condolences. But the conversation soon turned to gun control.

Democrats, many of whom expressed frustration at the levels of gun violence in the US, proposed increased regulation of firearms.

Florida's Democratic Senator Bill Nelson asked what it would take "for enough to be enough".

In an emotional interview on CNN, the mother of one of the victims called on President Trump to respond with policy.

"Do something. Action, we need it now. These kids need safety now," she said.

Image copyright AFP Image caption Thousands of people attended a candlelit vigil to honour the victims

But many Republicans refused to be drawn into the debate.

In his address to the nation on Thursday, Donald Trump didn't mention the word "gun" or "firearm" once.

Florida Senator Marco Rubio said that it was too soon to debate whether tighter gun laws could have stopped it.

Texas Senator Ted Cruz accused Democrats of politicising the shooting.

"They immediately start calling that we've got to take away the Second Amendment rights of law-abiding citizens. That's not the right answer," he told Fox News.