close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Redirect if username exists - don't work

Thread began 12/11/2010 1:03 pm by henrik.schlegel400884 | Last modified 12/12/2010 1:16 pm by henrik.schlegel400884 | 1424 views | 4 replies


Hi Brian,

thanks for your reply! Here is the php-code:

<?php require_once('../../Connections/mysql_sonic_magic.php'); ?>
<?php require_once("../../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php require_once("../../WA_SecurityAssist/WA_SHA1Encryption.php"); ?>
// *** Redirect if username exists
if (isset($_POST[$MM_flag])) {
$loginUsername = $_POST['UserEmail'];
$LoginRS__query = "SELECT UserEmail FROM users WHERE UserEmail='" . $loginUsername . "'";
mysql_select_db($database_mysql_sonic_magic, $mysql_sonic_magic);
$LoginRS=mysql_query($LoginRS__query, $mysql_sonic_magic) 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
$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");
// WA Application Builder Insert
if (isset($_POST["Register"])) // Trigger
$WA_connection = $mysql_sonic_magic;
$WA_table = "users";
$WA_sessionName = "users_UserID";
$WA_redirectURL = "users_LogIn.php";
$WA_keepQueryString = false;
$WA_indexField = "UserID";
$WA_fieldNamesStr = "UserEmail|UserPassword|UserFirstName|UserLastName|UserCity|UserState|UserZip|UserPhone|UserCountry|UserAddress";
$WA_fieldValuesStr = "".((isset($_POST["UserEmail"]))?$_POST["UserEmail"]:"") ."" . "|" . "".WA_SHA1Encryption(((isset($_POST["UserPassword"]))?$_POST["UserPassword"]:"")) ."" . "|" . "".((isset($_POST["UserFirstName"]))?$_POST["UserFirstName"]:"") ."" . "|" . "".((isset($_POST["UserLastName"]))?$_POST["UserLastName"]:"") ."" . "|" . "".((isset($_POST["UserCity"]))?$_POST["UserCity"]:"") ."" . "|" . "".((isset($_POST["UserState"]))?$_POST["UserState"]:"") ."" . "|" . "".((isset($_POST["UserZip"]))?$_POST["UserZip"]:"") ."" . "|" . "".((isset($_POST["UserPhone"]))?$_POST["UserPhone"]:"") ."" . "|" . "".((isset($_POST["UserCountry"]))?$_POST["UserCountry"]:"") ."" . "|" . "".((isset($_POST["UserAddress"]))?$_POST["UserAddress"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_mysql_sonic_magic;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
header("Location: ".$WA_redirectURL);

And the form-code in the body:

<div id="RegistrationContainer" class="WAATK">
<form method="post" name="WAATKRegistrationForm" id="WAATKRegistrationForm">
<table class="WAATKDataTable" cellpadding="0" cellspacing="0" border="0">
<th>First Name:</th>
<td><input type="text" class="WAATKTextField" name="UserFirstName" id="UserFirstName" value="" size="32" /></td>
<th>Last Name:</th>
<td><input type="text" class="WAATKTextField" name="UserLastName" id="UserLastName" value="" size="32" /></td>
<td><input type="text" class="WAATKTextField" name="UserAddress" id="UserAddress" value="" size="32" /></td>
<td><input type="text" class="WAATKTextField" name="UserCity" id="UserCity" value="" size="32" /></td>
<td><input type="text" class="WAATKTextField" name="UserState" id="UserState" value="" size="32" /></td>
<th>Zip/Postal Code:</th>
<td><input type="text" class="WAATKTextField" name="UserZip" id="UserZip" value="" size="32" /></td>
<td><input type="text" class="WAATKTextField" name="UserCountry" id="UserCountry" value="" size="32" /></td>
<td><input type="text" class="WAATKTextField" name="UserPhone" id="UserPhone" value="" size="32" /></td>
<td><input type="text" class="WAATKTextField" name="UserEmail" id="UserEmail" value="" size="32" /></td>
<th>Create Password:</th>
<td><input type="password" class="WAATKTextField" name="UserPassword" id="UserPassword" value="" /></td>
<div class="WAATKButtonRow">
<input type="Submit" name="Register" id="Register" value="Register" />
<input name="hiddenField" type="hidden" id="hiddenField" value="MM_insert" />

Thank You!

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...