PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old September 2nd, 2004, 10:37 AM
karlosp karlosp is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 3 karlosp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
single form with submit and preview buttons

Hi All

I have a single form with two buttons, a preview and submit. I would like to give users the option of previewing the contents of the form before it is inserted into my db.

I know I have to use "isset" and give the individual buttons their own values - could someone please provide me with an example that I could try and tweak to suit my needs?

Cheers

Reply With Quote
  #2  
Old September 9th, 2004, 03:37 AM
jabba_29 jabba_29 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: The Ultra Zone
Posts: 3 jabba_29 User rank is Just a Lowly Private (1 - 20 Reputation Level)  Folding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner Folder
Time spent in forums: 40 m 10 sec
Reputation Power: 0
Send a message via ICQ to jabba_29 Send a message via AIM to jabba_29 Send a message via MSN to jabba_29 Send a message via Yahoo to jabba_29
PHP Code:
<?php
 
if (isset($_POST['preview'])):
 
// echo your preview code
 
elseif (isset($_POST['submit'])):
 
// process your form
 
else:
 
?>
 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
     <fieldset>
     <legend>Test</legend>
     <label>Enter Text</label>
     <input type="text" name="test" /><br />
     <input type="submit" name="submit" title="submit" value="Submit" />
     *
     <input type="submit" name="preview" title="preview" value="Preview" />
     </fieldset>
 </form>
 <?php
 
endif;
 
?>

Reply With Quote
  #3  
Old September 9th, 2004, 09:59 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 956 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 650865 Folding Title: Super Ultimate Folder - Level 2Folding Points: 650865 Folding Title: Super Ultimate Folder - Level 2Folding Points: 650865 Folding Title: Super Ultimate Folder - Level 2Folding Points: 650865 Folding Title: Super Ultimate Folder - Level 2Folding Points: 650865 Folding Title: Super Ultimate Folder - Level 2Folding Points: 650865 Folding Title: Super Ultimate Folder - Level 2Folding Points: 650865 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 8 h 23 m 32 sec
Reputation Power: 4
Send a message via ICQ to Itsacon
I prefer this:

PHP Code:
if(isset($_POST['submit']))
{
    if
$_POST['submit'] == 'Submit')
    {
        
/* submit code */
    
}
    elseif(
$_POST['submit'] == 'Preview')
    {
        
/* preview code */
    
}
    else
    {
        echo 
"invalid function";
    }
}
/* output form */

?>
<input type="submit" name="submit" value="Preview" />
<input type="submit" name="submit" value="Submit" /> 


Not much difference, but a bit cleaner imho.

Reply With Quote
  #4  
Old September 9th, 2004, 02:24 PM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 233 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 50 m 19 sec
Reputation Power: 6
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
on my site I actually force the preview instead of making it an option

PHP Code:
<?php
$submit
=$_POST['submit'];
switch(
$submit)
{
case 
'Preview':
break 
1;
/* what is being posted looks like */
/* call a function with the form */
case 'Add':
/* add to DB */
break 1;
default:
/* call function with form */
break 1;
}
?>
<form>
<input type="submit" name="submit" value="Preview">
<input type="submit" name="submit" value="Add">
</form>
__________________
CHornJr
"One day I'll know what I am doing"
My Blog
Suanhacky Lodge #49
Rebel Squadrons

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > single form with submit and preview buttons


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


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway