<participant version="6.0">
	<insertText location="aboveHTML+18"><![CDATA[<?php
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
  $MM_dupKeyRedirect="@@dupKeyRedirect@@";
  $loginUsername = $_POST['@@frmUsername@@'];
  $LoginRS__query = sprintf("SELECT @@fldUsername@@ FROM @@tableName@@ WHERE @@fldUsername@@=%s", GetSQLValueString($loginUsername, "@@UsernameFieldType@@"));
  mysql_select_db($database_@@connName@@, $@@connName@@);
  $LoginRS=mysql_query($LoginRS__query, $@@connName@@) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);

  //if there is a row in the database, the username was found - can not add the requested username
  if($loginFoundUser){
    $MM_qsChar = "?";
    //append the username to the redirect page
    if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
    $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
    header ("Location: $MM_dupKeyRedirect");
    exit;
  }
}
?>]]></insertText>
	<searchPatterns whereToSearch="directive">
		<searchPattern paramNames="dupKeyRedirect,frmUsername,fldUsername,tableName,UsernameFieldType,connName" isOptional="false" limitSearch="all"><![CDATA[/\/\/ \*\*\* Redirect if username exists(?:\r\n|\r(?!\n)|\n)[ \t]*\$MM_flag="MM_insert";(?:\r\n|\r(?!\n)|\n)[ \t]*if \(isset\(\$_POST\[\$MM_flag\]\)\) \{(?:\r\n|\r(?!\n)|\n)[ \t]*\$MM_dupKeyRedirect="([^\r\n]*?)";(?:\r\n|\r(?!\n)|\n)[ \t]*\$loginUsername = \$_POST\['([^\r\n]*?)'\];(?:\r\n|\r(?!\n)|\n)[ \t]*\$LoginRS__query = sprintf\("SELECT ([^\r\n]*?) FROM ([^\r\n]*?) WHERE [^\r\n]*?=%s", GetSQLValueString\(\$loginUsername, "([^\r\n]*?)"\)\);(?:\r\n|\r(?!\n)|\n)[ \t]*mysql_select_db\(\$database_([^\r\n]*?), \$[^\r\n]*?\);(?:\r\n|\r(?!\n)|\n)[ \t]*\$LoginRS=mysql_query\(\$LoginRS__query, \$[^\r\n]*?\) or die\(mysql_error\(\)\);(?:\r\n|\r(?!\n)|\n)[ \t]*\$loginFoundUser = mysql_num_rows\(\$LoginRS\);(?:\r\n|\r(?!\n)|\n)[ \t]*(?:\r\n|\r(?!\n)|\n)[ \t]*\/\/if there is a row in the database, the username was found - can not add the requested username(?:\r\n|\r(?!\n)|\n)[ \t]*if\(\$loginFoundUser\)\{(?:\r\n|\r(?!\n)|\n)[ \t]*\$MM_qsChar = "\?";(?:\r\n|\r(?!\n)|\n)[ \t]*\/\/append the username to the redirect page(?:\r\n|\r(?!\n)|\n)[ \t]*if \(substr_count\(\$MM_dupKeyRedirect,"\?"\) >\s*=1\) \$MM_qsChar = "&";(?:\r\n|\r(?!\n)|\n)[ \t]*\$MM_dupKeyRedirect = \$MM_dupKeyRedirect \. \$MM_qsChar \."requsername="\.\$loginUsername;(?:\r\n|\r(?!\n)|\n)[ \t]*header \("Location: \$MM_dupKeyRedirect"\);(?:\r\n|\r(?!\n)|\n)[ \t]*exit;(?:\r\n|\r(?!\n)|\n)[ \t]*\}(?:\r\n|\r(?!\n)|\n)[ \t]*\}(?=\r\n|\r|\n|\?>)/i]]></searchPattern>
	</searchPatterns>
	<quickSearch>$LoginRS=mysql_query($LoginRS__query,</quickSearch>
</participant>
