<html>
<body>
<form method="post" action="">
<input type="text" name="customername" required/>
<input type="text" name="productname" required/>
<input type="text" name="units" required/>
<input type="text" name="price" required/>
<input type="submit" value="submit"/>
</form>
<?php
if($_POST)
{
$_SESSION['array']=array();
array_push($_SESSION['array'],($_POST));
print_r($_SESSION['array']);
}
?>
</body>
</html>
Here My Need Was i Want To Save the all data which was submitted by the user.but here it was
replacing existing data and displaying the last posted data.
Can u please help me to achieve It.
I want to save all the data upto sessions ends which was posted by the user
Venter
-2
Light Poster
Recommended Answers
Jump to PostIn PHP code use session_start() on the beginning to use a session.
<?php session_start(); if($_POST) { $_SESSION['array']=array(); array_push($_SESSION['array'],($_POST)); print_r($_SESSION['array']); } ?>
Jump to Postarray_push cannot handle the $_POST which handles more than one value. it onlyu handles one value per transaction so it needs to be in this form
@masterjiraya: can you explain above statement. $_POST is an array and array_push is defined as:
int array_push ( array …
All 7 Replies
broj1
356
Humble servant
Featured Poster
masterjiraya
-3
Junior Poster
broj1
356
Humble servant
Featured Poster
broj1
356
Humble servant
Featured Poster
broj1
356
Humble servant
Featured Poster
masterjiraya
-3
Junior Poster
masterjiraya
-3
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.