0

I know how to do basic forms. What I want to do is to pass a set value as a hidden field 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 input name (in this case "group1", "group2" and so on) as a hidden field to another column in the same record, so that I can search the records on this hidden field.
I hope I've explained this OK.

<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:&nbsp;&nbsp;</font><font color="#CC0000">&nbsp;</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:&nbsp;&nbsp;</font><font color="#CC0000">&nbsp;</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:&nbsp;&nbsp;</font><font color="#CC0000">&nbsp;</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:&nbsp;&nbsp;</font><font color="#CC0000">&nbsp;</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:&nbsp;&nbsp;</font><font color="#CC0000">&nbsp;</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:&nbsp;&nbsp;</font><font color="#CC0000">&nbsp;</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>
2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by facarroll
0

You'd do exactly the same as you would for a normal field. Create the necessary fields using

<input type="hidden" value="groupX" name="groupX">

Then on adminlogin.php get the value of the hidden field:

$hidden_field = $_POST['groupX'];
//Then insert into the database along with the text field as necessary
0

You'd do exactly the same as you would for a normal field. Create the necessary fields using

<input type="hidden" value="groupX" name="groupX">

Then on adminlogin.php get the value of the hidden field:

$hidden_field = $_POST['groupX'];
//Then insert into the database along with the text field as necessary

You've saved me again! Thanks.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.