We help IT Professionals succeed at work.
Get Started

Multiple-page signup form doesn't fully write to SQL database

chris_alex
chris_alex asked
on
308 Views
Last Modified: 2013-12-14
I have a sign up form split across 3 web pages (signup1.php, signup2.php, and soon-to-be-built signup3.php). Signup1.php functions fine, and captures the data into my SQL database. With Signup2.php, I want it to add data into the same database row where email matches the email submitted in the first signup form. Basically, I want signup1.php to gather some data (and write it to SQL) and then signup2.php to capture a little more data (and write to same SQL row), and then do the same with a signup3 form (not built yet). However, I just can't get the signup2 to function properly.

Form from Signup1.php (works fine!):

<form class="form" action="include/process_register1.php" method="POST">
            <label>
               <span>First name</span>
               <input type="text" class="input_text" name="fname" id="fname" size="40"/>
            </label>
            <label>
               <span>Last name</span>
               <input type="text" class="input_text" name="lname" id="lname" size="40"/>
            </label>
             <label>
               <span>Email</span>
               <input type="text" class="input_text" name="email" id="email" size="40"/>
            </label>
            <label>
               <span>Zipcode</span>
               <input type="text" class="input_text" name="zipcode" id="email" maxlength="5"/>
            </label>
             <input type="submit" class="button" value="Next" />      
                          </form>


SQL for Signup1.php (works fine!):

function insertUser1($fname, $lname, $email, $zipcode) {

      $myQuery = "INSERT INTO musicmatch_users (fname, lname, email, zipcode) VALUES ('{$fname}', '{$lname}', '{$email}', '{$zipcode}')";
      
      //run the query
      $result = mysql_query($myQuery);
}




Form from Signup2.php (Doesn't work!):

<form class="form" action="include/process_register2.php" method="POST">
            <label>Main Instrument<a href="#"><img src="images/labelquestion.png" width="25" height="25"></a></label>
            <select name="instrument1" data-placeholder="" class="chzn-select">
              <option value="Electric Bass">Electric Bass </option>
              <option value="Acoustic Bass">Acoustic Bass </option>
              <option value="Drum">Drum Kit </option>
              <option value="Acoustic Guitar">Acoustic Guitar </option>
              <option value="Acoustic-Electric Guitar">Acoustic-Electric Guitar </option>
              <option value="Banjo">Banjo </option>
              <option value="Bassoon">Bassoon </option>
              <option value="Cellos">Cellos </option>
              <option value="Clarinet">Clarinet </option>
              <option value="Double Bass">Double Bass </option>
              <option value="Doumbek">Doumbek </option>
              <option value="Electric Guitar">Electric Guitar </option>
              <option value="Electronic Drums">Electronic Drums </option>
              <option value="Other Percussion">Other Percussion</option>
              <option value="Flute">Flute </option>
              <option value="French horn">French horn </option>
              <option value="Fretless Acoustic Bass">Fretless Acoustic Bass </option>
              <option value="Fretless Electric Bass">Fretless Electric Bass </option>
              <option value="Fretted Acoustic Bass">Fretted Acoustic Bass </option>
              <option value="Keyboard">Keyboard </option>
              <option value="Saxaphone">Saxaphone </option>
              <option value="Synthesizer">Synthesizer </option>
              <option value="Trombone">Trombone </option>
              <option value="Trumpet">Trumpet </option>
              <option value="Ukulele">Ukulele </option>
              <option value="Upright Bass">Upright Bass </option>
              <option value="Violin">Violin</option>
            </select>
   <label>Other Instrument<a href="#"><img src="images/labelquestion.png" width="25" height="25"></a> </label>
            <select name="instrument2" data-placeholder="" class="chzn-select">
              <option value="Electric Bass">Electric Bass </option>
              <option value="Acoustic Bass">Acoustic Bass </option>
              <option value="Drum">Drum Kit </option>
              <option value="Acoustic Guitar">Acoustic Guitar </option>
              <option value="Acoustic-Electric Guitar">Acoustic-Electric Guitar </option>
              <option value="Banjo">Banjo </option>
              <option value="Bassoon">Bassoon </option>
              <option value="Cellos">Cellos </option>
              <option value="Clarinet">Clarinet </option>
              <option value="Double Bass">Double Bass </option>
              <option value="Doumbek">Doumbek </option>
              <option value="Electric Guitar">Electric Guitar </option>
              <option value="Electronic Drums">Electronic Drums </option>
              <option value="Other Percussion">Other Percussion</option>
              <option value="Flute">Flute </option>
              <option value="French horn">French horn </option>
              <option value="Fretless Acoustic Bass">Fretless Acoustic Bass </option>
              <option value="Fretless Electric Bass">Fretless Electric Bass </option>
              <option value="Fretted Acoustic Bass">Fretted Acoustic Bass </option>
              <option value="Keyboard">Keyboard </option>
              <option value="Saxaphone">Saxaphone </option>
              <option value="Synthesizer">Synthesizer </option>
              <option value="Trombone">Trombone </option>
              <option value="Trumpet">Trumpet </option>
              <option value="Ukulele">Ukulele </option>
              <option value="Upright Bass">Upright Bass </option>
              <option value="Violin">Violin</option>
            </select>
              <label>Years of Experience<a href="#"><img src="images/labelquestion.png" width="25" height="25"></a></label>
            <select name="experience" data-placeholder="" class="chzn-select">
              <option value="0-1">Less than 1 year</option>
              <option value="1-3">1 to 3 years</option>
              <option value="3-5">3 to 5 years</option>
              <option value="5-10">5 to 10 years</option>
              <option value="10+">More than 10 years</option>
            </select>
            <label>First Favorite Artist<a href="#"><img src="images/labelquestion.png" width="25" height="25"></a></label>
            <?php include('include/forms/artist1.php'); ?>
            <label>Second Favorite Artist<a href="#"><img src="images/labelquestion.png" width="25" height="25"></a></label>
            <?php include('include/forms/artist2.php'); ?>
            <label>First Favorite Music Genre<a href="#"><img src="images/labelquestion.png" width="25" height="25"></a></label>
            <?php include('include/forms/genre1.php'); ?>
            <label>Second Favorite Music Genre<a href="#"><img src="images/labelquestion.png" width="25" height="25"></a></label>
            <?php include('include/forms/genre2.php'); ?>
           
            <br class="clear"/>
            <label> </label>
            <input type="submit" class="button" value="Next" />
            <script type="text/javascript"> $(".chzn-select").chosen(); $(".chzn-select-deselect").chosen({allow_single_deselect:true}); </script>
          </form>



SQL for Signup2.php (Doesn't work!):

function insertUser2($instrument1, $instrument2, $experience, $genre1, $genre2, $artist1, $artist2) {
      $myQuery = "INSERT INTO musicmatch_users (instrument1, instrument2, experience, genre1, genre2, artist1, artist2) VALUES ('{$instrument1}','{$instrument2}','{$experience}','{$genre1}','{$genre2}','{$artist1}','{$artist2}') WHERE email = '$email'";
      
      //run the query
      $result = mysql_query($myQuery);
}


Thank you for your time!

Best,

Chris
signup1.php
signup2.php
process-register1.php
process-register2.php
functions.php
session.php
process-session.php
Comment
Watch Question
Most Valuable Expert 2011
Author of the Year 2014
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE