Check User Name: Isn't happening

I have a registration page in JavaScript that is working fine except for the fact that I need it to check username against the database to insure that usernames do not get duplicated in the database. Because it does not check username I come to realize that user’s information is getting mixed up if the username are the same.  I am sure I am not doing this correctly because I have not used JavaScript before…. So I than created an Insert Record on the registration:
Submit Values From: Form 1
Connection: Rescue
Insert Table: user_registration
Columns: ‘ID’Gets Value From “FORM.username as Integer’
Submit as: Integer
After insert, go to: myprofile.php
After creating the Insert Record I created the Check New Username:
Username Field: username
If already exist, go to: register.php
So I tested to see if what I added worked and it does not.  What does happen- is when I create a new record in which the user has the same username that is all ready in the database…it allows me to create a duplicate username in the database and then send me to the following blank screen with the URL: http://www.rescuealerts.com/forms/user_registration/user_registration.php. Instead of sending me back to registration page to try again. I also realize I need to program in a message stating that username is unavailable try again but I hadn’t gotten to that point because I am first trying to get the Check New Username to work.  Please find below the code for the Insert Record, the Check New Username and the registration input form.
Insert Record and Check New Username Code:
<?php require_once('Connections/rescue.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;   
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  return $theValue;
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
  $MM_dupKeyRedirect="register.php";
  $loginUsername = $_POST['username'];
  $LoginRS__query = sprintf("SELECT ID FROM user_registration WHERE ID=%s", GetSQLValueString($loginUsername, "int"));
  mysql_select_db($database_rescue, $rescue);
  $LoginRS=mysql_query($LoginRS__query, $rescue) 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;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO user_registration (ID) VALUES (%s)",
                       GetSQLValueString($_POST['username'], "text"));
  mysql_select_db($database_rescue, $rescue);
  $Result1 = mysql_query($insertSQL, $rescue) or die(mysql_error());
  $insertGoTo = "myprofile.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  header(sprintf("Location: %s", $insertGoTo));
