Jump to content

Archived

This topic is now archived and is closed to further replies.

hotaru

Preg_match issue

Recommended Posts

Here's the basic preg_match:

[code]
$pattern = '/^[a-z0-9]*$/i';
if (!preg_match($pattern, trim($_GET["p"])) || strlen(trim($_GET["p"]) == 0))
[/code]

Now if I have a p that equals a number, it shows the data, but it the p contains letters, it doesn't work! Can someone help, please?

Share this post


Link to post
Share on other sites
[a href=\"http://localhost/test.php?p=icons\" target=\"_blank\"]http://localhost/test.php?p=icons[/a]

works for me.

test.php:
[code]
<?php
$pattern = '/^[a-z0-9]*$/i';
if (!preg_match($pattern, trim($_GET["p"])) || strlen(trim($_GET["p"]) == 0))
{
echo "<html><body>fails</body></html>";
exit;
}
echo "<html><body>success</body></html>";
?>
[/code]

Share this post


Link to post
Share on other sites

×

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.