Hi guys, I hope the day is going well for everyone.
At the moment when I post I can only get 1 record to go into my array, I need to be able to put 35 in and have them echo out to the page before i decide what to do. with them, which will be putting them in my mysql database.
I want the array to be to be able to hold all the feild's in the post and each time the user post i want to see the record being added to the array.
Can someone tell me what is wrong here?
Thanks in Advance
Code: Select all
<?php
/*//check to see if the form has been submitted
if(isset($_POST['fname']))
{
$post_array = array();//initalize array
foreach ($_POST as $key => $value) {//loop through post values
$post_array[$key] = $value;//add post value to array
}
//loop through post_array and echo values
foreach($post_array as $key => $value)
{
echo $key .": " .$value."<br/>";
}
}*/
if (isset($_POST['fname']))
{
$post_array = array( array( ));
foreach ($_POST as $key[] => $value)
{
$post_array[] = $value;
}
foreach($post_array as $key => $value)
{
echo $key .": " .$value."<br/>";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form name="info" action="" method="post">
first name: <input type="text" name="fname" value="" /><br/>
last name:<input type="text" name="lname" /><br />
phone number:<input type="text" name="phone" /><br />
<input type="submit" />
</form>
</body>
</html>