Dumping info from sendmail form to database, and create login


#1

I have a php form (below) that sends mail confirmation to the user/admin, when a registration is complete. I want to have this form dump into a database.

From that database, allow people to log into the website (protected page), and be able to update his/her respective information.

I have the form below, which works great, but

  1. How do I make a connection to a database?

  2. How do I allow a registered/confirmed user to log back in and make changes as necessary?

I’m lost…

[php]<?php

This block must be placed at the very top of page.

--------------------------------------------------

require_once( dirname(FILE).’/form.lib.php’ );
phpfmg_display_form();

--------------------------------------------------

function phpfmg_form( $sErr = false ){
$style=" class=‘form_text’ ";

?>

Please check the required fields

  1. Basic Information
  2. First Name *
    " class='text_box'>
  3. Last Name *
    " class='text_box'>
  4. Phone Number  
    " class='text_box'>
  5. Create a Password *
    " class='text_box'>
  6. Gender *
    <?php phpfmg_dropdown( 'field_5', "Male|Female|Prefer Not to Answer" );?>
  7. Email Address  
    " class='text_box'>

  8. Additional Information
  9. Street Address *
    " class='text_box'>
  10. City *
    " class='text_box'>
  11. State *
    <?php phpfmg_dropdown( 'field_10', "Arizona|Alabama|Alaska||Arkansas|California|Colorado|Connecticut|Delaware|Florida|Georgia|Hawaii|Idaho|Illinois|Indiana|Iowa|Kansas|Kentucky|Louisiana|Maine|Maryland|Massachusetts|Michigan|Minnesota|Mississippi|Missouri|Montana|Nebraska|Nevada|New Hampshire|New Jersey|New Mexico|New York|North Carolina|North Dakota|Ohio|Oklahoma|Oregon|Pennsylvania|Rhode Island|South Carolina|South Dakota|Tennessee|Texas|Utah|Vermont|Virginia|Washington|West Virginia|Wisconsin|Wyoming" );?>
  12. Zip Code *
    " class='text_box'>
  13. Date of Birth *
    <?php $field_12 = array( 'month' => "-MM- =,|01|02|03|04|05|06|07|08|09|10|11|12", 'day' => "-DD- =,|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31", 'startYear' => date("Y")+0, 'endYear' => date("Y")-62, 'yearPrompt' => '-YYYY-', 'format' => "mm/dd/yyyy", 'separator' => "/", 'field_name' => "field_12", ); phpfmg_date_dropdown( $field_12 ); ?>
    <div id='field_12_tip' class='instruction'></div>
    </div>
    

  14. Free Agents - Select Which Leagues you are Interested in Playing for...
  15. Please select a league *
    <?php phpfmg_checkboxes( 'field_14', "Tuesday Co-Ed|Friday Co-Ed|Saturday Soccer League|Sunday Soccer League|Flag Football|Kickball|Women's Soccer" );?>

  16. Please send us your comments!  
    <?php phpfmg_hsc("field_16"); ?>
    <div id='field_16_tip' class='instruction'></div>
    </div>
    
  17. Security Code: *
    <?php phpfmg_show_captcha(); ?>
  18.         <li>
            <div class='col_label'>&nbsp;</div>
            <div class='form_submit_block col_field'>
    
                <input type='submit' value='Submit' class='form_button'>
                <span id='phpfmg_processing' style='display:none;'>
                    <img id='phpfmg_processing_gif' src='<?php echo PHPFMG_ADMIN_URL . '?mod=image&amp;func=processing' ;?>' border=0 alt='Processing...'> <label id='phpfmg_processing_dots'></label>
                </span>
            </div>
            </li>
    
    <?php phpfmg_javascript($sErr); } # end of form function phpfmg_form_css(){ ?>[/php]

#2

Well, not sure on your code as you have functions we can not see in your hidden page.

But, in general, you basically create a second PHP page that this page would post to in the “ACTION=” area of the form. Then, in that page, you would open your database connection. Connect to your table. Read all of the posted data into some format that you would want it stored in. It appears basically to be just the way it is now. So, you would have to just get the posted data in this manner: $field1=$_POST[‘field1’]; … Then, with all the data ready, you would create a query something like this: $query=“INSERT INTO users (name, field1 field2, etc) ($name, $field1, $field2, etc)”; Next, you would execute this query to insert the data into the database. Then, close the database connection…

Of course, this would be after error checking and validation. For example, first you would have to make sure that there were not already info for that name or user name. Lots cover for this project. You should review some of the tutorials on our site or google for “PHP sample login script”. We do not mind helping here, but, sounds like you need to do some reading first. Hope all this helps…