Results 1 to 10 of 10

Thread: Requiring User in Add.php

  1. #1
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default Requiring User in Add.php

    I want those who add a listing also be signed up as a user. I have added a field called username to the idx_link table. Then during the add listing process, I want to compare the email address and the user name in the idx_users table to the information being submitted thru add.php to make sure the email address and user name will be the same. They have to be in idx_users table first but I am not requiring the user to logged in at this point. But I will probably make that requirement shortly.

    In the ProcessFormAddUrl() function of add.php just before the line if(empty($error_msg)) { , I added the following:
    // mod to look for user name and email
    $conn = ConnectDB();
    $query = "select username, email from idx_users where email = '$email'";
    $result = $conn->Execute($query);
    if($result) {
    $u_email = $result->Fields("email");
    $u_username = $result->Fields("username");
    }
    if($u_email != $email) $error_msg = $msg["10101a"];
    if($u_username != $username) $error_msg = $msg["10101b"];
    Just a few lines above that, make the folllowing change:
    Code:
      // vars template
    // mod for $username
      global $error_msg, $password, $link_id, $title, $url, $description, $contact_name, 
    $email, $bid, $category, $add_cat1, $add_cat2, $keywords, $username ;
    NOTE: the global line should be just one line. I made it two lines for the forum because I hate to scroll to the right on the screen.

    Finally, in the msg.php file in the /themes/default folder, add the following after $msg["10107"] about line 467

    Code:
    // mod for user name
    $msg["10101a"] = "Email does not match the email in the user file";
    $msg["10101b"] = "Username does not match username in the user file";
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  2. #2
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    I also wanted to prevent duplicate email addresses in the user file.

    Open up users.class.php and make the following changes

    Code:
      function Register($username,$email,$password) {
      
        $username = strtolower($username);
    // mod for requiring username / email
        $email = strtolower($email);
    
        // check for existing user
        
    // mod for requiring username / email
    //    $query = "select username from $this->table_name where username='$username'";
        $query = "select username, email from $this->table_name where username='$username' or email='$email'";
    if you want to, make the following change in msg.php
    Code:
    $msg["10078"] = "Username or Email already exists";
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  3. #3
    Join Date
    May 2003
    Posts
    69

    Default

    How is this working out... I have had users place a listing and then sign up for a user account...they get confused because now they have a user id #, a username and 2 different passwords... I think that if this will work it will solve a lot of future problems with login mistakes...

    Let me know

    Lordkinjo
    Lordkinjo

  4. #4
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    seems to be ok.

    I just need to insert the username and password into the add form so that the info is automatically there.

    If I figure it out, I'll post it here.
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  5. #5
    Join Date
    Feb 2004
    Posts
    49

    Default

    Originally posted by esm
    seems to be ok.

    I just need to insert the username and password into the add form so that the info is automatically there.

    If I figure it out, I'll post it here.
    Have you figured it out?

  6. #6
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    in the add_form.html, add the following at the top just after rows that deal with "Add your site"

    Code:
    <tr class="tbl_normal">
      <td valign=top>username<input type=hidden name=username value="<%username%>"></td>
      <td><%username%></td>
    </tr>
    <tr class="tbl_normal">
      <td>Email</td>
      <td><%email%><input type=hidden name=email value="<%email%>"></td>
    </tr>
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  7. #7
    Join Date
    Feb 2004
    Posts
    49

    Default

    What about modify.html? Do I need to replace <input name=email value="<%email%>"> with just <%email%> as well to prevent it from being changed?

  8. #8
    Join Date
    Feb 2004
    Posts
    49

    Default

    Originally posted by esm
    in the add_form.html, add the following at the top just after rows that deal with "Add your site"

    Code:
    <tr class="tbl_normal">
      <td valign=top>username<input type=hidden name=username value="<%username%>"></td>
      <td><%username%></td>
    </tr>
    <tr class="tbl_normal">
      <td>Email</td>
      <td><%email%><input type=hidden name=email value="<%email%>"></td>
    </tr>
    With these added, I assume that I don't have to enter Email and Username in the form? Because they don't propagate in the add.html form.

  9. #9
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    there is no add.html file

    since the user is logged in, the Email and Username will display on the screen.
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  10. #10
    Join Date
    Feb 2004
    Posts
    49

    Default

    add_form.html is what I was referring to.

    I tried your code, I logged in but the <%username%> and <%email%> don't propagate. They just remain empty.

Similar Threads

  1. Unable to log user out
    By sissy in forum v5.x
    Replies: 3
    Last Post: 01-28-2004, 07:50 PM
  2. looking up user during add process
    By esm in forum v5.x
    Replies: 3
    Last Post: 06-18-2003, 10:27 PM
  3. User login problem
    By webmasterjr in forum v5.x
    Replies: 3
    Last Post: 12-16-2002, 06:03 AM
  4. User CP questions ???
    By ideavirus in forum v5.x
    Replies: 3
    Last Post: 07-14-2002, 07:05 AM
  5. How to disable user registration
    By binto in forum v5.x
    Replies: 1
    Last Post: 06-21-2002, 11:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •