Php And Html Form On The Same Page
I am learning php. I am passing some values from one page to another page, and letting the user enter form into this page and then storing into the database. I would like to stay o
Solution 1:
<?php
@session_start();
$_session['count']= $_GET['count'];
$_session['sum']= $_GET['Sum'];
for ($i=0;$i<$_session['count'];$i++){
//make necessary changes here as wellecho unserialize($_GET['serialized_name'])[$i];
//use session to store your data from previous page?><?php//put this code above the form to process the submitted data which was previously sent to update.phpif(isset($_POST[submit])){
//Your code
e.g.
$name=$_POST['name']
//whenever you want to access previous data just get it from session variable.
e.g. $count=$_SESSION['count'];
}?><html><!--Submit the data of the form to itself instead of update.php --><formmethod="post"action="<?phpecho$PHP_SELF;?>"><!--your html code --></form></html>
Solution 2:
Try this, put all this code in the page you want to stay on (I am saying it is update.php here):
<?phpif($_POST['submit_button'] == "Submit")
{
$name= $_POST['name'];
}
?><formmethod="post"action="update.php"><inputtype="text"name="name"value="value1" /><inputtype="submit"name="submit_button"value="Submit"/></form>
Solution 3:
You can pass more data over to update.php by using hidden fields just above your <input type=submit
.
e.g. <input type="hidden" name="some_data" value="<?php echo $some_data; ?>" />
Of course, any web visitor can see this data if they use their browser's "View source" feature, so only do this with data that cannot cause a security problem.
Then, in update.php, you can access that data by doing something like $some_data = $_POST["some_data"]
Post a Comment for "Php And Html Form On The Same Page"