Why is $_POST always null? php CODE: if(isset($_POST['addFriend_name'])) { echo('TEST'); } Code (markup): js CODE: function addFriend(name) { //set vars document.getElementById('addFriend_name').value = name; //refresh screen document.getElementById('addFriend_form').submit(); } Code (markup): html CODE: <div style="display:none;"> <form id="addFriend_form" method="post" action="http://www.foreverplaying.com/script/members/member_test.php"> <p> <input type="hidden" id="addFriend_name" name="addFriend_name" /> </p> </form> </div> Code (markup): If you the source code would help the page is: http://www.foreverplaying.com/script/members/member_glock77.php Please help. I've been working on this problem for an hour and I still can't see whats wrong? Mabye some fresh eyes might see the problem. If you need anymore info tell me and I'll post it. Thanks.
Because it doesn't make any sense. "addFriend_name" type should be text, not hidden. Try this: <div style="display:none;"> <form id="addFriend_form" method="post" action="http://www.foreverplaying.com/script/members/member_test.php"> <p> <input type="text" id="addFriend_name" name="addFriend_name" /> </p> </form> </div> HTML: Here's a standalone example of how $_POST and form works together: <?php echo "<form action='' method='post'>"; echo "<input type='text' name='addFriend_name' />"; echo "<input type='submit' value='lol' />"; if(isset($_POST['addFriend_name'])) { echo $_POST['addFriend_name']; } ?> PHP:
First of all, I don't get your javascript piece, it sets a value, and than refreshes the page without sending that value... I don't know why you use it either. Just skip the javascript part, ant together with rainulf's script it would work. If it doesn't, could you please give the outcome of print_r($_POST)
Yes php is installed properly. What do you mean it doesn't send the value? I need the javascript part because it is part of a function which makes the hidden field value a name (could be any name) and then submits it to the server for processing. I don't get why the $_POST var is always null.
can you try this and see if it works <?php echo "<form action='' method='post'>"; echo "<input type='text' name='addFriend_name' value='test' />"; echo "<input type='submit' value='lol' />"; if(isset($_POST['addFriend_name'])) { echo $_POST['addFriend_name']; } ?>
The file you gave me works (tested in its own file) but my full script still doesn't work. What I don't understand is I have another form on the same page with about 7 fields and that form works (It uses the same format). The form which is not working is just above the other form but that shouldn't matter. The php functions are at the top of the page. The main problem is still not working.