scottiesr1 Posted June 23, 2011 Share Posted June 23, 2011 I am attempting to send a form with the input as submit. I want the input name to be a variable so I can distinguish where this input is sent from and act accordingly in when processing the input. I can't seem to get this variable name to change and I only get the actual variable name to be sent instead of the value of the variable. The variable I am trying to send is mem_or_ven. "$mem_or_ven", the name is literal: $mem_or_ven. If I leave out the quotes, no luck, either. I would appreciate any help!! Here is my code: <?php if (isset($_POST["member_x"])) { $mem_or_ven = "member"; } ?> <form id="loginForm" name="loginForm" method="post" action="register-exec.php"> <table width="300" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <th>First Name </th> <td><input name="fname" type="text" class="textfield" id="fname" /></td> </tr> <tr> <th>Last Name </th> <td><input name="lname" type="text" class="textfield" id="lname" /></td> </tr> <td> </td> <td><input name="$mem_or_ven" type="submit" name="Submit" value="Register" /></td> </tr> </table> </form> THX! Link to comment https://forums.phpfreaks.com/topic/240200-using-input-with-a-variable-name-tag/ Share on other sites More sharing options...
QuickOldCar Posted June 23, 2011 Share Posted June 23, 2011 Your variable is in html, so you must echo the php like so. <td><input name="<?php echo $mem_or_ven;?>" type="submit" name="Submit" value="Register" /></td> Link to comment https://forums.phpfreaks.com/topic/240200-using-input-with-a-variable-name-tag/#findComment-1233807 Share on other sites More sharing options...
scottiesr1 Posted June 24, 2011 Author Share Posted June 24, 2011 Thanks a bunch!! Now it makes sense. I would have never thought of embedding the php actual value!! Link to comment https://forums.phpfreaks.com/topic/240200-using-input-with-a-variable-name-tag/#findComment-1234129 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.