Zubrag.com
September 15, 2019, 10:33:18 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Problems with redirect & adding extra fields in signup page  (Read 4457 times)
ianprend
Newbie
*
Posts: 5


« on: November 15, 2009, 07:28:43 PM »

Now that I have the cookies sorted out there is just one more problem to solve. I've noticed that this has been mentioned by others on other posts but no answers have been forthcoming.

The problem is that when you add extra fields to the signup page no matter which order you put them in the program seems to regard column 4 in the user management as the redirect url. So if you have the columns listed in users.def as follows..

Login,STRING,12
Password,STRING,12
Email,STRING,30
First Name,STRING,15
Last Name,STRING,15
Address,STRING,40
Postcode,STRING,8
Telephone,STRING,13
Redirect URL,STRING,15

...then when you login to the protected page it redirects to www.myurl.com/firstname or whatever you call that 4th column in user management when it should go to www.myurl.com/index.php on successful login.

Can someone please tell me which file deals with the redirect and how to stop it doing this. It seems like a common problem but no one has posted an answer as yet. It all works perfectly if I don't have the extra fields and just have this in users.def..

Login,STRING,12
Password,STRING,12
Email,STRING,30
Redirect URL,STRING,15

..but as soon as I add the extra fields it reverts to the situation described above. I really would prefer to have those extra fields in the signup process so if anyone can help I would be most grateful. Smiley

Logged
ianprend
Newbie
*
Posts: 5


« Reply #1 on: November 17, 2009, 05:48:29 PM »

Solved! For those of you who are wanting to put extra fields into the signup form here is the solution to stop it redirecting to whatever the value of the 4th column of admin manager.

The key is to move the columns over one place by putting in a dummy redirect url field.

Go to signup.php and look for the following code..

if (USE_EMAIL && !USE_USERNAME)
      die('"USE_USERNAME" must be set to "true" when "USE_EMAIL" is set to "true"');
  }

  function parse_user_input() {
    $this->login = isset($_POST['access_login']) ? $_POST['access_login'] : '';
    $this->pass = $_POST['access_password'];
    $this->email = LOGIN_AS_EMAIL
                 ? $this->login
                 : (isset($_POST['access_email']) ? $_POST['access_email'] : '');


then add this line underneath..

$this->redirect = $_POST['landing'];


You can then add the other fields below this such as..

$this->firstname = $_POST['firstname'];
$this->lastname = $_POST['lastname'];
$this->address = $_POST['address'];
$this->telephone = $_POST['telephone'];

These are extra fields I used but you can make up your own. Now go down further and find the following code...

 fputs($fusers, "\n" . $this->login. ',' . $this->pass . ',' . $this->email);
    fclose($fusers);

and add the following extra info (marked in red)

fputs($fusers, "\n" . $this->login. ','. $this->pass. ','. $this->email. ','. $this->redirect);
    fclose($fusers);

You can then add the extra field names after that such as...

fputs($fusers, "\n" . $this->login. ','. $this->pass. ','. $this->email. ','. $this->redirect. ','. $this->firstname. ','. $this->lastname. ','. $this->address. ',' . $this->telephone);
    fclose($fusers);

Now the last thing you have to do is open up login_form.php and add the following code anywhere in between the <form> </form> tags...

<input name="landing" type="hidden" value="">

You have now given the redirect field a dummy value of nothing which will show up as a blank in the redirect url column (The 4th Column) in admin manager. The other fields you have added will then be automatically entered into their proper columns. Make sure you have them in order in users.def

eg...

Login,STRING,12
Password,STRING,12
Email,STRING,27
Redirect URL,STRING,12
First Name,STRING,14
Last Name,STRING,14
Address,STRING,46
Telephone,STRING,13

Now whenever anyone logs in they will be taken to the default url you set up in settings.php
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC