hotaru Posted April 7, 2006 Share Posted April 7, 2006 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? Link to comment https://forums.phpfreaks.com/topic/6782-preg_match-issue/ Share on other sites More sharing options...
DougieB2 Posted April 7, 2006 Share Posted April 7, 2006 seems to work ok. can you give an example of a 'p' string that fails? Link to comment https://forums.phpfreaks.com/topic/6782-preg_match-issue/#findComment-24684 Share on other sites More sharing options...
hotaru Posted April 7, 2006 Author Share Posted April 7, 2006 ./p=icons Link to comment https://forums.phpfreaks.com/topic/6782-preg_match-issue/#findComment-24717 Share on other sites More sharing options...
DougieB2 Posted April 7, 2006 Share Posted April 7, 2006 [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] Link to comment https://forums.phpfreaks.com/topic/6782-preg_match-issue/#findComment-24868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.