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

rating

Need help modifying the default login forms

Thread began 11/03/2010 4:43 pm by SaladoGuy | Last modified 11/10/2010 10:09 am by Jason Byrnes | 1798 views | 9 replies |

SaladoGuyBeta Tester

Need help modifying the default login forms

Using Security Assist 1.1.9 (I have the whole "super suite" of WA tools)

FYI, in this post I use the term "redirect" loosely because I don't know the exact technical definition of "redirect".

For my site I generated a complete set of registration and log in forms using the SecurityAssist series of tutorials (securityassist/ "Introduction to SecurityAssist"
01_overview.swf and so on)

During initial user testing, I'm getting reports from the users that they are having a difficult time with the registration and login screens. I need to change some things but I'm not sure how to do it, so let me describe the problems and what I need - and maybe someone can offer a solution.

The way the my site is setup now, when a user tries to add an item to the cart, they are immediately forced to login (the viewcart page has the login page rule restriction enabled). (For reasons that I won't get into right here, I really do need them to log in before they view the cart.) If they ALREADY have an account, they log in and are sent to the viewcart page, and everything is perfect.

However, if they must register because they DON'T already have an account, what ends up happening is this:

1) Customer clicks add to cart
2) Customer sees "Log in or Register" screen, where they click the link to the registration form (I added this link myself, it's just an regular HTML text link)
3) Customer fills out registration form and clicks submit
4) Customer is sent BACK to the login form, apparently because registering does not simultaneously log them in and also because possibly the "insert record" server behavior (a DataAssist behavior) is set to redirect to the login screen
5) Customer submits the login form, and is then sent to the "edit profile" page, instead of viewcart.php.

Usually by this time the new user is terribly confused and wants to leave the site :-(

So in other words, if they already have an account, they log in and are correctly sent (redirected?) to the view cart page, but if they have to register for a new account, the requested destination page (viewport) & redirect gets "lost" and the user ends up being sent to the profile page, instead of the viewcart page. I assume this is because the default action of the login form is to redirect to the profile page, IF the login form was called directly (and somehow by the time we get back around to it, it no longer knows that the user was headed for the viewcart page).

I think there's 2 essential technical problems: First, somewhere during the registration process, the redirect gets lost. Is there some recommended way to preserve that? In other words, I need the registration page to redirect to the original destination page like the login form does, except that somehow the destination page needs to be preserved through several pages (instead of just one).

Second - is there someway to log the user in when they register WITHOUT sending them to the login screen? In other words, make it so that filling out and submitting the registration form logs them in as well as creates their account. My understanding is that the login screen essentially sets several session variables, and once those are set, that's the definition of"logged in". Is that a correct understanding/assessment, or does something else happen during login?

I have another problem with detecting incorrect email addresses, but I'll post about that in another thread.

Sign in to reply to this post

Jason ByrnesWebAssist

For the redirecting issue, you just need to make sure that the link to the registration page will pass along any querystring variables, for example, if the login page is named users_Registration.php, you link should look like:

php:
<a href="users_Registration.php<?php echo ((isset($_SERVER["QUERY_STRING"])?"?".htmlentities($_SERVER["QUERY_STRING"]):""));?>">click here to registeer</a>




To automatically log the user in, you would need to modify the insert record behavior on the registration page so that it does not redirect after the record is inserted.

you would then need to apply the Security assist authenticate user behavior to the page.


Before adding it to the registration page, though, double click the authenticate user server behavior on the log in page and note each of the settings, you will want to make sure to set it up exactly the same on the registration page.

The authenticate user behavior code will most likely be added to the page before the insert record code, you will need to rearrange this so that the record is inserted first.

Sign in to reply to this post

SaladoGuyBeta Tester

Originally Said By: Jason Byrnes
  For the redirecting issue, you just need to make sure that the link to the registration page will pass along any querystring variables, for example, if the login page is named users_Registration.php, you link should look like:

php:
<a href="users_Registration.php<?php echo ((isset($_SERVER["QUERY_STRING"])?"?".htmlentities($_SERVER["QUERY_STRING"]):""));?>">click here to registeer</a>
  



Thank you! For anyone who might read this thread later: I had to add the php code to the text link on the LogIn page as Jason described, then I also had to edit the "insert record" Server Behavior on the Registration page and check the box "Pass original querystring". I'm not sure if that box is normally checked by default or not, I may have unchecked it when I first ran the wizard.

More details coming soon....

Sign in to reply to this post

SaladoGuyBeta Tester

In case I wasn't clear in that last post: Once I made those 2 edits, it followed all the way through to viewcart.php like I wanted it to.

Sign in to reply to this post

Jason ByrnesWebAssist

Glad to hear it is working.

Sign in to reply to this post

SaladoGuyBeta Tester

Originally Said By: Jason Byrnes
  Glad to hear it is working.  



Well almost working.

It works as part of the add-to-cart process, meaning, they can click add to cart, see the login page, click through to the registration page, register & login with one form ( ;-) ) and then be redirected to the viewcart page.

