new to php, trouble with $POST

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stuckne1
Forum Newbie
Posts: 7
Joined: Sat Nov 27, 2010 10:51 am

new to php, trouble with $POST

Post by stuckne1 »

I'm simply trying to get an action when a button is clicked, but when I click the btnAdd nothing happens...

<html>
<head>
<title>Add New User</title>
</head>
<body>
<form action="addUser.php" method="post">
<h1>Add New User</h1>
<table>
<tr>
<td></td>
<td><input type="button" name='btnAdd' value="Add" ></td>
</tr>
</table>
<?php echo("itch"); ?>
<?php print('itch'); ?>
<?php

if (isset($_POST['btnAdd']))
{
print("btn test");
//testFunction();
}
</form>
</body>
</html>
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: new to php, trouble with $POST

Post by McInfo »

1. You should be getting a parse error because a PHP closing tag is missing after the if block.

2. An <input type="button"> does not submit a form, but an <input type="submit"> does.

3. Please use BBCode tags in your posts. Try the PHP Code button on the submission form.
stuckne1
Forum Newbie
Posts: 7
Joined: Sat Nov 27, 2010 10:51 am

Re: new to php, trouble with $POST

Post by stuckne1 »

okay thanks! Those changes worked.
Post Reply