Jump to content

Edge11

New Members
  • Posts

    1
  • Joined

  • Last visited

Edge11's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello everyone I have script php and input html which input form let user pass only if writen anything is random before -admin-com for example if user put jfucfbhx3-admin-com or fhcd35-admin-com or anything random before -admin-com will pass to the next page alledite.php but if user writen on the input something that is not before -admin-com won't pass so only let user pass if writen something random before -admin-com here is the script <?php # for test porpoises define('BR','<br />'); if( $_SERVER['REQUEST_METHOD']=='POST' && !empty( $_POST['code'] ) ){ # set $displayonly=false to actually do the redirection $displayonly=false; $code=filter_input(INPUT_POST,'code',FILTER_SANITIZE_STRING); $pages=array( '-admin-com' => 'alledite.php', '-moderator-com' => 'halfedite.php', '-coroot-com' => 'edite.php' ); foreach( $pages as $str => $redirect ){ # construct a basic regex pattern from the array key. $pttn=sprintf( '@((.*)?%s)@', preg_quote( $str ) ); # for testing if( $displayonly )echo $pttn . BR; # Run the regex and if a match is found use the corresponding # value from the above array as the redirection endpoint. preg_match( $pttn, $code, $matches ); if( !empty( $matches ) ){ $header=sprintf('Location: %s', $redirect ); exit( $displayonly ? $header : header( $header ) ); } } } ?> <!DOCTYPE html> <html lang='en'> <head> <meta charset='utf-8' /> <title>Match string and redirect</title> </head> <body> <form method='post'> <input type='text' name='code' /> <input type='submit' /> </form> </body> </html> So the part of regex is who do this is @((.*)?%s)@ Its all working now like charm but what I want is the same idea with different text I want a regex like @((.*)?%s)@ For @admin.com not for -admin-com as shown in code below I have showed you guys all my script to understand me deeply please any help I will appreciate it thanks
×
×
  • Create New...

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.