yusufhermanto Posted October 22, 2009 Share Posted October 22, 2009 i have code like this : user.php <form name="form1" method="post" action="proses_user.php?act=euser" > </p> <table width="565" border="0" class="tbl"> <tr> <td>First Name</td> <td><label> <input type="text" name="txtFNm" id="txtFNm" > </label></td> </tr> <tr> <td> </td> <td><label> <input type="submit" name="cmdSave" id="cmdSave" value="Simpan"> </label></td> </tr> </table> proses_user.php <?php witch($act){ case 'euser': $sfname = $_GET['txtFNm']; echo 'Your First Name: ' . $sfname; break; } ?> at proses_user.php i want to get value from txtFNm, but $sfname not have value. how to fix this problem thanks Link to comment https://forums.phpfreaks.com/topic/178562-cant-get-variable-value/ Share on other sites More sharing options...
Adam Posted October 22, 2009 Share Posted October 22, 2009 Are you seeing "Your First Name:"? Where does the $act variable come from? Link to comment https://forums.phpfreaks.com/topic/178562-cant-get-variable-value/#findComment-941754 Share on other sites More sharing options...
tomcant Posted October 22, 2009 Share Posted October 22, 2009 Are you seeing "Your First Name:"? Where does the $act variable come from? It really doesn't matter where $act comes from. This variable is being used from within the `proses_user.php' script and has nothing to do with the HTML form. To the OP: in the HTML you specified that the forms data be sent to `proses_user.php' via the POST method. So why are you trying to access that data through `$_GET' ? Use this instead: $sfname = $_POST['txtFNm']; Link to comment https://forums.phpfreaks.com/topic/178562-cant-get-variable-value/#findComment-941799 Share on other sites More sharing options...
Adam Posted October 22, 2009 Share Posted October 22, 2009 Are you seeing "Your First Name:"? Where does the $act variable come from? It really doesn't matter where $act comes from. This variable is being used from within the `proses_user.php' script and has nothing to do with the HTML form. Being as he's using the variable within a switch, that relies on $act equaling 'euser', it's quite possible the problem laid with the $act variable. To the OP: in the HTML you specified that the forms data be sent to `proses_user.php' via the POST method. So why are you trying to access that data through `$_GET' ? Use this instead: $sfname = $_POST['txtFNm']; Ha. However, that's probs the problem. I missed it on my first scower of the code. Link to comment https://forums.phpfreaks.com/topic/178562-cant-get-variable-value/#findComment-941801 Share on other sites More sharing options...
purpleshadez Posted October 22, 2009 Share Posted October 22, 2009 as the previous comment, you are using the post method on your form. Also in your switch you are using $act which means you have register globals on. I recommend turning this off and use $_GET['act'] instead. You either need to change your method in user.php to get or use $_POST['txtFNm'] Link to comment https://forums.phpfreaks.com/topic/178562-cant-get-variable-value/#findComment-941802 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.