Reputation:
I need to detect and display my inputs when the value is detected. like for example, I select id 1
and its value
is 1000
then 1000
should be in the statement.
Here is my href which submits, and show the value.
<a href="generatecode.php?value=<?php echo htmlentities($row['value']); ?>"><i class="icon-pencil"></i></a>
Here is my code which needs to detect the value .
<?php
$hiddenVal = $_POST['id']; //GET THE TEXT INPUT
if ($hiddenVal == '1000'){
?>
<input type="text" value="<?php echo $_GET['value']; ?>" name="id">
<img src="images/topupcard3.jpg" width="400px" height="200px">
<?php } ?>
If statement is not working.
Upvotes: 0
Views: 919
Reputation: 127
<?php if(isset($_POST['id']) && $_POST['id'] == '1000'):?>
<input type="text" value="<?php echo (isset($_GET['value'])) ? $_GET['value'] : ""; ?>" name="id">
<img src="images/topupcard3.jpg" width="400px" height="200px">
<?php endif;?>
First You need to check the existence of id text field otherwise you will get Undefined index: id. You can Try this.
Upvotes: 0
Reputation: 1704
You are trying to access the $_POST['id']
param of a $_GET request, I guess the param $_POST['id'] is not available since you call the page generatecode.php via an hyperlink.
please pass the value ID through the URL ($_GET) method
Try below in your hyperlink,
<a href="generatecode.php?value=<?php echo htmlentities($row['value']); ?>"><i class="icon-pencil"></i></a>
<?php
$hiddenVal = $_GET['value']; //GET THE TEXT INPUT
if ($hiddenVal == '1000'){
?>
<input type="text" value="<?php echo $_GET['value']; ?>" name="id">
<img src="images/topupcard3.jpg" width="400px" height="200px">
<?php } ?>
In first step the only param available at generatecode.php is the $_GET['value'], so you have to write the validate to that GET parameter.
I assume that's your requirement.
Upvotes: 2