I want to store all values from all input fields in an array using $_POST
. here is my code. if I echo $info[0]
I get an error o is an undefined offset
<html>
<head><time>My Practice</time></head>
<body>
<form method="POST" action="">
<table>
<tr>
<td>First Name</td>
<td><input type="text" name="fname"/></td>
</tr>
<tr>
<td>Last Name</td>
<td><input type="text" name="lname"/></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email"/></td>
</tr>
<tr>
<td>Password</td>
<td><input type="text" name="pass"/></td>
</tr>
<tr>
<td> <input type="submit" name="sub" /></td>
</tr>
</tr>
</table>
</form>
</body>
</html>
<?php if(isset($_POST['sub'])){ $info = array('var1' => $_POST['fname'], 'var2' => $_POST['lname'] ,'var3' => $_POST['email'] , 'var4' => $_POST['pass']); echo $info[1]; } ?>