Collegeboox Posted November 6, 2011 Share Posted November 6, 2011 I am trying to write an if statement that checks to make sure the information put in the text box is an imbedded file. Does anyone know how to do that? Quote Link to comment https://forums.phpfreaks.com/topic/250538-if-statements-contains/ Share on other sites More sharing options...
nethnet Posted November 6, 2011 Share Posted November 6, 2011 Elaborate on this please. What do you mean exactly when you say you want to check a text box for an imbedded file? A text box will contain a string.. are you meaning to check for a filepath on your server? Quote Link to comment https://forums.phpfreaks.com/topic/250538-if-statements-contains/#findComment-1285389 Share on other sites More sharing options...
Collegeboox Posted November 6, 2011 Author Share Posted November 6, 2011 My site is a music blogging site where the admins blog music that they have found and I want to make sure that they type in "<iframe width="640" height="360" src="http://www.youtube.com/embed/BPVlNTQRoZk?feature=player_embedded" frameborder="0" allowfullscreen></iframe>" in the textbox rather than this " Ideas? Quote Link to comment https://forums.phpfreaks.com/topic/250538-if-statements-contains/#findComment-1285391 Share on other sites More sharing options...
trq Posted November 6, 2011 Share Posted November 6, 2011 Why would you want your users to have to type more than they need to. Why not, instead, have your program output the markup, and your users simply provide the link? Quote Link to comment https://forums.phpfreaks.com/topic/250538-if-statements-contains/#findComment-1285398 Share on other sites More sharing options...
Collegeboox Posted November 6, 2011 Author Share Posted November 6, 2011 The users are not using it is is a group of 4 admins one including me. Also I do not know how to do that otherwise that is what I would have done. Quote Link to comment https://forums.phpfreaks.com/topic/250538-if-statements-contains/#findComment-1285399 Share on other sites More sharing options...
trq Posted November 6, 2011 Share Posted November 6, 2011 Once you have the url in a variable you would simply echo it something like: echo "<iframe width='640' height='360' src='$url' frameborder='0' allowfullscreen></iframe>"; Quote Link to comment https://forums.phpfreaks.com/topic/250538-if-statements-contains/#findComment-1285401 Share on other sites More sharing options...
KevinM1 Posted November 6, 2011 Share Posted November 6, 2011 It's easier to do what thorpe suggests than what you want to do. Think about it: With thorpe's suggestion, you need to check if the link is valid; that it fits the format you're looking for. But, you can ensure that the iframe the link goes in is correctly formed as you'd be creating it programmatically. With your idea, you'd need to verify that the iframe is correctly formed AND verify that the link within is also valid. It's more work for no real gain. Regarding output, well, how were you going to output these iframes originally? Just take the (hopefully well-formed) iframes from the db and echo them, right? If that's the case, then why can't you simply echo a premade iframe with the particular link variable as its source? EDIT: see thorpe's code above. Quote Link to comment https://forums.phpfreaks.com/topic/250538-if-statements-contains/#findComment-1285404 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.