tags:

views:

31

answers:

2
+4  A: 

You have to use name attribute for each input fields like

<input type="text" id="username" name="username" />

Thanks

Muhit
Might want to also check `if ($_SERVER['REQUEST_METHOD'] == 'POST') {` instead of `if ($_POST['submit'])`. You might at some point forget to set a name on your submit button, but the REQUEST_METHOD will always be present.
Marc B
+1  A: 

Is this the code that is on Adduser.php page? If it is a different page, when a user clicks submit button the Adduser.php page will receive the http request.

Not that you need to use name attribute on inputs. So when this form above is submitted it will receive a http request containing $_POST['submit'], $_POST['username'], $_POST['password']. Which is why at top of the form I first check to see if the submit button was pretty by using PHP::isset() function.

IE.

<?php
if(isset($_POST['submit'])){
//process post submission
//perform mysql insert and notify user the result status
}else{
//initialize form values
$_POST['userName'] = '';
$_POST['password'] = '';
}
?>
<html>
<body>
<form action="<?=$_SERVER['PHP_SELF']?>">
<input type="text" name="username" value="<?=$_POST['userName']?>" />
<input type="text" name="password" value="<?=$_POST['password']?>" />
<input type="submit" name="submit" value="Add user"/>
</form>
</body>
</html>
Chris