Deny certain pasted text in $POST['..']

Hey everyone,

I’ve just took 5 minutes to code on a link generator, that takes input submitted with $POST, and generates an <iframe> link. I’ve only used 2 variables for that, but since I actually thought about making it only for YouTube links, how could I only allow to submit links (only)?

To allow both:

if (!preg_match('~^http:\\/\\/(www\\.)?youtube\\.com~', $_POST['url'])) {
  echo 'Youtube URL's only';


Ok, thanks. I was just about thinking about the comparison, and if-else statement. I was probably a bit confuzed. The problem now actually is, it doesn’t allow ANY other link of youtube. For example

What determines if it’s a youtube link? Starting with ?

if(strpos($_POST['url'], '') !== 0) {
  echo 'You Tube videos only';

Finished product, btw:

Works. Thank you. :smiley:

Note the difference - his looks for , you put in

Adjust the pattern.