Jump to content

Not accepting POST value


Minklet

Recommended Posts

I posted this in the Regex forum, but the regex I have works fine, so this seems to be more of a php problem

 

Similarly, this regex to allow an embed code for youtube also will not work when it comes from a form field.

 

This doesnt work:

$embed = $_POST['mixembedlink'];

if (preg_match('/<object width=\"([0-9]*)\" height=\"([0-9]*)\"><param name=\"movie\" value=\"(.*)\"><\/param><param name=\"allowFullScreen\" value=\".*\"><\/param><param name=\"allowscriptaccess\" value=\".*\"><\/param><embed src=\".*\" type=\".*\" allowscriptaccess=\".*\" allowfullscreen=\".*\" width=\"[0-9]*\" height=\"[0-9]*\"><\/embed><\/object>/',$embed,$preg_out)) {;
$width = $preg_out[1];
$height = $preg_out[2];
$url = $preg_out[3];


echo 'WORKING';


} else {
echo 'NOT WORKING!';
}

 

This however does work:

$embed = '<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/1mt3vZHDiM8?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/1mt3vZHDiM8?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>';

if (preg_match('/<object width=\"([0-9]*)\" height=\"([0-9]*)\"><param name=\"movie\" value=\"(.*)\"><\/param><param name=\"allowFullScreen\" value=\".*\"><\/param><param name=\"allowscriptaccess\" value=\".*\"><\/param><embed src=\".*\" type=\".*\" allowscriptaccess=\".*\" allowfullscreen=\".*\" width=\"[0-9]*\" height=\"[0-9]*\"><\/embed><\/object>/',$embed,$preg_out)) {;
$width = $preg_out[1];
$height = $preg_out[2];
$url = $preg_out[3];


echo 'WORKING';


} else {
echo 'NOT WORKING!';
}

 

 

Can anyone shed some light on why this is? The form names are exactly right. I think i've checked and renamed them about 10 times each.

 

 

 

I checked with firebug and compared the POST value to the string in the one that works and they are exactly the same. I can't figure out what the problem is at all

Link to comment
Share on other sites

Did you try using the modifier m so it accepts multiple lines.

 

/<object width=\"([0-9]*)\" height=\"([0-9]*)\"><param name=\"movie\" value=\"(.*)\"><\/param><param name=\"allowFullScreen\" value=\".*\"><\/param><param name=\"allowscriptaccess\" value=\".*\"><\/param><embed src=\".*\" type=\".*\" allowscriptaccess=\".*\" allowfullscreen=\".*\" width=\"[0-9]*\" height=\"[0-9]*\"><\/embed><\/object>/m

 

Also try the s modifier.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.