1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need some help with my php + mysql based form

Discussion in 'PHP & Perl' started by sfidirectory, Aug 8, 2011.

Tags:
  1. sfidirectory

    sfidirectory Senior Member

    Joined:
    Mar 29, 2010
    Messages:
    899
    Likes Received:
    483
    Occupation:
    Web developer/BTC enthusiast
    Location:
    php artisan make:migration
    Home Page:
    Have been working on this PHP based form for a little while now, basically it is a registration form and I am wanting to put the details from the form into a MySQL database (which I have already built). Trouble is no values seem to get inserted into the various rows in the database and am wondering if someone with more experience than myself can glance over it and let me know what is wrong? Thanks in advance!


    I will display the code for the form itself, the include for the database connection, and the MySQL code here (for obvious reasons I have changed the real user details for database.php include):


    The code for the form + php processing:



    Code:
    <?php
    require('includes/database.php'); //Include DB connection information
    ?>
    
    
    
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Untitled Document</title>
        </head>
    
        <body>
    
        <fieldset>
          <legend>Registration Form</legend>
          <form method="post" action="<?php echo ($_SERVER['PHP_SELF']) ?>" enctype="application/x-www-form-urlencoded">
        
        <fieldset class="userdetails">
        <legend>User Credentials</legend>
        <ul>
        <li><label for="user_email">Email Address:</label><input name="user_email" maxlength="50" id="user_email" size="40" type="text"></li>
        <li><label for="user_pass">Your Password:</label><input name="user_pass" maxlength="50" id="user_pass" size="30" type="password"></li>
        <li><label for="user_pass_confirm">Password Again:</label><input name="user_pass_confirm" maxlength="50" id="user_pass_confirm" size="30" type="password"><br></li>
        <li><label for="user_username">Your Username:</label><input name="user_username" maxlength="50" id="user_username" size="30" type="text"></li>
        </ul>
        </fieldset>
        
        <fieldset>
        <legend>Contact Details</legend>
        <ul>
        <li><label for="firstname">First Name:</label><input name="firstname" type="text" id="firstname" size="25" maxlength="200" /></li>
        <li><label for="lastname">Last Name:</label><input name="lastname" type="text" id="lastname" size="25" maxlength="200" /></li>
        <li><label for="gender">Gender:</label>
        <select name="gender" id="gender">
        <option value="male" selected="selected">Male</option>
        <option value="female">Female</option>
        <option value="unspecified">Unspecified</option>
        </select></li>
        <li><label for"dateOfBirth">Date of birth:</label>
          <select name="birthdate_day" id="birthday_date">
            <option selected="selected" value="">Day</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
            <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
            <option value="21">21</option>
            <option value="22">22</option>
            <option value="23">23</option>
            <option value="24">24</option>
            <option value="25">25</option>
            <option value="26">26</option>
            <option value="27">27</option>
            <option value="28">28</option>
            <option value="29">29</option>
            <option value="30">30</option>
            <option value="31">31</option>
    
        </select>
         <select name="birthdate_month" id="birthdate_month">
            <option selected="selected" value="">Month</option>
            <option value="1">January</option>
            <option value="2">February</option>
            <option value="3">March</option>
            <option value="4">April</option>
            <option value="5">May</option>
            <option value="6">June</option>
            <option value="7">July</option>
            <option value="8">August</option>
            <option value="9">September</option>
            <option value="10">October</option>
            <option value="11">November</option>
            <option value="12">December</option>
    
        </select>
        <input name="birthdate_year" maxlength="4" id="birthdate_year" size="4" type="text" value="Year">
        </li>
            
            <li>
              <label for="phoneNumber">Home Phone:</label>
              <input name="phoneNumber" maxlength="9" id="phoneNumber" size="9" type="text"><span class="informational">e.g: 033456789</span></li>
            
            <li><label for="mobileNumber">Mobile Number:</label>
              <input name="mobileNum" maxlength="11" id="mobileNum" size="11" type="text"><span class="informational">e.g: 0276123456</span></li>
            
            <li><label for="addressline1">Street Address:</label>
            <input name="addressLine1" maxlength="100" id="addressLine1" size="40" type="text"></li>
            <li><label for="addressline2">Suburb:</label>
            <input name="addressLine2" maxlength="100" id="addressLine2" size="40" type="text"></li>
            <li><label for="addressline3">City:</label>
            <input name="addressLine3" maxlength="100" id="addressLine2" size="40" type="text"></li>
            <li><label for="stateprovince">State/Province:</label>
            <select name="stateprovince" id="stateprovince">
            <option selected="selected" value=""></option>
            <option value="northland">Northland</option>
            <option value="auckland">Auckland</option>
            <option value="waikato">Waikato</option>
            <option value="bayofplenty">Bay of Plenty</option>
            <option value="eastcoast">East Coast</option>
            <option value="hawkesbay">Hawkes Bay</option>
            <option value="taranaki">Taranaki</option>
            <option value="kingcountry">King Country</option>
            <option value="wanganui">Wanganui</option>
            <option value="manawatu">Manawatu</option>
            <option value="wairarapa">Wairarapa</option>
            <option value="wellington">Wellington</option>
            <option value="nelsonbays">Nelson Bays</option>
            <option value="marlborough">Marlborough</option>
            <option value="buller">Buller</option>
            <option value="westland">Westland</option>
            <option value="northcanterbury">North Canterbury</option>
            <option value="canterbury">Canterbury</option>
            <option value="midcanterbury">Mid Canterbury</option>
            <option value="southcanterbury">South Canterbury</option>
            <option value="northotago">North Otago</option>
            <option value="otago">Otago</option>
            <option value="southland">Southland</option>
            <option value="chathamisl">Chatham Islands</option>
            </select></li>
            
            <li><label for="postcode">Post Code:</label>
            <input name="postcode" maxlength="4" id="postcode" size="4" type="text"><span class="informational"><a href="http://www.nzpost.co.nz/nzpost/control/business/postcode_finder#post_code_finder" target="_blank" title="Find your post code (only for New Zealand)">Find your post code</a></span></li>
            
            <li><label for="closest_town">Closest Town:</label>
            <select name="closest_town" id="closest_town">
            <option selected="selected" value="0">Please choose...</option>
            <option value="dargaville">Northland - Dargaville</option>
            <option value="kaikohe">Northland - Kaikohe</option>
            <option value="kaitaia">Northland - Kaitaia</option>
            <option value="kawakawa">Northland - Kawakawa</option>
            <option value="kerikeri">Northland - Kerikeri</option>
            <option value="maungaturoto">Northland - Maungaturoto</option>
            <option value="paihia">Northland - Paihia</option>
            <option value="whangarei">Northland - Whangarei</option>
            <option value="0"> </option>
            <option value="aucklandcity">Auckland - Auckland City</option>
            <option value="franklin">Auckland - Franklin</option>
            <option value="greatbarrierisland">Auckland - Great Barrier Island</option>
            <option value="helensville">Auckland - Helensville</option>
            <option value="hibiscuscoast">Auckland - Hibiscus Coast</option>
            <option value="manukaucity">Auckland - Manukau City</option>
            <option value="northshore">Auckland - North Shore</option>
            <option value="papakuracity">Auckland - Papakura City</option>
            <option value="waihekeisl">Auckland - Waiheke Island</option>
            <option value="waitakerecity">Auckland - Waitakere City</option>
            <option value="warkworth">Auckland - Warkworth</option>
            <option value="wellsford">Auckland - Wellsford</option>
            <option value="0"> </option>
            <option value="cambridge">Waikato - Cambridge</option>
            <option value="coromandel">Waikato - Coromandel</option>
            <option value="hamilton">Waikato - Hamilton</option>
            <option value="huntly">Waikato - Huntly</option>
            <option value="matamata">Waikato - Matamata</option>
            <option value="morrinsville">Waikato - Morrinsville</option>
            <option value="otorohanga">Waikato - Otorohanga</option>
            <option value="paeroa">Waikato - Paeroa</option>
            <option value="raglan">Waikato - Raglan</option>
            <option value="taumarunui">Waikato - Taumarunui</option>
            <option value="teawamutu">Waikato - Te Awamutu</option>
            <option value="tekuiti">Waikato - Te Kuiti</option>
            <option value="thames">Waikato - Thames</option>
            <option value="tokoroa_putaruru">Waikato - Tokoroa/Putaruru</option>
            <option value="waihi">Waikato - Waihi</option>
            <option value="waihi_beach">Waikato - Waihi Beach</option>
            <option value="whangamata">Waikato - Whangamata</option>
            <option value="0"> </option>
            <option value="katikati">Bay of Plenty - Katikati</option>
            <option value="mt_maunganui">Bay of Plenty - Mt. Maunganui</option>
            <option value="opotiki">Bay of Plenty - Opotiki</option>
            <option value="rotorua">Bay of Plenty - Rotorua</option>
            <option value="taupo">Bay of Plenty - Taupo</option>
            <option value="tauranga">Bay of Plenty - Tauranga</option>
            <option value="te_puke">Bay of Plenty - Te Puke</option>
            <option value="turangi">Bay of Plenty - Turangi</option>
            <option value="whakatane">Bay of Plenty - Whakatane</option>
            <option value="0"> </option>
            <option value="gisborne">Gisborne - Gisborne</option>
            <option value="ruatoria">Gisborne - Ruatoria</option>
            <option value="0"> </option>
            <option value="dannevirke">Hawkes Bay - Dannevirke</option>
            <option value="hastings">Hawkes Bay - Hastings</option>
            <option value="napier">Hawkes Bay - Napier</option>
            <option value="waipukurau">Hawkes Bay - Waipukurau</option>
            <option value="wairoa">Hawkes Bay - Wairoa</option>
            <option value="0"> </option>
            <option value="hawera">Taranaki - Hawera</option>
            <option value="mokau">Taranaki - Mokau</option>
            <option value="new_plymouth">Taranaki - New Plymouth</option>
            <option value="opunake">Taranaki - Opunake</option>
            <option value="stratford">Taranaki - Stratford</option>
            <option value="0"> </option>
            <option value="ohakune">Wanganui - Ohakune</option>
            <option value="taihape">Wanganui - Taihape</option>
            <option value="waiouru">Wanganui - Waiouru</option>
            <option value="wanganui">Wanganui - Wanganui</option>
            <option value="0"> </option>
            <option value="bulls">Manawatu - Bulls</option>
            <option value="fielding">Manawatu - Feilding</option>
            <option value="levin">Manawatu - Levin</option>
            <option value="manawatu">Manawatu - Manawatu</option>
            <option value="marton">Manawatu - Marton</option>
            <option value="palmerston_north">Manawatu - Palmerston North</option>
            <option value="0"> </option>
            <option value="carterton">Wairarapa - Carterton</option>
            <option value="featherston">Wairarapa - Featherston</option>
            <option value="greytown">Wairarapa - Greytown</option>
            <option value="martinborough">Wairarapa - Martinborough</option>
            <option value="masterton">Wairarapa - Masterton</option>
            <option value="paihiatua">Wairarapa - Pahiatua</option>
            <option value="woodville">Wairarapa - Woodville</option>
            <option value="0"> </option>
            <option value="kapiti">Wellington - Kapiti</option>
            <option value="lower_hutt">Wellington - Lower Hutt City</option>
            <option value="porirua">Wellington - Porirua</option>
            <option value="upper_hutt">Wellington - Upper Hutt City</option>
            <option value="wellington">Wellington - Wellington City</option>
            <option value="0"> </option>
            <option value="golden_bay">Nelson Bays - Golden Bay</option>
            <option value="motueka">Nelson Bays - Motueka</option>
            <option value="murchison">Nelson Bays - Murchison</option>
            <option value="nelson">Nelson Bays - Nelson</option>
            <option value="picton">Nelson Bays - Picton</option>
            <option value="0"> </option>
            <option value="blenheim">Marlborough - Blenheim</option>
            <option value="marlborough_sounds">Marlborough - Marlborough Sounds</option>
            <option value="0"> </option>
            <option value="greymouth">West Coast - Greymouth</option>
            <option value="hokitika">West Coast - Hokitika</option>
            <option value="westport">West Coast - Westport</option>
            <option value="0"> </option>
            <option value="akaroa">Canterbury - Akaroa</option>
            <option value="amberley">Canterbury - Amberley</option>
            <option value="ashburton">Canterbury - Ashburton</option>
            <option value="cheviot">Canterbury - Cheviot</option>
            <option value="christchurch">Canterbury - Christchurch City</option>
            <option value="darfield">Canterbury - Darfield</option>
            <option value="fairlie">Canterbury - Fairlie</option>
            <option value="geraldine">Canterbury - Geraldine</option>
            <option value="hamnersprings">Canterbury - Hanmer Springs</option>
            <option value="kaiapoi">Canterbury - Kaiapoi</option>
            <option value="kaikoura">Canterbury - Kaikoura</option>
            <option value="mtcook">Canterbury - Mt Cook</option>
            <option value="rangiora">Canterbury - Rangiora</option>
            <option value="0"> </option>
            <option value="timaru_oamaru_kurow">Timaru - Oamaru - Kurow</option>
            <option value="timaru_oamaru_oamaru">Timaru - Oamaru - Oamaru</option>
            <option value="timaru_oamaru_timaru">Timaru - Oamaru - Timaru</option>
            <option value="timaru_oamaru_twizel">Timaru - Oamaru - Twizel</option>
            <option value="timaru_oamaru_waimate">Timaru - Oamaru - Waimate</option>
            <option value="0"> </option>
            <option value="alexandra">Otago - Alexandra</option>
            <option value="balclutha">Otago - Balclutha</option>
            <option value="cromwell">Otago - Cromwell</option>
            <option value="dunedin">Otago - Dunedin</option>
            <option value="lawrence">Otago - Lawrence</option>
            <option value="milton">Otago - Milton</option>
            <option value="palmerston">Otago - Palmerston</option>
            <option value="queenstown">Otago - Queenstown</option>
            <option value="ranfurly">Otago - Ranfurly</option>
            <option value="roxburgh">Otago - Roxburgh</option>
            <option value="wanaka">Otago - Wanaka</option>
            <option value="0"> </option>
            <option value="bluff">Southland - Bluff</option>
            <option value="edendale">Southland - Edendale</option>
            <option value="gore">Southland - Gore</option>
            <option value="invercargill">Southland - Invercargill</option>
            <option value="lumsden">Southland - Lumsden</option>
            <option value="otautau">Southland - Otautau</option>
            <option value="riverton">Southland - Riverton</option>
            <option value="stewart_island">Southland - Stewart Island</option>
            <option value="te_anau">Southland - Te Anau</option>
            <option value="tokanui">Southland - Tokanui</option>
            <option value="winton">Southland - Winton</option>
            <option value="0"> </option>
            <option value="chathamisl">Chatham Islands</option>
            </select></li>
        
            <li><label for="u18conf">I am over 18...</label> <input id="u18conf" name="u18conf" type="checkbox"></li></ul>
        
            <input name="SubmitButton" class="joinitrade" value="Join iTrade"  id="SubmitButton" type="submit">
            </form>
            </fieldset>
            
    <?php
    
    if (isset($_POST['SubmitButton'])) {    
    
        //Execute the following if form is submitted
        $user_email = mysql_real_escape_string($_POST['user_email']); //Post user email
        $user_pass = mysql_real_escape_string(sha1(md5($_POST['user_pass']))); //Post password     from form and encrypt
        $user_pass_confirm = mysql_real_escape_string(sha1(md5($_POST['user_pass_confirm'])));         //Post password confirmation from form and encrypt
        $user_username = mysql_real_escape_string($_POST['user_username']);
        $firstname = mysql_real_escape_string($_POST['firstname']);
        $lastname = mysql_real_escape_string($_POST['lastname']);
        $gender = mysql_real_escape_string($_POST['gender']);
        $birthday_date = mysql_real_escape_string($_POST['birthday_date']);
        $birthdate_month = mysql_real_escape_string($_POST['birthdate_month']);
        $birthdate_year = mysql_real_escape_string($_POST['birthdate_year']);
        $phoneNumber = mysql_real_escape_string($_POST['phoneNumber']);
        $mobileNumber = mysql_real_escape_string($_POST['mobileNumber']);
        $addressline1 = mysql_real_escape_string($_POST['addressline1']);
        $addressline2 = mysql_real_escape_string($_POST['addressline2']);
        $addressline3 = mysql_real_escape_string($_POST['addressline3']);
        $stateprovince = mysql_real_escape_string($_POST['stateprovince']);
        $postcode = mysql_real_escape_string($_POST['postcode']);
        $closest_town = mysql_real_escape_string($_POST['closest_town']);
        
        if(empty($user_email) || empty($user_pass) || empty($user_pass_confirm) || empty($firstname) || empty($firstname) || empty($lastname) || empty($user_username) || empty($gender) || empty($birthday_date) || empty($birthdate_month) || empty($birthdate_year) || empty($phoneNumber) || empty($addressline1) || empty($addressline2) || empty($addressline3) || empty($stateprovince) || empty($postcode) || empty($closest_town)) { //Check for empty fields
            die("<b>Error:</b> All fields are required in order to register an account.");
        }
    
        if(strlen($user_username) > 25) { //Check if username exceeds limit of 25 characters
            die("<b>Error:</b> Your username may not exceed 25 characters.");
        }
    
        if(strlen($user_pass) < 8 || strlen($user_pass) > 15) { //Check if username exceeds limit of 25 characters
            die("<b>Error:</b> Your password may not exceed 15 characters, or not be less that 8 characters.");
        }
    
        if (!preg_match("/[a-zA-Z0-9_-]/", $user_username)) { //Check for unallowed characters in username
            die("<b>Error:</b> Your username may only contain letters (a-z), numbers (0-9), underscores (_) and hypens (-).");
        }
    
        if ($user_pass != $user_pass_confirm) { //Check if passwords match
            die("<b>Error:</b> Your passwords do not match.");
        }
    
        $check = mysql_query("SELECT * FROM loginsystem2 WHERE user_username = '$user_username'") or die(mysql_error());
        $check2 = mysql_num_rows($check);
        if ($check2 != 0) { //Check if account already exists witih this username
            die("<b>Error:</b> There is already an existing account with the username <b>$username</b>.");
        }
        mysql_query("INSERT INTO `loginsystem2` (`user_email`, `user_pass`, `user_pass_confirm`, `user_username`, `firstname`, `lastname`, `gender`, `birthday_date`, `birthdate_month`, `birthdate_year`, `phoneNumber`, `mobileNumber`, `addressline1`, `addressline2`, `addressline3`, `stateprovince`, `postcode`, `closest_town`)VALUES ('$user_email', '$user_pass', '$user_pass_confirm', '$user_username', '$firstname', '$lastname', '$gender', '$birthday_date', '$birthdate_month', '$birthdate_year', '$phoneNumber', '$mobileNumber', '$addressline1', '$addressline2', '$addressline3', '$stateprovince', '$postcode', '$closest_town')") OR die(mysql_error());
        
    echo "Account created! You may now <a href=\"login.php\">login</a>.";
    }
        ?>
    </body>
    </html>
    The code for the database.php file, which is required to connect to the database:

    Code:
    <?php
    mysql_connect("localhost", "username", "password") or die(mysql_error()); 
    mysql_select_db("loginsystem2") or die(mysql_error());
    ?>
    
    The code for the database "loginsystem2". in .sql:

    Code:
    DROP TABLE IF EXISTS users;
    
    CREATE TABLE users(
      
    user_id int(11) NOT NULL AUTO_INCREMENT,
      
    user_email varchar(50) NOT NULL,
      
    user_pass varchar(25) NOT NULL,
      
    user_pass_confirm varchar(11) NOT NULL,
      
    firstname varchar(25) NOT NULL,
      
    lastname varchar(25) NOT NULL,
      
    gender varchar(11) NOT NULL,
      
    birthday_date int(2) NOT NULL,
      
    birthday_month int(2) NOT NULL,
      
    birthday_year int(4) NOT NULL,
      
    phoneNumber int(9) NOT NULL,
      
    mobileNumber int(11) NOT NULL,
      
    addressline1 varchar(100) NOT NULL,
      
    addressline2 varchar(100) NOT NULL,
      
    addressline3 varchar(100) NOT NULL,
      
    stateprovince varchar(40) NOT NULL,
      
    postcode tinyint(4) NOT NULL,
      
    closest_town varchar(40) NOT NULL,
      
    user_level tinyint(4) DEFAULT '0',
      
    user_hash varchar(32) DEFAULT NULL,
      
    user_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
      
    PRIMARY KEY (user_id)
    );
     
  2. infTee

    infTee Junior Member

    Joined:
    Mar 2, 2010
    Messages:
    101
    Likes Received:
    97
    Location:
    Ireland
    No mySql errors at all? Try doing a var dump of $_POST to see what's being sent when you submit.
    Code:
    <?php var_dump($_POST);?>
    Put it at the top or anywhere before the "if(isset($_POST['SubmitButton']))"
     
  3. seeplusplus

    seeplusplus Power Member

    Joined:
    Aug 18, 2008
    Messages:
    511
    Likes Received:
    163
    Lots of IF statements, but I would put the INSERT statement into an ELSE.

    Also you need to cleanse the data before it is inserted into your database. Use a separate .php file in which all the values can be passed as POST, cleaned/validated, and then inserted into the DB.

    HTH :)
     
  4. gimme4free

    gimme4free Executive VIP Jr. VIP Premium Member

    Joined:
    Oct 22, 2008
    Messages:
    1,879
    Likes Received:
    1,932
    Your SQL creates a table named 'users'. Your query in the PHP code tries to insert the row to a table named 'loginsystem2'.
     
  5. Reefer

    Reefer Junior Member

    Joined:
    Jan 3, 2010
    Messages:
    194
    Likes Received:
    71
    Occupation:
    BALLIN
    Location:
    no lie
    winner winner.

    Code:
    
    $check = mysql_query("SELECT * FROM users WHERE user_username = '$user_username'") or die(mysql_error());
        $check2 = mysql_num_rows($check);
        if ($check2 != 0) { //Check if account already exists witih this username
            die("<b>Error:</b> There is already an existing account with the username <b>$username</b>.");
        }
        mysql_query("INSERT INTO `users` (`user_email`, `user_pass`, `user_pass_confirm`, `user_username`, `firstname`, `lastname`, `gender`, `birthday_date`, `birthdate_month`, `birthdate_year`, `phoneNumber`, `mobileNumber`, `addressline1`, `addressline2`, `addressline3`, `stateprovince`, `postcode`, `closest_town`)VALUES ('$user_email', '$user_pass', '$user_pass_confirm', '$user_username', '$firstname', '$lastname', '$gender', '$birthday_date', '$birthdate_month', '$birthdate_year', '$phoneNumber', '$mobileNumber', '$addressline1', '$addressline2', '$addressline3', '$stateprovince', '$postcode', '$closest_town')") OR die(mysql_error());
    
    
     
  6. kaidoristm

    kaidoristm Power Member

    Joined:
    Feb 13, 2009
    Messages:
    561
    Likes Received:
    726
    Occupation:
    Freelancer
    Location:
    Estonia
    Home Page:
    Try to insert it into table "users" not into database "loginsystem2"

    Check that line
    PHP:
    mysql_query("INSERT INTO `loginsystem2` (`user_email`, `user_pass`, `user_pass_confirm`, `user_username`, `firstname`, `lastname`, `gender`, `birthday_date`, `birthdate_month`, `birthdate_year`, `phoneNumber`, `mobileNumber`, `addressline1`, `addressline2`, `addressline3`, `stateprovince`, `postcode`, `closest_town`)VALUES ('$user_email', '$user_pass', '$user_pass_confirm', '$user_username', '$firstname', '$lastname', '$gender', '$birthday_date', '$birthdate_month', '$birthdate_year', '$phoneNumber', '$mobileNumber', '$addressline1', '$addressline2', '$addressline3', '$stateprovince', '$postcode', '$closest_town')") OR die(mysql_error());
    You should change "loginsystem2" (which is your database name) to "users" (which is your table name)
     
    Last edited: Aug 11, 2011