TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 10-16-2008, 07:15 PM   #1 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Help Small php error - Thank you in advance!

there is no error outputted but i know the problem is in the preg_match part. Some assistance would be great!
Thank you!


Rules for preg:match, and to blur for me to read ;)
PHP Code:
int preg_match string $pattern string $subject [, array &$matches [, int $flags [, int $offset ]]] ) 
The script is small and might be ugly but it is only a practice run ;) so no flame :)

PHP Code:
<?php
error_reporting
(E_ALL E_NOTICE);

include 
"config.php";

if(isset(
$_POST['submit']))
{

$url=$_POST['url'];
if(
strlen($url)<1

  
{

      print 
"You did not enter a URL.";

  

  }

    
  }
if (
preg_match('~^http://[a-z]{2,3}\.youtube\.com/\?v=[\w-]+(?:&feature=related)?$~i','',$url)) {
 
    
$url="INSERT into upload (link) values('$url')";

    
mysql_query($url) or die(mysql_error());

    print 
"Link added!";

}

else

  {

    print 
"<form action='index.php' method='post'>";

    print 
"URL(include http://):<br>";

    print 
"<input type='text' name='url' size='20'><br>";

    print 
"<input type='submit' name='submit' value='submit'></form>";

 }





?>
Code;Freeek,.
codefreek is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 06:03 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design