PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 21st, 2009, 10:12 AM
Naughty Naughty is offline
Contributing User
Click here for more information.
 
Join Date: Jul 2009
Posts: 83 Naughty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 53 m 8 sec
Reputation Power: 1
Question To save the contents after completing the page/form

I have created a page to fill in the details like name, upload a wav file, enter the text blah blah, on clicking continue it's directed to second page ( which I call as review page ) like display the datas entered in 1st page.

Now on clicking save button, the entered details should be saved in a table format as below ( page3.php ):
Code:
Form name    create date      sent date     status      action
form1           10/2/2009        12/2/2009    completed  (heckbox )
form2           10/23/2009      11/3/2009    In-complete  "


Finally at end a delete and select all button.

So if the user clicks over form1, It'll direct it to new form page and process would be repeated as before.


How can I do the save part in a table format as above in php?

Reply With Quote
  #2  
Old October 22nd, 2009, 01:30 AM
icandothat's Avatar
icandothat icandothat is offline
Super Moderator
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: San Diego, CA
Posts: 1,657 icandothat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 22 h 10 m 4 sec
Reputation Power: 4
When you say "save part in a table format" do you mean you want to store the data in some permanent way ? or just present it to the user in this way?
__________________
There is no spoon.

Reply With Quote
  #3  
Old October 22nd, 2009, 08:46 AM
Naughty Naughty is offline
Contributing User
Click here for more information.
 
Join Date: Jul 2009
Posts: 83 Naughty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 53 m 8 sec
Reputation Power: 1
I want to do both.
But for now I want to present it to the user in this way.

Reply With Quote
  #4  
Old October 26th, 2009, 02:28 PM
icandothat's Avatar
icandothat icandothat is offline
Super Moderator
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: San Diego, CA
Posts: 1,657 icandothat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 22 h 10 m 4 sec
Reputation Power: 4
So you want to have a sort of repeatable loop where you a user can input some information, see the data they submitted presented to them and then allow them to fill the form again and then see both submissions... That's what I'm understanding
So I guess the way I would do it is this.

page1: the form they fill out
page2: a script that will parse the form details from $_POST and store them in an array in the $_SESSION as such
<?php
$x = count($_SESSION['CART']);
$_SESSION['CART'][$x]['created_date'] = $_POST['created_date'];
$_SESSION['CART'][$x]['sent_date'] = $_POST['sent_date'];
$_SESSION['CART'][$x]['status'] = $_POST['status'];


header('location:http://mysite.com/display');
?>

Then a third page to read the session vars and display them on screen


<?php
echo '<form action='update.php' method='post'><table>'
$x = 0;
foreach($_SESSION['CART'] as $row){
echo '<tr>';
echo '<td><input type="checkbox" id=$x /></td>';
echo '<td>'.$row['created_date'].'</td>';
echo '<td>'.$row['sent_date'].'</td>';
echo '<td>'.$row['status'].'</td>';
echo '</tr>';
}
echo '</table></form>';
?>

This is pretty rough but should give you a starting position. Let me know what you need clarification on .




?>

Reply With Quote
  #5  
Old October 26th, 2009, 04:05 PM
Naughty Naughty is offline
Contributing User
Click here for more information.
 
Join Date: Jul 2009
Posts: 83 Naughty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 53 m 8 sec
Reputation Power: 1
Hey,

Let me stop confusing you. I'll explain clearly what I'm trying to do.

To say the truth I have nearly 2 or 3 php pages connected. In page1.php as mentioned earlier I have form with name of candidate, other details.
on clicking continue it'll get direct to the page2.php, where that's different thing.

In page 1 I have two buttons Save and Continue. So on clciking save I want to direct it to page3 ( a page where user details eneterd would be display his/her name with create and sent date along with checkbox.

The part of my page1.php code

Code:
<div align="center">
Name of the Candidate:<input type="text" name="event">
<br/>
<br/>
Upload a file:<input type="file" name="datafile" size="40">
<br/>
<br/>
</p>
<br /> 
<p>
<input type="submit" value="Save" name="save">
<input type="submit" value="Continue" name="continue">
</p>


Code:

<form method="post" action="page2.php" enctype="multipart/form-data">


The form whether save or continue would direct the page to page2.php. But I want to direct to page2.php on save and page3.php on continue.

Any help!

Reply With Quote
  #6  
Old October 26th, 2009, 05:45 PM
IAmALlama IAmALlama is offline
Me
Click here for more information. Click here for more information
Click here for more information
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 1,937 IAmALlama User rank is Private First Class (20 - 50 Reputation Level)IAmALlama User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 5 Days 1 h 54 m 18 sec
Reputation Power: 4
you would probably have to use javascript to change the action of the form depending on which button, save or continue, was clicked. The other option (I just tested and appears to work) would be to just leave the form to post to page2 and check in the post vars under the button name for what which button was clicked. If the save button was clicked, save the post vars to session and do a header redirect to page3 where you pull the vars off of the session. something like:

page1.php
PHP Code:
<form method="post" action="page2.php">
all your form stuff.
<
input type="submit" name="save" value="Save">
<
input type="submit" name="continue" value="Continue">
</
form


page2.php
PHP Code:
<?php
//start the session
session_start();
//save the post data to the session
$_SESSION['post'] = isset($_SESSION['post'])?array_merge((array)$_SESSION['post'],(array)$_POST):(array)$_POST;
//check if the save button was pressed
if(isset($_POST['save'])){
    
//close the session and make sure it was written
    
session_write_close();
    
//redirect to page3.php
    
header("Location: page3.php");
    
//stop the script to prevent further execution
    
exit;
}
//if we made it down here, the continue button
//was pressed instead of the save button

//continue on page2.php stuff.
?>


page3.php
PHP Code:
//check if there is session post data.
if(isset($_SESSION['post'])){
    
//if so, add the data from $_SESSION['post'] into the $_POST array
    
$_POST = isset($_POST)?array_merge((array)$_SESSION['post'],(array)$_POST):(array)$_SESSION['post'];
    unset(
$_SESSION['post']);
}
//continue on with page3.php stuff.
//you can also now access all the data from both forms in the $_POST array. 

the idea in this is that if you have a form with two submit buttons, only the one you click on is passed in the $_POST array. so on the second page (page2.php) we check if the save button was pressed instead of the continue button and if so save the data from the form in $_SESSION and move to page3.php.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > To save the contents after completing the page/form


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek