SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict einSTein's Avatar
    Join Date
    Aug 2006
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    1 form 2 action please answer urgent

    i need to make a form with 2 submit buttons the first one sends the data of the form to a blank page and the other send the data to another self page

    Description:

    1st button is to preview the form data in a blank page (preview.php,"Blank")
    2nd button is to send data to make do a query in the database (add.php,"self")

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A form cannot have more than 1 action.

    However, a php script can serve multiple purposes.
    PHP Code:
    if ($_POST) {
        if (isset(
    $_POST['add'])) {
            
    // code for add
        
    } else {
            
    // default, code for preview
        
    }
    } else {
        
    // no form posted

    This assumes that the "add" button will be textually after the preview button in the forms html source code. Do not do an explicit check for the first submit button in the form, because in certain browsers, the name of that button may not be sent if the user submits the form with the enter key.

  3. #3
    SitePoint Addict einSTein's Avatar
    Join Date
    Aug 2006
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i need to preview in blank page to make the data remains at the feilds coz i'm using FCK editor and i can return back the data to it

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, the sample code I gave you will give you a blank page.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •