Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get value from textbox

Tags:

php

I want to get the value of a textbox in PHP, and when I try this:

<form method=post action="update.php">
<input type="text" name="Hex" />
<input type="submit" value="OK" />  
</form>
<?php
$test = $_POST['Hex'];
echo $test;
?>      

I just get the error:

Undefined index: Hex

I've Googled to no avail; so please someone, help me!

like image 671
GuiceU Avatar asked Mar 02 '26 01:03

GuiceU


2 Answers

i think the issue is with the quotation marks, @GuiceU you forgot to add the quotes to post.

Just replace your method = post with method="post"

HTML code:

<form method="post" action="update.php">
<input type="text" name="Hex" />
<input type="submit" value="OK" />  
</form>

php code:

<?php
               $test = $_POST['Hex'];
               echo $test;
?>  
like image 188
arun Avatar answered Mar 03 '26 14:03

arun


I hope this help you:

    <?php
if (isset($_POST['submit'])) {
$test = $_POST['Hex'];
echo $test;
} else { ?>
<form method="post" action="">
<input type="text" name="Hex" />
<input type="submit" value="OK" name="submit" />  
</form>
<?php } ?>
like image 36
phsaires Avatar answered Mar 03 '26 15:03

phsaires



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!