?>
Registration Code:
<script src='http://www.rescuealerts.com/forms/user_registration/scripts/gen_validatorv5.js' type='text/javascript'></script>
<script src='http://www.rescuealerts.com/forms/user_registration/scripts/sfm_captcha_validator.js' type='text/javascript'></script>
<script src='http://www.rescuealerts.com/forms/user_registration/scripts/sfm-png-fix.js' type='text/javascript'></script>
<link rel='stylesheet' type='text/css' href='http://www.rescuealerts.com/forms/user_registration/style/user_registration.css'/>
<form id='user_registration' method='post' action='http://www.rescuealerts.com/forms/user_registration/user_registration.php' accept-charset='UTF-8'>
   <div id='user_registration_errorloc' class='error_strings' style='width:500px;text-align:left'></div>
  <div id='user_registration_outer_div' style='width:500px;height:1120px'>
      <div style='position:relative; font-weight: normal;' id='user_registration_inner_div'>
         <input type='hidden' name='sfm_form_submitted' value='yes'/>
         <div id='heading_container'>
            <div id='heading'>Please Enter Your Information Here:</div>
         </div>
         <div id='Image2_container'>
            <img class='sfm_image_in_form' src='http://www.rescuealerts.com/forms/user_registration/images/rescue_logo_3 copy.jpg' width='128' height='24' alt='Rescue Alerts Logo'/>
         </div>
         <div id='register_name_container'>
            <input type='text' name='register_name' id='register_name' size='20' class='sfm_textbox'/>
         </div>
         <div id='label39_container'>
            <label id='label39' for='register_name' class='sfm_form_label'>Name:</label>
         </div>
         <div id='register_semail_container'>
            <input type='text' name='register_semail' id='register_semail' size='20' class='sfm_textbox'/>
         </div>
         <div id='register_pemail_container'>
            <input type='text' name='register_pemail' id='register_pemail' size='20' class='sfm_textbox'/>
         </div>
         <div id='label2_container'>
            <label id='label2' for='register_pemail' class='sfm_form_label'>Primary Email:</label>
         </div>
         <div id='label3_container'>
            <label id='label3' for='register_semail' class='sfm_form_label'>Secondary Email:</label>
         </div>
         <div id='register_cellphone_container'>
            <input type='text' name='register_cellphone' id='register_cellphone' size='20' class='sfm_textbox'/>
         </div>
         <div id='register_phone_container'>
            <input type='text' name='register_phone' id='register_phone' size='20' class='sfm_textbox'/>
         </div>
         <div id='label4_container'>
            <label id='label4' for='register_phone' class='sfm_form_label'>Home Phone:</label>
         </div>
         <div id='label5_container'>
            <label id='label5' for='register_cellphone' class='sfm_form_label'>Cell Phone:</label>
         </div>
         <div id='register_pass_container'>
            <input type='password' name='register_pass' id='register_pass' size='20' class='sfm_textbox'/>
         </div>
         <div id='register_login_container'>
            <input type='text' name='register_login' id='register_login' size='20' class='sfm_textbox'/>
         </div>
         <div id='label6_container'>
            <label id='label6' for='register_pass' class='sfm_form_label'>User Password:</label>
         </div>
         <div id='label38_container'>
            <label id='label38' for='register_login' class='sfm_form_label'>User Login:</label>
         </div>
         <div id='heading1_container'>
            <div id='heading1'>Enter Emergency Contact  Information Here:</div>
         </div>
         <div id='label14_container'>
            <div id='label14'>Contact 1:</div>
         </div>
         <div id='con1_cell_container'>
            <input type='text' name='con1_cell' id='con1_cell' size='20' class='sfm_textbox'/>
         </div>
         <div id='con1_name_container'>
            <input type='text' name='con1_name' id='con1_name' size='20' class='sfm_textbox'/>
         </div>
         <div id='label11_container'>
            <label id='label11' for='con1_cell' class='sfm_form_label'>Cell Phone:</label>
         </div>
         <div id='label40_container'>
           <label id='label40' for='con1_name' class='sfm_form_label'>Name:</label>
         </div>
         <div id='con1_land_container'>
            <input type='text' name='con1_land' id='con1_land' size='20' class='sfm_textbox'/>
         </div>
         <div id='label10_container'>
            <label id='label10' for='con1_land' class='sfm_form_label'>Land Line:</label>
         </div>
         <div id='con1_email_container'>
            <input type='text' name='con1_email' id='con1_email' size='20' class='sfm_textbox'/>
         </div>
         <div id='label12_container'>
            <label id='label12' for='con1_email' class='sfm_form_label'>Email:</label>
         </div>
         <div id='label15_container'>

hjohnson2011 wrote:
I have a registration page in JavaScript that is working fine except for the fact that I need it to check username against the database to insure that usernames do not get duplicated in the database. Because it does not check username I come to realize that user’s information is getting mixed up if the username are the same.  I am sure I am not doing this correctly because I have not used JavaScript before….
When asking for help, you stand a much better chance of getting the answers you need if you create a simple test page to illustrate the problem, rather than posting hundreds of lines of code. A test page helps isolate the problem without being distracted by everything else in your complex form.
What's not clear from your description is what the JavaScript is intended to do. Taking a quick look at the code you have posted here, the Insert Record server behavior handles only the username. Yet your form has dozens of fields. Also, the form's action attribute points to user_registration.php. Is this the same page or a different script? If it's a different script, that's what's inserting the values into the database. The Check User Name server behavior is never called. Or is an external JavaScript file taking the values after validation and using an Ajax call to insert them in the database? Again, this would bypass the Check User Name server behavior.
Having said that, the Check User Name server behavior is, to my mind, worse than useless, because it redirects the user to another page, thereby losing all the user input. The simple solution is to add a UNIQUE index to the username column in the database. This prevents a duplicate entry from being inserted. However, you need to customize the Insert Record server behavior to intercept the MySQL error like this:
  // remove the or die() clause
  $Result1 = mysql_query($insertSQL, $rescue);
  // if the username is already in use
  if (!$Result1 && mysql_errno() == 1062) {
      $error = $_POST['username'] . ' is already in use. Choose another.';
  } elseif (mysql_error()) {
      $error = 'Sorry, there is a problem with the database. Try later.';
  } else {
      $insertGoTo = "myprofile.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
  }  // close extra conditional statement
You can then redisplay the page if the username is already taken, and use the $_POST array to preserve the user's input in the form.

