adding form data to mysql in different columns

  • gwolff2005
  • Newbie
  • Newbie
  • gwolff2005
  • Posts: 13

Post 3+ Months Ago

Hi guys,
I need urgently your help.
I am developing a psychological test. The users are logging onto a site from there is a link to the test page.
The mysql database contains the following columns:

id int(11) No
username var(20) No
password varchar(20) No
firstname varchar(30) No
resultspo char(2) No
resultsm char(2) No
resultspassion char(3) No

The user fills out the form and then presses the button. NOW How can I do the following. As you can see below in the code, the answers of the questions need to be saved to different rows of the current user. In this case the answer of question numer one needs to be ADDED to the already existing value of row resultspo in mysql, question two needs to be added to the value of resultsmo in mysql, as well as number three needs to be added then to resultsmo.
After adding all the values, the page needs to go to the next page which is call passiontest2. Please help. How can I do that???
Thanks!

Code: [ Select ]
<?php
session_start();
?>
<!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=iso-8859-1" />
<title>Your Passion Test</title>
<style type="text/css">
<!--
.style1 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 11px;
    font-weight: bold;
    color: #000033;
}
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style4 {
    font-size: 20px;
    color: #996600;
}
-->
</style>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<table width="699" border="0" align="center" cellspacing="5" class="style1">
    <tr>
     <td colspan="3"><div align="center"><span class="style4">Your Passion Test</span></div></td>
    </tr>
    <tr>
     <td width="24">&nbsp;</td>
     <td width="429">&nbsp;</td>
     <td width="220"><div align="right">Saturday, 03/28/09</div></td>
    </tr>
    <tr>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td><div align="right"><?php echo $_SESSION['MM_firstname']; ?></div></td>
    </tr>
    <tr>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td><div align="right"></div></td>
    </tr>
    <tr>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td>1</td>
     <td><strong>I like talking to people. </strong><br />
         </b></td>
     <td><div align="left">
         <input name="po1" type="radio" value="0" />
        0
        <input name="repo1" type="radio" value="1" />
        1
        <input name="po1" type="radio" value="2" />
        2
        <input name="po1" type="radio" value="3" />
        3
        <input name="po1" type="radio" value="4" />
        4
        <input name="po1" type="radio" value="5" />
        5</div></td>
    </tr>
    <tr>
     <td>2</td>
     <td>It is important for me what other people think. </td>
     <td><p>
         <label></label>
         <label></label>
         <input name="mo2" type="radio" value="0" />
        0
        <input name="remo2" type="radio" value="1" />
        1
        <input name="mo2" type="radio" value="2" />
        2
        <input name="mo2" type="radio" value="3" />
        3
        <input name="mo2" type="radio" value="4" />
        4
        <input name="mo2" type="radio" value="5" />
        5<br />
        <br />
     </p></td>
    </tr>
    <tr>
     <td>3</td>
     <td class="style1">My level of excitement is high right now. </td>
     <td><p>
         <label></label>
         <input name="mo3" type="radio" value="0" />
        0
        <input name="mo3" type="radio" value="1" />
        1
        <input name="mo3" type="radio" value="2" />
        2
        <input name="mo3" type="radio" value="3" />
        3
        <input name="mo3" type="radio" value="4" />
        4
        <input name="mo3" type="radio" value="5" />
        5<br />
     </p></td>
    </tr>
    <tr>
     <td>4</td>
     <td>I like solving mathematical tasks. </td>
     <td><input name="po4" type="radio" value="0" />
        0
        <input name="po4" type="radio" value="1" />
        1
        <input name="po4" type="radio" value="2" />
        2
        <input name="po4" type="radio" value="3" />
        3
        <input name="po4" type="radio" value="4" />
        4
        <input name="po4" type="radio" value="5" />
        5</td>
    </tr>
</table>
<p align="center">
    <input name="Submit" type="submit" class="style1" value="go on" />
