0
I am developing a website for sending videos to teachers, for this, I made a form with the following fields:
Considering I’m still learning PHP. I would like to know if it is possible to have the youtube link inserted by the user filled in the following way in mysql:
Video link inserted by the user: https://www.youtube.com/watch?v=KBk-ayp6yyU
Apart from the link, I would like only mysql to be the video code, as an example:
Kbk-ayp6yyU
Another example:
Link: https://www.youtube.com/watch?v=Nzta28cfu3w
In mysql: Nzta28cfu3w
How can I do this? Below is the registration:
<?php
include("conexao.php");
$nome_video = $_POST['nome_video'];
$disciplina = $_POST['disciplina'];
$link_video = $_POST['link_video'];
$coment_video = $_POST['coment_video'];
$arquivo = $_FILES["arquivo"];
if (is_uploaded_file($_FILES['arquivo']['tmp_name'])){
$extensao = strtolower(substr($_FILES['arquivo']['name'], -4)); //pega a extensao do arquivo
$novo_nome = md5(time()) . $extensao; //define o nome do arquivo
$diretorio = "upload/"; //define o diretorio para onde enviaremos o arquivo
move_uploaded_file($_FILES['arquivo']['tmp_name'], $diretorio.$novo_nome); //efetua o upload
$sql_logar = "INSERT INTO video_monitor (titulo_video, disciplina, link_video, coment_video, arquivo, data)
VALUES('$nome_video', '$disciplina', '$link_video', '$coment_video', '$novo_nome', NOW())";
$exe_logar = mysqli_query($conection, $sql_logar) or die (mysqli_error($conection));
} else {
$sql_logar = "INSERT INTO video_monitor (titulo_video, disciplina, link_video, coment_video, arquivo, data)
VALUES ('$nome_video', '$disciplina', '$link_video', '$coment_video', 'Nenhum arquivo', NOW())";
$exe_logar = mysqli_query($conection, $sql_logar) or die (mysqli_error($conection));
}
?>
https://stackoverflow.com/questions/412467/how-to-embed-youtube-videos-in-php
– Matheus