Hi, I’m aiming to output this link like: [B][url]www.mysite.com/username[B]user[B]$1
Check out this scenario and notice the username [COLOR=”#FF0000″]mark[COLOR=”#FF0000″]user?=$1
[LIST]
[url]www.mysite.com/[COLOR=”#FF0000″]mark[url]www.mysite.com/[COLOR=”#FF0000″]user?=$1[url]www.mysite.com/[COLOR=”#FF0000″]user?=mark
[B]The Web.config code
[CODE]<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration>
<connectionStrings>
<add connectionString=”server=localhost;uid=tycoonUdyn9;pwd="?rY?%=;u5X8_";Database=tycoon” name=”tycoon” providerName=”MySql.Data.MySqlClient” />
</connectionStrings>
<system.webServer>
<rewrite>
<rules>
<!–<rule name=”rule 1″ stopProcessing=”true”>
<match url=”/*” ignoreCase=”true” />
<action type=”Rewrite” url=”/capture.php?user={URL}” />
</rule>–>
<!– replicating matches like: http://mysite.com/username –>
<rule name=”site” patternSyntax=”Wildcard”>
<match url=”*” />
<conditions>
<add input=”{REQUEST_FILENAME}” matchType=”IsFile” negate=”true” />
<add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” negate=”true” />
</conditions>
<action type=”Rewrite” url=”/capture.php?user=$1″ />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
[B]The parser code
[code=php]define(‘SITE_ROOT’, $_SERVER[‘DOCUMENT_ROOT’]);
require_once(SITE_ROOT . ‘/db.php’);
require_once(SITE_ROOT . ‘/templates.php’);
if (isset($_GET[‘user’])) {
if (!true_user($_GET[‘user’])) {
header(‘Location: /broken_link.shtml’);
} else {
load_template(‘capture’);
}
}
function true_user($user) {
global $tubcConnection;
$query = “SELECT * FROM users WHERE username = ?”;
$stmt = $tubcConnection->prepare($query);
$stmt->bind_param(‘s’, $user);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows === 1) {
return TRUE;
}
return FALSE;
}