Jump to content

Can't Get Variable Value ?


yusufhermanto

Recommended Posts

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

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'];

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.

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']

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.