Hi everyone, can you help me understand the logic why I can't access one of my the items in POST.
Here is my form:

<form action="insert2.php" method="POST">

<table border="0">               
            <tr>
                    <td width="40%"><b>Date:</b></td>
                    <td width="60%"> <input type='text' name="today" placeholder='<?php echo $today ?>' disabled='disabled'> </td>
            </tr>

            <tr>
                    <td width="40%"><b>User ID:</b></td>
                    <td width="60%"> 
                    <input type="text" name="userid" placeholder='<?php           
                    echo $_GET['message'];  
                    ?>'>
                    </td>
            </tr>
            </table>
            <br>
            <br>

                <font color="#990000" size="5px">    [ Choose the appropriate status, and edit the text field for the appropriate action ] </font>

                    <br>
                    <br>


            <table border="0">   
</FORM>

When I var_dump($_POST); it says that ["userid"]=> string(0) while in fact, it has a placeholder value and the value is displayed, but why I can't pass it?

Any help would be very much appreciated. Thankyou.

Recommended Answers

All 2 Replies

the "placeholder" attribute (while not supported in all browsers) is a fancy way of giving a "hint" to the user as to what is supposed to go into the field. A place holder is usually something like "First Name" or "Phone Number" so when the user clicks the field, they know what they are supposed to type there. The value there ("First Name", etc..) is not the actual value of the field. If you want a default value passed in, you will need to set the value of the input, but then your placeholder would not be visibile unless the value is empty.

If you you want the GET to be passed to the form, instead of:
placeholder="<?echo ($_GET['message']);?>"
use
value="<?echo ($_GET['message']);?>"

Hope that helps!

Ryan

commented: Yes. It helps. A lot :) Thank you so much :) +1

You should use the value attribute of input type text

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.