How to Add to the signup form

Started by timholt, January 21, 2008, 05:57:35 PM

timholt

I have added a mailing address to the form and users.def but it will not report to users.php. and manager.php, what do I need to do.

zubrag

Hi. Could you post your users.def contents here?

timholt

Here you go Zubrag,

Login,STRING,15
Password,STRING,15
Email,STRING,30
Mailing Address,30
City,30
State,2
Zip Code,5
Redirect URL,STRING,40

zubrag

Each column you add should have data type specified. Like STRING, TEXT, etc. Your fixed definition file would look like this:

Login,STRING,15
Password,STRING,15
Email,STRING,30
Mailing Address,STRING,30
City,STRING,30
State,STRING,2
Zip Code,STRING,5
Redirect URL,STRING,40

timholt

Thanks Zubrag,
Now I have a column for each in manager.php but it's blank. It's not posting the addtional info to manager its just blank. Below is my signup_form.php, is it correct?

<form method="post">
      <img src="/protect/signup.jpg" align="left"><h3><font color="CC9966">HPT Archives Registration</h3></font>
      <font color="red"><?php echo $this->error; ?></font><br />
      Login:<br /><input type='input' name='access_login' value='<?php echo $this->login ?>'/><br />Password:<br />
      <input type="password" name="access_password" />
  <?php if (USE_EMAIL && !LOGIN_AS_EMAIL) echo "<br />Email:<br /><input type='input' name='access_email' value='$this->email' />"; ?><br />
      Mailing Address:<br /><input type='input' name='address' value='<?php echo $this->address ?>' /><br />
     City:<br /><input type='input' name='city' value='<?php echo $this->city ?>' /><br />
     Zip Code:<br /><input type='input' name='zip'value='<?php echo $this->zip ?>' /><br />
     State:<br /><input type='input' name='state'value='<?php echo $this->state ?>' /><br />
     <p></p>
      <input type="submit" name="access_submit" value="Sign up" />
    </form>

zubrag

Hi. Adding fields on the signup form does not automatically get them filled in database (i.e. what you see in manager.php)

In order to save them, you'll have to update following code in signup.php

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'] : '');
    $this->city = $_POST['city'];
    $this->zip = $_POST['zip'];
    ... same for other fields you want to be saved from signup.php


Code in bold should be added

Also, following code needs to be updated with your new fields:

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

Does this help?

timholt

Thanks!!

My add ons work perfectly now!
This is a great script and we appreciate all the support.

Thanks again...

hawkeye0386

Hi Zubrag,

I am working on this right now, and I can't seem to get it to work. Here is are my files.

user.def

Login,STRING,15
Password,STRING,15
Email,STRING,30
First Name,String,30
Last Name,String,30
Redirect URL,STRING,40

signup_form.php

<form method="post">
      <p><span class="style3">User signup</span></p>
      <p><font color="red"><?php echo $this->error; ?></font><br />
         
       <font color="#BA9715" size="2" face="Verdana, Arial, Helvetica, sans-serif">Login:</font><br />
         <input type='input' name='access_login' value='<?php echo $this->login ?>'/><br />
         <font color="#BA9715" size="2" face="Verdana, Arial, Helvetica, sans-serif">Password:</font><br />
         <input type="password" name="access_password" />
         <?php if (USE_EMAIL && !LOGIN_AS_EMAIL) echo "<br />Email:<br /><input type='input' name='access_email' value='$this->email' />"; ?>
         <br>
         <span class="style4">First Name:</span><br />
        <input type='input' name='FirName' value='<?php echo $this->FirName ?>' />
        <br />
         <span class="style4">Last Name:</span><br />
        <input type='input' name='LasName'value='<?php echo $this->LasName ?>' />
        <br />

signup.php

   $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'] : '');
   $this->FirName = $_POST['first name'];
    $this->LasName = $_POST['last name'];
   
    fputs($fusers, "\n" . $this->login . ',' . $this->pass . ',' . $this->email . ',' . $this->FirName . ',' . $this->LasName);

Can you find what I am doing wrong. Thanks!

Revenant

Could it be that you need an underscore for first_name, and last_name

   $this->FirName = $_POST['first name'];
    $this->LasName = $_POST['last name'];


Just a sincere guess.


Revenant

My login form keeps redirecting to the $fullname in the address bar on submission.  Example: www.test.com/ppa/testfirstname%20testlastname

???

Please help

hawkeye0386

you need to make sure the word String is all caps (like this STRING)

CyndiSmith

This was a great string of posts!  I've followed carefully (and with much anxiety) and have just updated my signup page, and it seems to be working great.

THANK YOU ALL FOR THE GREAT CORRECTIONS, and for the idea in the first place.  I'll let you know how it goes.

:D Cyndi

CyndiSmith

Hi!  Thanks again for this great code...  I'm quite the NEWBIE at this, but have found your instructions very easy to follow and extremely helpful.  Here's where I am now:

1.   The "Password Protect Advanced" program is set up and it's working great. E-mail retrieval of username & password works great, too.

2.   I've added new fields to the signup form, plus I've added an "access code" that requires people to have that special code before they can sign up.  Hopefully, all the required code updates have been made in the user.def file, signup_form.php, and signup.php. (see code below) 

3.   After following all the instructions for adding elements to the signup form,
I am still not getting data posted to the users file (so that I can see it in managers.php). 

**When I access the management page, all the database columns are blank except for user, password – I need to capture their first and last names.


         After signing in with
         "user, password, me@cyndismith.com, firstname, lastname, TVF2008(the access code),"
           here's what my users.php file looks like:

          <?php die(); ?>
          user1,password1,email1@user.com,http://example.com,,

          login,password,me@cyndismith.com,,


Here's my code:

user.def   (note, I don't have any user-specific URLs that I need to assign)

    Login,STRING,15
    Password,STRING,12
    Email,STRING,30
    First Name,STRING,20
    Last Name,STRING,20
    Redirect URL,STRING,10

signup_form.php  (note, I'm also using the "access code" function, and it works great!)

     <form method="post">
      <h3>User Registration and Authentication</h3>
      <font color="red"><?php echo $this->error; ?></font>
     <br />
      Login: ( Create User Name)<br /><input type='input' name='access_login' value='<?php echo $this->login ?>'/>
     <br />
     Password:<br />
      <input type="password" name="access_password" />
      <?php if (USE_EMAIL && !LOGIN_AS_EMAIL) echo "<br />Email:<br /><input type='input' name='access_email' value='$this->email' />"; ?>
       <br>
        <span class="style4">First Name:</span><br />
        <input type='input' name='FirName' value='<?php echo $this->FirName ?>' />
       <br />
        <span class="style4">Last Name:</span><br />
        <input type='input' name='LasName'value='<?php echo $this->LasName ?>' />
       <br />
     <br />
     <span class="style4">Secret Access Code:</span><br />
      <input type='input' name='access_code'value= >
      <p>
      <input type="submit" name="access_submit" value="Sign up" />
     </p>
    </form>


signup.php:

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'] : '');
    $this->FirName = $_POST['first_name'];
    $this->LasName = $_POST['last_name'];
   $this->code = $_REQUEST['access_code'];


function save_user() {
    // save user to database
    $fusers = fopen(USERS_LIST_FILE,'a+');
    if (!$fusers) {
      $this->error = "Cannot add user to database.";
      return false;
    }
    fputs($fusers, "\n" . $this->login. ',' . $this->pass . ',' . $this->email . ',' . $this->FirName . ',' . $this->LasName);
    fclose($fusers);


Thanks so much for helping me out on this.  The password access is wonderful - now I just have to capture the firstname & lastname in my database!

:) Cyndi