I want to use headers to redirect the client if they didn't come from the
correct page, but I have a problem with one page. If they leave a form field
empty, they are redirected back to the page they came from with an error
number and a 6 digit 1d number in the location bar which defines what field
was left empty( order.php?prob= 2&id=000001)
My only problem is that when they repost, the $_SERVER['HTTP_REFERER']
contains the get variables and doesn't match, so they get redirected.
Instead of coding an if statement for every possible combination of error
numbers and ids, I decided it would be faster to use regular expressions.
This is the first time I've ever used regular expressions. I've found lots
of tutorials for regular expressions in Perl, but none of them seem to cross
over properly to PHP, or at least for what i need. I have the following
code....
preg_match("htt p://fakeaddress\.sy tes\.net/pillowtalk/order\.php(\?pr ob=[0-4
])?", $_SERVER['HTTP_REFERER'])
which keeps on returning "Warning: Delimiter must not be alphanumeric or
backslash in line 2"
I was wondering if anybody knows of a good place to learn how to use regular
expressions in PHP, or if you could tell me what I'm doing wrong? Thanks
--
Warren
-- Custom web design, cheap like cheese
correct page, but I have a problem with one page. If they leave a form field
empty, they are redirected back to the page they came from with an error
number and a 6 digit 1d number in the location bar which defines what field
was left empty( order.php?prob= 2&id=000001)
My only problem is that when they repost, the $_SERVER['HTTP_REFERER']
contains the get variables and doesn't match, so they get redirected.
Instead of coding an if statement for every possible combination of error
numbers and ids, I decided it would be faster to use regular expressions.
This is the first time I've ever used regular expressions. I've found lots
of tutorials for regular expressions in Perl, but none of them seem to cross
over properly to PHP, or at least for what i need. I have the following
code....
preg_match("htt p://fakeaddress\.sy tes\.net/pillowtalk/order\.php(\?pr ob=[0-4
])?", $_SERVER['HTTP_REFERER'])
which keeps on returning "Warning: Delimiter must not be alphanumeric or
backslash in line 2"
I was wondering if anybody knows of a good place to learn how to use regular
expressions in PHP, or if you could tell me what I'm doing wrong? Thanks
--
Warren
-- Custom web design, cheap like cheese
Comment