Similar Messages

  • PL/SQL Function to check user name and password

    Hi,
    I am new to PL/SQL. I have a table that stores user name and password. I want to write a PL/SQL function that checks if the entered user name and password is correct, by validation against the values in the table... Can someone help me with the code? Both user name and password is varchar2

    First of all, I believe you mean a procedure that would check the application username and password. Fot, if you mean a PL/SQL procedure, that runs in the database, and that means it has to be executed after the client application is connected to the database.
    Maybe you need a procedure like this:
    procedure check_pass(p_user varchar2, p_pass varchar2) is
    pragma autonomous_transaction;
    v_passwd varchar2(200);
    begin
    select passwd into v_passwd
    from password_table
    where user_name=p_user;
    if v_passwd!=p_pass then
    update password_table set
    last_unsucc_logon=sysdate
    ,unsucc_logon_n=nvl(unsucc_logon_n,0)+1
    where user_name=p_user;
    commit;
    raise_application_error(-20101,'Invalid username/password!');
    end if;
    exception
    when no_data_found then
    raise_application_error(-20101,'Invalid username/password!');
    end;
    Study this piece of code and see if this will do.

  • Check user name on selection screen

    Dear all,
    I have been able to make a field mandatory on a selection screen. This is field username. However, the system does not check if the user exists.
    What I have done is made a copy of the program behind LX16: RLINV015
    Now I have ZLX16 and ZRLINV015
    I know the SAP users are found in tabel USR02, so I have added this table under data definition where the other tables are mentioned.
    How do I enforce that only existing usernames are entered?
    Thanks,
    Nick

    Marcin,
    I really appreciate your answer, it brought me somewhere. However, the code I pasted is addeing a new field, whereas I really need the user name in field LINK-UNAME, otherwise my inventory document is not getting the user name.
    I have tried the following to achieve this:
    AT SELECTION-SCREEN.
      SELECT SINGLE bname FROM usr02 INTO link-uname
                                     WHERE bname = pa_user
    This was however not doing the job.
    Do you have any more suggestions?
    Thanks,
    Nick

  • HELP!! My User-Name isn't working. I'm locked out of editing my settings :(

    I tried going into my Time Machine setting to change them and it prompted me to log in "as an administrator" to make changes. It says "Type an administrators name and password to make changes". I didn't know what this meant because usually my name is already in the "Name" field and all I have to do is put in my password. Now, both fields are blank, and when I fill in the name and password fields, it doesn't work. I don't know why. I'm sure the password is right but I I don't know how to determine the correct user name since mine doesn't work : (
    Please help me.

    Reset the password. Info here: http://docs.info.apple.com/article.html?artnum=106156

  • Can't login to my verizon on my new galaxy s3 check user name and password in correct but says that it is not does login over internet

    My new gaxay s3 doesn't login to my verizon on my phone comes up username doesn't match password and I entered right but doesn't work but does login over internet on phone

    ericm1969 wrote:
    My new gaxay s3 doesn't login to my verizon on my phone comes up username doesn't match password and I entered right but doesn't work but does login over internet on phone
      Is the phone that you are running the app from, the primary line for your plan? I had an issue with my RAZR MAXX where with my Fascinate it worked fine, but the MAXX would not let me access it, as it was not the primary line. Once I created a new MyVerizon account username and password it let me in, and I could see everything. The original account worked fine if I ran the app from the primary line phone.

  • Firfox offers unwanted alternatives when I begin to input a user name.

    When I input a user name for yahoo or gmail, Firefox offers alternatives that I have previously input. So I get a list of typos and sometimes my password concatenated to the user name.
    == This happened ==
    Every time Firefox opened
    == I started using Firefox.

    See also:
    http://kb.mozillazine.org/Deleting_autocomplete_entries
    http://kb.mozillazine.org/Password_Manager
    [[Remembering passwords]]

  • I am receiving the 'Could not sign you in [Access denied: 530]. Check your user name and password' problem on Adobe Muse CC 2014 and I cannot access the xml file that is supposed to fix this issue?

    I am a PC user and I have Adobe Creative Cloud Muse 2014. I have received the 'Could not sign you in [Access denied: 530]. Check your user name and password' error when trying to upload my muse site to my ftp host, GoDaddy. I have successfully done this in the past and only recently it has stopped working. I looked online at the FAQ Adobe Muse Help | Uploading an Adobe Muse Site to a third-party hosting service and it said to download the ftpprefs.xml file but this file simply leads to a blank page that says /*Not found*//*Not found*/.
    Can someone direct me to a working page with this file or provide a different solution? Thank you!

    Hello,
    As you are getting error [Access denied: 530] it means issue is with access. Either the username and password you are entering is incorrect or you do not have proper permissions.
    I would suggest you to contact Godaddy to either reset password or reset the permissions.
    Regards
    Vivek

  • Previously Firefox would show a number at the end of the file name (renaming the file by adding a number) showing that I had already downloaded a file at least once before. Recently that isn't happening. How do I get that feature back?

    When downloading, previously Firefox would show a number at the end of the file name (renaming the file by adding a number) showing that I had already downloaded a file at least once. Now that isn't happening. How do I get that feature back?

    When downloading, previously Firefox would show a number at the end of the file name (renaming the file by adding a number) showing that I had already downloaded a file at least once. Now that isn't happening. How do I get that feature back?

  • Yahoo mail remebers my password but not the user name. I've checked the remember box.

    I've checked the remember box but Firefox is remembering the password but is not remembering the user name when I sign in to my email account. I'm not having sign in trouble with IE nor am I having trouble signing in on my laptop with either Firefox or IE, so the problem would seem to be with this computer.

    * Websites remembering you and automatically log you in is stored in a cookie.
    * Create an allow cookie exception (Tools > Options > Privacy > Cookies: Exceptions) to keep such a cookie, especially for secure websites and if cookies expire when Firefox is closed.
    * In [[Private Browsing]] mode all cookies are session cookies that expire if that session is ended, so websites won't remember you.
    * You enter Private Browsing mode if you select: Tools > Options > Privacy > History: Firefox will: "Never Remember History"
    * To see all History and Cookie settings, choose: Tools > Options > Privacy, choose the setting <b>Firefox will: Use custom settings for history</b>
    * Uncheck: [ ] "Automatically start Firefox in a private browsing session"
    * Do not use [[Clear Recent History]] to clear the "Cookies" and the "Site Preferences"
    Clearing "Site Preferences" clears all cookies, images, pop-up windows, software installation, and password exceptions.

  • Error 15401: Windows NT user or group not found. Check the name again

    when adding a windows login on SQL SERVER 2008 R2 below error is throwing
    Windows NT user or group 'domain\user' not found. Check the name again.
    I have gone through the link
    http://support.microsoft.com/kb/324321/en-us &
    http://support.microsoft.com/kb/2770837
    collation setting of the instance is not case sensitive.

    Hi DevXYZ,
    Have you checked the other possible reasons for this issue?
    The login does not exist
    Verify that the Windows login still exists in the domain. Your network administrator may have removed the Windows login for specific reasons, and you may not be able to grant that login access
    to the SQL Server.
    Verify that you are spelling the domain and login name correctly and that you are using the following format:
    Domain\User
    If the login exists, and it is correct, and you still receive the error, continue with the following sections in this article.
    Duplicate security identifiers
    In a Windows domain, unique Security Identifiers (SIDs) are automatically assigned to Windows logins in the domain. When you add a Windows login as a SQL Server login, the SID is stored in a system table in SQL Server. If you try to add a new login which has
    the same SID as an existing SQL Server login, the 15401 error occurs.
    Authentication failure
    You might receive error 15401 when the domain controller for the domain where the login resides (the same or a different domain) is not available for some reason. 
    If the login is in a different domain than the SQL Server, verify that the correct trusts exist between the domains.
    Verify that the domain controller of the login is accessible by using the
    ping command from the computer that is running SQL Server. Check both the IP address and the name of the domain controller.
    After you tried all the possible methods list above, you still receive the same error, please check the error log as Dean Savović mentioned above and share us the detailed error message here
    as we can analysis further.
    Thanks
    Candy Zhou

  • TS3988 Each time I log into iCloud, I check, Keep me logged in, but this does not work.  I have to reenter user name etc each time I try to go back to my iCloud account.

    Each time I log into iCloud, I check, Keep me logged in, but this does not work.  I have to reenter user name and password etc each time I try to go back to my iCloud account.

    Hi,
    In Keychain Access app in the Menu for the App is Keychain First Aid.
    If you open this is the tick box for Synchronising the Login password with the so called Login Keychain ticked ?
    9:49 pm      Monday; March 16, 2015
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • On Yahoo Mail...and ONLY Yahoo Mail..I get a 404 error after entering my user name and password. This doesn't happen with IE, just Firefox, and just Yahoo Mail. Yahoo was absouletly no help whatsoever; can you solve the mystery? Thanks

    On Yahoo Mail...and ONLY Yahoo Mail..I get a 404 error after entering my user name and password. This doesn't happen with IE, just Firefox, and just Yahoo Mail. I tried uninstalling and reinstalling FF; no change. Yahoo was absolutely no help whatsoever; can you solve the mystery? Thanks

    HI Emmet,
    thanks so much for your posts back. I really appreciate it and yes that does help to know that you could not get it working.
    I did have some success, in removing the SSL Authentication checkbox in the smtp server settings - I found that this allowed my friend to be able to send mail from the mail app via his sbcglobal (yahoo) account.
    So that did help but of course the messages do not have ssl encryption and I'm not sure how big a deal that is for an individual. He is able to receive mail but unless the SSL authentication box is unchecked, he cannot send.
    i hope that helps anyone out there also!
    Thanks also for the tip about sparrow - yes I have heard of it and it is very popular, he may end up using that in the end.    
    Thanks again, much appreciated.
    Felix    

  • TS3899 When i check my email I get the message "Cannot Get Mail.  The user name or password for "Gmail" is incorrect".  The user name and password are definiately correct, I can log on through safari.  This worked fine this morning!

    My gmail account has stopped working on my iphone, saying the user name or password is incorrect, but both are definitely correct.  I have tried restarting the phone, deleting the account and setting it up again, and checked that I can log on through safari.  It had been working fine until this morning!  Any ideas how to fix this?

    Turn off 2 step authentication on your gmail account in a browser.   It should work fine afterwards.

  • When checking email I now get an error message saying User name or password is incorrect...

    When checking email I now get an error message saying User name or password is incorrect...  Went to AT&T store and they didn't have a clue how to fix it...
    I'm sure this question has been asked, but can someone point me in the right direction? 

    I am also having the same problem and I did go on my computer and change the password and my iPad still gives error message. Yes wish someone could help.

  • Why is my mail saying "cannot get mail - user name or password for Gmail is incorrect" but on the Gmail app there is no problem.  I have checked the settings and everything seems to be ok

    Why is my mail saying "cannot get mail - user name or password for Gmail is incorrect" but on the Gmail app there is no problem.  I have checked the settings and everything seems to be ok

    Go here and unlock your account... https://www.google.com/accounts/DisplayUnlockCaptcha

Maybe you are looking for

  • C:forEach and logic:iterate tags repeating elements of a collection

    I have an issue that makes absolutely no sense to me. Basically I am using struts, and I am returning a form that contains a List of customers. I am simply trying to iterate that list into a simple table for each customer. The end result will have ro

  • Keyboard and Touch Screen both not working

    Hi everyone. My dog got to my palm pre and put a crack in the screen. I ordered a new one on Ebay.  So I disassembled the phone, and reassembled it using Youtube videos. No spare screws or parts so I'm pretty sure I did it correctly. The touchscreen

  • How can i find the jar file version in Solaris

    Hi,all. I just forget the java command by which i can know a jar file's version.I searched the jar command manual,unfortunately there is nothing helpful. Can anyone tell me what should i do? Thanks in advance.

  • I've installed firefox and the bookmarks doesn't work

    I've installed, un-installed, and re-installed firefox. Bookmarks will not work. I've clicked the star - and nothing. I've tried to use the menu bar to bookmark a page and - nothing. I've checked the sqllite file and it is not marked as read only. Wh

  • How extract a custom site-collection templates from Central Administration (SharePoint 2007)

    In our company installed SharePoint 2007. On the tab "Create site collection" in the Central Administration we have a custom template (for russian language), which has been installed by previous developer. There is no documentation or installation fi