Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 05-29-2008, 08:40 PM preg_match help
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
This is what I have:
PHP Code:
preg_match('/^http:\/\/:[www.]?arenlor.com\/index2.php$/i',$_SERVER['HTTP_REFERER']) 
I know referer can be faked or disabled but this isn't anything more than a fun feature on my one page actually so it's not needed. Anyway I think the issue is with the [www.]? part or it may be with the colon, not sure.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
 
Register now for full access!
Old 05-30-2008, 04:10 PM Re: preg_match help
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Check out this change:
PHP Code:
<?php
$_SERVER
['HTTP_REFERER'] = 'http://www.arenlor.com/index2.php';
$_SERVER['HTTP_REFERER'] = 'http://arenlor.com/index2.php';
if (
preg_match('/^http:\/\/(?:www.)?arenlor.com\/index2.php$/i',$_SERVER['HTTP_REFERER'])) {
  echo 
'Referrer Match';
}
?>
There were 2 issues:
1) You had an extra colon in there.
2) Brackets are used to list allowed characters, not to denote a section (that's not the right word, but hopefully you get what I mean). Use parenthesis to denote a section. Adding ?: after the first parenthesis means that it doesn't capture the match -- it's optional for your usage here.

Hope that helps
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 05-31-2008, 02:12 AM Re: preg_match help
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
Thanks, that solved it, not sure what the first two lines are though.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 05-31-2008, 02:14 AM Re: preg_match help
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
That's me sticking in test data. You wouldn't use it on a live site.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 05-31-2008, 02:50 AM Re: preg_match help
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
I never knew you could manipulate $_SERVER like that.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 05-31-2008, 03:06 AM Re: preg_match help
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
You can do that with any of the global variables.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 05-31-2008, 03:12 AM Re: preg_match help
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
That's pretty sweet.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Reply     « Reply to preg_match help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.71152 seconds with 12 queries