However, if the user simply comes to the site and tries to sign up directly (without going through the add-to-cart function) when I remove all the redirects in the "Authenticate User" behavior dialog, then they get redirected to the "You have entered a duplicate email address" page (even though it's not a duplicate and they are, technically, both registered correctly and getting logged in correctly. It's only the redirect that's broken). I assume that is because it's simply the only other redirect in the code so it defaults to there.

Formerly in the "Authenticate User" behavior dialog, I had it set to be redirected to the customer_profile page if they just come right the the registration page and sign up. I would still like them to be sent to the customer_profile IF it's a "normal" sign-up and they are not in the middle of being redirected to the viewcart page.

Is that possible?

I tried adding the customer_profile "redirect on success" back into it, but they still get sent to the "duplicate email" page. Strange - that all worked before. Maybe the code is in the wrong order?

I'm attaching the page here.

Thanks.

Sign in to reply to this post

SaladoGuyBeta Tester

BTW I really did check the data base (it's a very small test database) and the email addresses I'm trying are unique - they are not already in the DB. :-)

Sign in to reply to this post

Jason ByrnesWebAssist

the code at line 37 - 56:

php:
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
  $MM_dupKeyRedirect="customer_duplicate.php";
  $loginUsername = $_POST['email'];
  $LoginRS__query = "SELECT email FROM customers WHERE email='" . $loginUsername . "'";
  mysql_select_db($database_ploughshare, $ploughshare);
  $LoginRS=mysql_query($LoginRS__query, $ploughshare) 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;
  }
}



comes after the insert record code that is at line 7 - 35

php:
// WA Application Builder Insert
if (isset($_POST["Register_x"])) // Trigger
{
  $WA_connection = $ploughshare;
  $WA_table = "customers";
  $WA_sessionName = "customers_customerid";
  $WA_redirectURL = "";
  $WA_keepQueryString = true;
  $WA_indexField = "customerid";
  $WA_fieldNamesStr = "firstname|lastname|address1|address2|city|state|zip|country|phonenum1|phonenum2|email|password";
  $WA_fieldValuesStr = "".((isset($_POST["firstname"]))?$_POST["firstname"]:"")  ."" . "|" . "".((isset($_POST["lastname"]))?$_POST["lastname"]:"")  ."" . "|" . "".((isset($_POST["address1"]))?$_POST["address1"]:"")  ."" . "|" . "".((isset($_POST["address2"]))?$_POST["address2"]:"")  ."" . "|" . "".((isset($_POST["city"]))?$_POST["city"]:"")  ."" . "|" . "".((isset($_POST["state"]))?$_POST["state"]:"")  ."" . "|" . "".((isset($_POST["zip"]))?$_POST["zip"]:"")  ."" . "|" . "".((isset($_POST["country"]))?$_POST["country"]:"")  ."" . "|" . "".((isset($_POST["phonenum1"]))?$_POST["phonenum1"]:"")  ."" . "|" . "".((isset($_POST["phonenum2"]))?$_POST["phonenum2"]:"")  ."" . "|" . "".((isset($_POST["email"]))?$_POST["email"]:"")  ."" . "|" . "".WA_SHA1Encryption(((isset($_POST["password"]))?$_POST["password"]:""))  ."";
  $WA_columnTypesStr = "',none,''|',none,''|',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_ploughshare;
  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);
  }
}



the code order needs to be reversed so that the record is inserted after checking for the new user name.

Sign in to reply to this post

SaladoGuyBeta Tester

FYI - that works. Thanks!

Sign in to reply to this post

Jason ByrnesWebAssist

glad to hear it is working.

Sign in to reply to this post
loading

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

Content

rating

Layout

rating

Ease of use

rating

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...