</p>
</form>
</body>
</html>
  1. <?php
  2. session_start();
  3. ?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  8. <title>Your Passion Test</title>
  9. <style type="text/css">
  10. <!--
  11. .style1 {
  12.     font-family: Verdana, Arial, Helvetica, sans-serif;
  13.     font-size: 11px;
  14.     font-weight: bold;
  15.     color: #000033;
  16. }
  17. .style3 {font-family: Verdana, Arial, Helvetica, sans-serif}
  18. .style4 {
  19.     font-size: 20px;
  20.     color: #996600;
  21. }
  22. -->
  23. </style>
  24. </head>
  25. <body>
  26. <form id="form1" name="form1" method="post" action="">
  27. <table width="699" border="0" align="center" cellspacing="5" class="style1">
  28.     <tr>
  29.      <td colspan="3"><div align="center"><span class="style4">Your Passion Test</span></div></td>
  30.     </tr>
  31.     <tr>
  32.      <td width="24">&nbsp;</td>
  33.      <td width="429">&nbsp;</td>
  34.      <td width="220"><div align="right">Saturday, 03/28/09</div></td>
  35.     </tr>
  36.     <tr>
  37.      <td>&nbsp;</td>
  38.      <td>&nbsp;</td>
  39.      <td><div align="right"><?php echo $_SESSION['MM_firstname']; ?></div></td>
  40.     </tr>
  41.     <tr>
  42.      <td>&nbsp;</td>
  43.      <td>&nbsp;</td>
  44.      <td><div align="right"></div></td>
  45.     </tr>
  46.     <tr>
  47.      <td>&nbsp;</td>
  48.      <td>&nbsp;</td>
  49.      <td>&nbsp;</td>
  50.     </tr>
  51.     <tr>
  52.      <td>1</td>
  53.      <td><strong>I like talking to people. </strong><br />
  54.          </b></td>
  55.      <td><div align="left">
  56.          <input name="po1" type="radio" value="0" />
  57.         0
  58.         <input name="repo1" type="radio" value="1" />
  59.         1
  60.         <input name="po1" type="radio" value="2" />
  61.         2
  62.         <input name="po1" type="radio" value="3" />
  63.         3
  64.         <input name="po1" type="radio" value="4" />
  65.         4
  66.         <input name="po1" type="radio" value="5" />
  67.         5</div></td>
  68.     </tr>
  69.     <tr>
  70.      <td>2</td>
  71.      <td>It is important for me what other people think. </td>
  72.      <td><p>
  73.          <label></label>
  74.          <label></label>
  75.          <input name="mo2" type="radio" value="0" />
  76.         0
  77.         <input name="remo2" type="radio" value="1" />
  78.         1
  79.         <input name="mo2" type="radio" value="2" />
  80.         2
  81.         <input name="mo2" type="radio" value="3" />
  82.         3
  83.         <input name="mo2" type="radio" value="4" />
  84.         4
  85.         <input name="mo2" type="radio" value="5" />
  86.         5<br />
  87.         <br />
  88.      </p></td>
  89.     </tr>
  90.     <tr>
  91.      <td>3</td>
  92.      <td class="style1">My level of excitement is high right now. </td>
  93.      <td><p>
  94.          <label></label>
  95.          <input name="mo3" type="radio" value="0" />
  96.         0
  97.         <input name="mo3" type="radio" value="1" />
  98.         1
  99.         <input name="mo3" type="radio" value="2" />
  100.         2
  101.         <input name="mo3" type="radio" value="3" />
  102.         3
  103.         <input name="mo3" type="radio" value="4" />
  104.         4
  105.         <input name="mo3" type="radio" value="5" />
  106.         5<br />
  107.      </p></td>
  108.     </tr>
  109.     <tr>
  110.      <td>4</td>
  111.      <td>I like solving mathematical tasks. </td>
  112.      <td><input name="po4" type="radio" value="0" />
  113.         0
  114.         <input name="po4" type="radio" value="1" />
  115.         1
  116.         <input name="po4" type="radio" value="2" />
  117.         2
  118.         <input name="po4" type="radio" value="3" />
  119.         3
  120.         <input name="po4" type="radio" value="4" />
  121.         4
  122.         <input name="po4" type="radio" value="5" />
  123.         5</td>
  124.     </tr>
  125. </table>
  126. <p align="center">
  127.     <input name="Submit" type="submit" class="style1" value="go on" />
  128. </p>
  129. </form>
  130. </body>
  131. </html>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • awatson
  • Novice
  • Novice
  • awatson
  • Posts: 20

Post 3+ Months Ago

You should probably read up on some basic web development - but basically you need to change the action parameter of your form to point to a php file.

The php file would need to do the following:
* check that the user is properly logged in (which should then give you the id value for that user)
* do an update query to update that user's record in the database, using the values from the form in the appropriate places
* display the next page of the form.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 61 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.