Jump to content

Problem with a form.


facarroll

Recommended Posts

I don't know whether this is a PHP or an HTML question.

I want to be able to post a preset value to accompany an input text value, and have both values entered in the database record.

You can see in the code below that the form asks for names for up to six student groups, such as "Year7", "Year8", "Year9" and so on. What I want my form to do is to post the accompanying preset input name (in this case "group1", "group2", "group3", and so on) to a second column in the same record, so that I can search the records on this preset field.

How can I do this?

 <table width="750" align="center" cellpadding="4">
                    <form action="admin_login.php" method="post" enctype="multipart/form-data">
                      <tr>
                        <td><div align="right"><font size="-1">Student Group 1:  </font><font color="#CC0000"> </font></div></td>
                        <td><input name="group1" type="text" value="<?php echo "$group1"; ?>" /></td>
                      </tr>
                      <tr>
                        <td><div align="right"><font size="-1">Student Group 2:  </font><font color="#CC0000"> </font></div></td>
                        <td><input name="group2" type="text" value="<?php echo "$group2"; ?>" /></td>
                      </tr>
                      <tr>
                        <td><div align="right"><font size="-1">Student Group 3:  </font><font color="#CC0000"> </font></div></td>
                        <td><input name="group3" type="text" value="<?php echo "$group3"; ?>" /></td>
                      </tr>
                      <tr>
                        <td><div align="right"><font size="-1">Student Group 4:  </font><font color="#CC0000"> </font></div></td>
                        <td><input name="group4" type="text" value="<?php echo "$group4"; ?>" /></td>
                      </tr>                      
                      <tr>
                        <td><div align="right"><font size="-1">Student Group 5:  </font><font color="#CC0000"> </font></div></td>                        
                        <td><input name="group5" type="text" value="<?php echo "$group5"; ?>" /></td>                        
                      </tr>                      
                      <tr>
                        <td><div align="right"><font size="-1">Student Group 6:  </font><font color="#CC0000"> </font></div></td>                        
                        <td><input name="group6" type="text" value="<?php echo "$group6"; ?>" /></td>                        
                      </tr> 
<tr>
                        <td><div align="right"></div></td>
                        <td><input type="submit" name="Submit" value="Submit Form" /></td>
                      </tr>
                    </form>

Link to comment
https://forums.phpfreaks.com/topic/216132-problem-with-a-form/
Share on other sites

I will store a user supplied name for the field "group1". Obviously, the text input will be whatever the user decides, but elsewhere I need to be able to search the database for this record based on the data supplied by the user. I can do this if I have an accompanying field with one of the six preset names. I cannot search on the user supplied data because it could be anything, meaningful only to the user. Ask me further if this does not make sense.

Link to comment
https://forums.phpfreaks.com/topic/216132-problem-with-a-form/#findComment-1123248
Share on other sites

I'll try to explain further. When the user enters text into the form, it is meaningful only to that user. It is always a name, but could be "Bill", or "grade3", or "new students". There are six fields the user can use. I want to have a preset name that goes into the record, being group1 to group6. Then I can search the database for the preset field names and derive the user names accordingly.

Link to comment
https://forums.phpfreaks.com/topic/216132-problem-with-a-form/#findComment-1123250
Share on other sites

It might make more sense if we knew the big picture, such as what other information is being stored, and the database structure. Right now it seems that if you were to just give the field the data is stored in a descriptive name, it would be unnecessary to have additional fields.

Link to comment
https://forums.phpfreaks.com/topic/216132-problem-with-a-form/#findComment-1123253
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.