SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Taunton, UK
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can I reset the value of $_POST["submit"]

    I have a page that uses jquery tabs and on one of these tabs I have a simple enquiry form. Anyway after the form is submitted, it no longer displays if I go to another tab and then back again.

    Code:
    <div id="tab_3">
    
    <h2>Enquiry Form</h2>
    
    <?php
    
    if (!$_POST["submit"] or count($arrErrors) > 0 or $errors == 1) { 
    
    ?>
    
    
    <form id="enquiry" method="post" action="<?php echo $PHP_SELF; ?>">
    Hence I am wondering if I can reset the value of $_POST["submit"] so the the form will display again?
    Mediakitchen Limited
    App Development | Website Design & Development | Flash Game Development
    Somerset, UK
    http://www.mediakitchen.co.uk

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Surely it make more sense to rid of that clause in the if statement?

    Anyway:
    PHP Code:
    unset($_POST['submit']); 
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Taunton, UK
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey thanks Jake.

    If I get rid of the clause in the if statement, then the form is displayed after submission. I have the if clause so after submitting the form, the user gets a "Thank you for contacting blah" message. I suppose I could display the form under the thank you message but thought it may be clearer if the form isn't displayed after submission.

    I have just tried the unset command and it seems to take me back to the first tab for some reason rather than staying on tab 3 where the enquiry form resides. Hmm???
    Mediakitchen Limited
    App Development | Website Design & Development | Flash Game Development
    Somerset, UK
    http://www.mediakitchen.co.uk

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chuckylefrek View Post
    it may be clearer if the form isn't displayed after submission.
    Then why do you want to display it again then?

    One option would be to display the message and, using JQuery, fade that message out and fade in the form again.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Taunton, UK
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wanted to display the form again if the user navigates using the tabs then returns to this enquiry form tab.

    I have realised now that after submitting, it seems to display the contents of tab 1 anyway so another hurdle to overcome. Weird as I am sure it was remaining on tab3 earlier after submitting the form.

    Would prefer not to go with the fade out option due to the risk of a user missing the message and then not knowing if their form had been submitted or not

    Cheers

    Paul
    Mediakitchen Limited
    App Development | Website Design & Development | Flash Game Development
    Somerset, UK
    http://www.mediakitchen.co.uk

  6. #6
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Taunton, UK
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have opted just to keep the form onscreen at all times but have worked out how to use jquery to hide the confirmation message if I click on a different tab then come back again by putting the confirmation text into a div called "confirmation"

    Code:
    $('#tabs').bind('tabsselect', function(event, ui) {
    	
    	 if (ui.panel.id == "tab_3") {      
    
    		$('#confirmation').html("");  
    		
    
        	}
        
    });
    Probably not the best solution but at least it works
    Mediakitchen Limited
    App Development | Website Design & Development | Flash Game Development
    Somerset, UK
    http://www.mediakitchen.co.uk

  7. #7
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,784
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Naming a button "submit" can cause clashed in some browsers with JavaScript as the browser will then assume that a submit call refers to the button instead of the submit function and those browsers (eg. IE) will then be unable to submit the form at all from within JavaScript.

    It is best to not give submit buttons a name at all (unless you have multiple submit buttons and need to tell which was used based on the value passed).
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


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
  •