SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Zealot jplatenius's Avatar
    Join Date
    Nov 2003
    Location
    Vancouver Island, Canada
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help hiding form on submit

    Hi all,

    I'm new to the game. Almost done this form and trying to hide it after the client hits Submit. So the form hides and my Thank you message is displayed. The way it works now is the fomr stays and my message is displayed above it, but for formatting reasons, it doesn't work as well as it could.

    Is there a quick line that I can put in to accomplish this?
    PHP Code:
      <?
    if(sizeof($_POST)) {
    $body ""
    while(list(
    $key$val) = each($HTTP_POST_VARS)) {
    $body .= "$key$val\n";
    }
    $headers .= "From: Web Form <".$Name.">\n\n"
    mail("[email="john@virtuallycertain.com"]john@virtuallycertain.com[/email]"// to
    "Ocean Bliss Rental Request",
    $body$headers);
    ?>
    <div align="center">
     <strong><p>Thanks for sending us your request to stay at Ocean Bliss Loft in Tofino.</p>
       
          <p>We will contact you soon to confirm your reservation and at that time 
            request a deposit to reserve your accommodations.</p>
     </strong>
    (My form is below this HTML)

    Any help appreciated.

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The basic syntax for that sort of thing is..
    if(isset($_POST['submit'])){
    ....stuff to do with the submitted form here...
    } else {
    ... show the form here ...
    }

    where 'submit' is the name of the forms submit button (or use some other form element)

  3. #3
    SitePoint Zealot jplatenius's Avatar
    Join Date
    Nov 2003
    Location
    Vancouver Island, Canada
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks mark,

    so does that mean i put the hiddin Thanks message after...

    if(isset($_POST['submit'])){

    HTML TAGS... Hidden message that shows after submit... Thank you for being such a dude

    } else {
    the form is here
    }

  4. #4
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Correct.

  5. #5
    SitePoint Zealot jplatenius's Avatar
    Join Date
    Nov 2003
    Location
    Vancouver Island, Canada
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I'm havining problems with the php tags. Here is what I have:
    PHP Code:
    <?
    if(sizeof($_POST)) {
    $body ""
    while(list(
    $key$val) = each($HTTP_POST_VARS)) {
    $body .= "$key$val\n";
    }
    $headers .= "From: Web Form <".$Name.">\n\n"
    mail("[email="john@virtuallycertain.com"]john@virtuallycertain.com[/email]"// to
    "Ocean Bliss Rental Request",
    $body$headers);
    if(isset(
    $_POST['submit'])){
    ?>
    <div align="center">
     <strong><p>Thanks for sending us your request to stay at Ocean Bliss Loft in Tofino.</p>
       
          <p>We will contact you soon to confirm your reservation and at that time 
            request a deposit to reserve your accommodations.</p>
     </strong>
    </div>
    <?php
    } else {
    ?>
    <div align="center">
     <div class="box">
      <form name="Contact" method="post" action=<? echo $PHP_SELF?>
       <div>
        <label>Arrival:</label>
         <select name="ArrivalMonth" value="<?php echo $ArrivalMonth ?>" />
          <option value="Month">Month</option>
          <option value="January">January</option>
          <option value="January">February</option>
          <option value="March">March</option>
          <option value="April">April</option>
          <option value="May">May</option>
          <option value="June">June</option>
          <option value="July">July</option>
          <option value="August">August</option>
          <option value="September">September</option>
          <option value="October">October</option>
          <option value="November">November</option>
          <option value="December">December</option>
         </select>
          <select name="ArrivalDay" value="<?php echo $ArrivalDay ?>" />
          <option value="Day">Day</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
          <option value="8">8</option>
          <option value="9">9</option>
          <option value="10">10</option>
          <option value="11">11</option>
          <option value="12">12</option>
          <option value="13">13</option>
          <option value="14">14</option>
          <option value="15">15</option>
          <option value="16">16</option>
          <option value="17">17</option>
          <option value="18">18</option>
          <option value="19">19</option>
          <option value="20">20</option>
          <option value="21">21</option>
          <option value="22">22</option>
          <option value="23">23</option>
          <option value="24">24</option>
          <option value="25">25</option>
          <option value="26">26</option>
          <option value="27">27</option>
          <option value="28">28</option>
          <option value="29">29</option>
          <option value="30">30</option>
          <option value="31">31</option>
         </select>
         <select name="ArrivalYear" value="<?php echo $ArrivalYear ?>" />
          <option value="Year">Year</option>
          <option value="2004">2004</option>
          <option value="2005">2005</option>
          <option value="2006">2006</option>
         </select>
        </div>
       <div>
        <label>Departure:</label>
         <select name="DepartureMonth" value="<?php echo $DepartureMonth ?>" />
          <option value="Month">Month</option>
          <option value="January">January</option>
          <option value="February">February</option>
          <option value="March">March</option>
          <option value="April">April</option>
          <option value="May">May</option>
          <option value="June">June</option>
          <option value="July">July</option>
          <option value="August">August</option>
          <option value="September">September</option>
          <option value="October">October</option>
          <option value="November">November</option>
          <option value="December">December</option>
         </select>
          <select name="DepartureDay" value="<?php echo $DepartureDay ?>" />
          <option value="Day">Day</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
          <option value="8">8</option>
          <option value="9">9</option>
          <option value="10">10</option>
          <option value="11">11</option>
          <option value="12">12</option>
          <option value="13">13</option>
          <option value="14">14</option>
          <option value="15">15</option>
          <option value="16">16</option>
          <option value="17">17</option>
          <option value="18">18</option>
          <option value="19">19</option>
          <option value="20">20</option>
          <option value="21">21</option>
          <option value="22">22</option>
          <option value="23">23</option>
          <option value="24">24</option>
          <option value="25">25</option>
          <option value="26">26</option>
          <option value="27">27</option>
          <option value="28">28</option>
          <option value="29">29</option>
          <option value="30">30</option>
          <option value="31">31</option>
         </select>
         <select name="DepartureYear" value="Year" />
          <option value="2004">2004</option>
          <option value="2005">2005</option>
          <option value="2006">2006</option>
         </select>       
        </div>
       <div>
        <label>Name:</label>        
         <input name="Name" type="text" id="Name" size="25" />
        </div>
       <div>
        <label>Street:</label>        
         <input name="Street" type="text" id="Address" size="25" />
        </div>
       <div>
        <label>City:</label>        
         <input name="City" type="text" id="City" size="25" />
        </div>
       <div>
        <label>Prov./State:</label>        
         <input name="Province" type="text" id="Province" size="25" />
        </div>
       <div>
        <label>Country:</label>        
         <input name="Country" type="text" id="Country" size="25" />
        </div>
       <div>
        <label>Postal/Zip Code:</label>        
         <input name="PostalCode" type="text" id="PostalCode" size="25" />
        </div>
       <div>
        <label>Phone:</label>        
         <input name="Phone" type="text" id="Phone" size="25" />
        </div>
       <div>
        <label>Email:</label>        
         <input name="Email" type="text" id="Email" size="25" />
        </div>
       <div>
        <label>Comments:</label>
         <textarea name="Comments" cols="23" rows="10" id="Comments" /></textarea> 
        </div>
       <div>
         <input type="submit" class="submit" name="Submit" value="Submit Form" />
         <input type="reset" class="submit" name="Reset" value="Reset Form">
        </div>
      </form> 
     </div>
    </div>
    <?php
    }
    ?>
    But I'm getting a parse error. As you can see, I'm closing the php before the HTML, and then openning it up again after HTML is done, then opening again... Am I not using the php tag properly here?

  6. #6
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?
    if(isset($_POST['Submit']))
    {
      
    $body "";
      while(list(
    $key$val) = each($_POST))
      {
        
    $body .= "$key$val\n";
      }
      
    $headers .= "From: Web Form <".$Name.">\n\n";
      
    mail("john@virtuallycertain.com"// to
      
    "Ocean Bliss Rental Request",
      
    $body$headers);
    ?>
    <div align="center">
    <strong><p>Thanks for sending us your request to stay at Ocean Bliss Loft in Tofino.</p>

          <p>We will contact you soon to confirm your reservation and at that time
            request a deposit to reserve your accommodations.</p>
    </strong>
    </div>
    <?php
    } else {
    ?>
    ...put all your form stuff here...
    <?php
    }
    ?>
    Indentation really helps when trying to match braces etc.. (/me hopes he got his right )

  7. #7
    SitePoint Zealot Scout141's Avatar
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks like you're missing an extra brace at the bottom to close the 'mail-script'
    PHP Code:
    if(sizeof($_POST)) {
    ...
    ...
    ...

    <?php
         
    }
    }
    ?>
    I would probably put the mailing part inside the 'if -submit' section and avoid the extra 'size of post' test. Note: If you do it this way, you only need the one curly brace at the bottom like it currently is...

    HTH


    Edit:


    Yeah, indentation _does_ help!

    Doh! End of day!
    /me Didn't catch the sneaky allusion to the answer!

  8. #8
    SitePoint Zealot jplatenius's Avatar
    Join Date
    Nov 2003
    Location
    Vancouver Island, Canada
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for all the good stuff there. I got it back and running but the form still doesn't hide when it is submitted.

    Here's the url: www.oceanblissloft.com/tofino_accommodations_rates2.php

    I'm sort of regretting putting the stupid form in there... but a sense of completion will make it feel soo much better. Any thoughts?

  9. #9
    SitePoint Zealot Scout141's Avatar
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's your code look like now?

  10. #10
    SitePoint Zealot jplatenius's Avatar
    Join Date
    Nov 2003
    Location
    Vancouver Island, Canada
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?

    if(isset($_POST['submit']))
    {
     
    $body ""
     while(list(
    $key$val) = each($HTTP_POST_VARS))
     {
      
    $body .= "$key$val\n"
     }
     
    $headers .= "From: Web Form <".$Name.">\n\n"
     
    mail("[email="john@virtuallycertain.com"]john@virtuallycertain.com[/email]"// to
     
    "Ocean Bliss Rental Request",
     
    $body$headers);
    ?>
    <div align="center">
     <strong><p>Thanks for sending us your request to stay at Ocean Bliss Loft in Tofino.</p>
       
          <p>We will contact you soon to confirm your reservation and at that time 
            request a deposit to reserve your accommodations.</p>
     </strong>
    </div>
    <?php
    } else {
    ?>

    form is here
     
    <?php
    }
    ?>

  11. #11
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your submit button is named 'Submit' not 'submit' so try :
    if(isset($_POST['Submit']))

    which is what i originally pasted in my example above..pay attention!!! (j/k)

  12. #12
    SitePoint Zealot jplatenius's Avatar
    Join Date
    Nov 2003
    Location
    Vancouver Island, Canada
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    doh! thank you and appologies appologies -- i am a servant, you are my master...

  13. #13
    SitePoint Zealot jplatenius's Avatar
    Join Date
    Nov 2003
    Location
    Vancouver Island, Canada
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    did i mention that you guys rock...thanks so much, eh.


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
  •