makeshift_theory Posted December 11, 2006 Share Posted December 11, 2006 Hello guys and gals,I am having a wierd problem I have never encountered before. My forms are being dynamically created from a class and the turn out of that form is this:[code]<center><form action="/admin/select_server.php" method="POST"><input type="submit" name="viewnew" value="View Pending" class="button"><br><br><input type="submit" name="Library" value="Library Server" class="button"><br><br><input type="submit" name="Leads Library" value="Leads Library Server" class="button"><br><br><input type="submit" name="addnew" value="Add New Server" class="button"></form></center>[/code]...as you can the name field is Leads Library with no spaces however when I run this code:[code] if($_SERVER['REQUEST_METHOD']=='POST') { extract($_POST); foreach($_POST as $k => $P) echo $k; }[/code]... the key turns into Leads_Library..why is that? Link to comment https://forums.phpfreaks.com/topic/30230-php-taking-spaces-and-turning-to-_s/ Share on other sites More sharing options...
makeshift_theory Posted December 11, 2006 Author Share Posted December 11, 2006 I think I found out, I believe it's due to the way name boxes are handled, I don't believe spaces are allowed. Go figure... ::) Link to comment https://forums.phpfreaks.com/topic/30230-php-taking-spaces-and-turning-to-_s/#findComment-139004 Share on other sites More sharing options...
kenrbnsn Posted December 11, 2006 Share Posted December 11, 2006 Althought I couldn't find a specific reference in the manual, I believe PHP will convert any characterin a form name that is illegal in a PHP variable name to an underscore. This is because a form name can potentionally become a PHP variable name. Since you can't have a space in a PHP variable name, it is replaced with an underscore. The manual does explicitly mention replacing a period in a form name with an underscore.Ken Link to comment https://forums.phpfreaks.com/topic/30230-php-taking-spaces-and-turning-to-_s/#findComment-139008 Share on other sites More sharing options...
makeshift_theory Posted December 11, 2006 Author Share Posted December 11, 2006 Cool, thanks for the information. I will lock topic. Link to comment https://forums.phpfreaks.com/topic/30230-php-taking-spaces-and-turning-to-_s/#findComment-139016 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.