+ Post New Thread
Page 2 of 4 FirstFirst 1234 LastLast
Results 16 to 30 of 47
Coding Thread, PHP form in Coding and Web Development; Originally Posted by Edu-IT That's not it unfortunately. It is here :P Works fine. Try this: Code: <style type="text/css"> /*Contact ...
  1. #16

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,698
    Thank Post
    335
    Thanked 516 Times in 484 Posts
    Rep Power
    180
    Quote Originally Posted by Edu-IT View Post
    That's not it unfortunately.
    It is here :P Works fine.

    Try this:

    Code:
    <style type="text/css">
    /*Contact form*/
    label {
    width:12em;
    float:left;
    text-align:right;
    margin-right:1.5em;
    display:block
    }
    .submit input {
    margin-left:4.5em;
    }
    input.text {
    border:1px solid #232a15
    margin:2px;
    border:1px solid #A8A8A8
    font-family:Verdana,Arial,Helvetica,sans-serif;
    }
    textarea {
    border: 1px solid #232a15
    margin: 2px;
    border:1px solid #A8A8A8
    font-family:Verdana,Arial,Helvetica,sans-serif;
    }
    fieldset {
    border:1px solid #232a15
    padding: 4px;
    border:1px solid #A8A8A8
    }
    p.error, p.success {
       font-weight: bold;
       padding: 10px;
       border: 1px solid;
      }
      p.error {
       background: #ffc0c0
       color: #900
      }
      p.success {
       background: #b3ff69
       color: #4fa000
      }
    </style>
    <form action="<?php echo basename(__FILE__); ?>" method="post">
    <noscript>
      <p><input type="hidden" name="nojs" id="nojs" /></p>
    </noscript>
         <fieldset>
         <div>
         <label for="name">Name</label>
         <input type="text" class="text" name="name" id="name" size="30" value="<?php if (isset($_POST['name']) && !empty($_POST['name'])) echo $_POST['name']; ?>" />
        </div>
         <div>
         <label for="pupilsname">Pupils Name (if different)</label>
         <input type="text" class="text" name="pupilsname" id="pupilsname" size="30" value="<?php if (isset($_POST['pupilsname']) && !empty($_POST['pupilsname'])) echo $_POST
    
    ['pupilsname']; ?>" />
        </div>
         <div>
         <label for="tutorgroup">Tutor group</label>
         <input type="text" class="text" name="tutorgroup" id="tutorgroup" size="30" value="<?php if (isset($_POST['tutorgroup']) && !empty($_POST['tutorgroup'])) echo $_POST
    
    ['tutorgroup']; ?>" />
        </div>
        <div>
         <label for="pupilssportactivity">Pupils sport/activity</label>
         <input type="text" class="text" name="pupilssportactivity" id="pupilssportactivity" size="30" value="<?php if (isset($_POST['pupilssportactivity']) && !empty($_POST
    
    ['pupilssportactivity'])) echo $_POST['pupilssportactivity']; ?>" />
        </div>
        <div>
         <label for="pupilsachievement">Pupils achievement</label>
         <textarea rows="6" cols="40" name="pupilsachievement" id="pupilsachievement" value="<?php if (isset($_POST['pupilsachievement']) && !empty($_POST['pupilsachievement'])) 
    
    echo $_POST['pupilsachievement']; ?>" /></textarea>
        </div>
         <div>
         <label for="email">E-mail</label>
         <input type="text" class="text" name="email" id="email" size="30" value="" />
        </div>
        <div class="submit">
         <input type="submit" name="submit" id="submit" value="Submit" />
        </div>
        </fieldset>
       </form>
    Works fine in IE8 now.

    Steve


    test.png

  2. #17

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,161
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    Quote Originally Posted by Steve21 View Post
    It is here :P Works fine.

    Try this:

    Code:
    <style type="text/css">
    /*Contact form*/
    label {
    width:12em;
    float:left;
    text-align:right;
    margin-right:1.5em;
    display:block
    }
    .submit input {
    margin-left:4.5em;
    }
    input.text {
    border:1px solid #232a15
    margin:2px;
    border:1px solid #A8A8A8
    font-family:Verdana,Arial,Helvetica,sans-serif;
    }
    textarea {
    border: 1px solid #232a15
    margin: 2px;
    border:1px solid #A8A8A8
    font-family:Verdana,Arial,Helvetica,sans-serif;
    }
    fieldset {
    border:1px solid #232a15
    padding: 4px;
    border:1px solid #A8A8A8
    }
    p.error, p.success {
       font-weight: bold;
       padding: 10px;
       border: 1px solid;
      }
      p.error {
       background: #ffc0c0
       color: #900
      }
      p.success {
       background: #b3ff69
       color: #4fa000
      }
    </style>
    <form action="<?php echo basename(__FILE__); ?>" method="post">
    <noscript>
      <p><input type="hidden" name="nojs" id="nojs" /></p>
    </noscript>
         <fieldset>
         <div>
         <label for="name">Name</label>
         <input type="text" class="text" name="name" id="name" size="30" value="<?php if (isset($_POST['name']) && !empty($_POST['name'])) echo $_POST['name']; ?>" />
        </div>
         <div>
         <label for="pupilsname">Pupils Name (if different)</label>
         <input type="text" class="text" name="pupilsname" id="pupilsname" size="30" value="<?php if (isset($_POST['pupilsname']) && !empty($_POST['pupilsname'])) echo $_POST
     
    ['pupilsname']; ?>" />
        </div>
         <div>
         <label for="tutorgroup">Tutor group</label>
         <input type="text" class="text" name="tutorgroup" id="tutorgroup" size="30" value="<?php if (isset($_POST['tutorgroup']) && !empty($_POST['tutorgroup'])) echo $_POST
     
    ['tutorgroup']; ?>" />
        </div>
        <div>
         <label for="pupilssportactivity">Pupils sport/activity</label>
         <input type="text" class="text" name="pupilssportactivity" id="pupilssportactivity" size="30" value="<?php if (isset($_POST['pupilssportactivity']) && !empty($_POST
     
    ['pupilssportactivity'])) echo $_POST['pupilssportactivity']; ?>" />
        </div>
        <div>
         <label for="pupilsachievement">Pupils achievement</label>
         <textarea rows="6" cols="40" name="pupilsachievement" id="pupilsachievement" value="<?php if (isset($_POST['pupilsachievement']) && !empty($_POST['pupilsachievement'])) 
     
    echo $_POST['pupilsachievement']; ?>" /></textarea>
        </div>
         <div>
         <label for="email">E-mail</label>
         <input type="text" class="text" name="email" id="email" size="30" value="" />
        </div>
        <div class="submit">
         <input type="submit" name="submit" id="submit" value="Submit" />
        </div>
        </fieldset>
       </form>
    Works fine in IE8 now.

    Steve


    test.png
    That worked, thanks. Must be something I did.

  3. #18

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,698
    Thank Post
    335
    Thanked 516 Times in 484 Posts
    Rep Power
    180
    Quote Originally Posted by Edu-IT View Post
    That worked, thanks. Must be something I did.
    As I said :P Made label wider:

    width:12em;

    vs your 4em (or make names shorter)


    What was other issue, it doesn't clear on input?

    Steve

  4. #19

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,161
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    Perfect! Sorry. :-D

    Anyone help with the PHP stuff?

  5. #20

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,698
    Thank Post
    335
    Thanked 516 Times in 484 Posts
    Rep Power
    180
    Quote Originally Posted by Edu-IT View Post
    Perfect! Sorry. :-D

    Anyone help with the PHP stuff?
    You should be able to do a:

    Code:
    document.formname.reset();
    After the submit to clear the boxes.

    Steve

  6. #21

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,161
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    Where, sorry, after the closing fieldset?

  7. #22

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,698
    Thank Post
    335
    Thanked 516 Times in 484 Posts
    Rep Power
    180
    Quote Originally Posted by Edu-IT View Post
    Where, sorry, after the closing fieldset?
    There's few ways to do it, but cleanest (Think that word exists!)

    Change:

    Code:
     <input type="submit" name="submit" id="submit" value="Submit" />
    to

    Code:
    <input name="submit" type="button" value="Submit!" onclick="document.submitForm.submit();document.submitForm.reset();">
    Think that's right. (Obviously you need to put form name in though, which I don't think you did yet?)

    Steve
    Last edited by Steve21; 26th May 2011 at 12:26 PM.

  8. #23

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,161
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    That retains all data still.

  9. #24

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,698
    Thank Post
    335
    Thanked 516 Times in 484 Posts
    Rep Power
    180
    Quote Originally Posted by Edu-IT View Post
    That retains all data still.
    Have you named your form yet? Needs a named form to go against. In the original one it didn't have a name :P Can you post all what you're trying again please.

    Steve

  10. #25

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,161
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    <form name="sports" action="<?php echo basename(__FILE__); ?>" method="post">
    <noscript>
    <p><input type="hidden" name="nojs" id="nojs" /></p>
    </noscript>
    <fieldset>
    <div>
    <label for="name">Your name</label>
    <input type="text" class="text" name="name" id="name" size="30" value="<?php if (isset($_POST['name']) && !empty($_POST['name'])) echo $_POST['name']; ?>" />
    </div>
    <div>
    <label for="pupilsname">Pupils name (if different)</label>
    <input type="text" class="text" name="pupilsname" id="pupilsname" size="30" value="<?php if (isset($_POST['pupilsname']) && !empty($_POST['pupilsname'])) echo $_POST
    ['pupilsname']; ?>" />
    </div>
    <div>
    <label for="tutorgroup">Tutor group</label>
    <input type="text" class="text" name="tutorgroup" id="tutorgroup" size="30" value="<?php if (isset($_POST['tutorgroup']) && !empty($_POST['tutorgroup'])) echo $_POST
    ['tutorgroup']; ?>" />
    </div>
    <div>
    <label for="pupilssportactivity">Pupils sport/activity</label>
    <input type="text" class="text" name="pupilssportactivity" id="pupilssportactivity" size="30" value="<?php if (isset($_POST['pupilssportactivity']) && !empty($_POST
    ['pupilssportactivity'])) echo $_POST['pupilssportactivity']; ?>" />
    </div>
    <div>
    <label for="pupilsachievement">Pupils achievement</label>
    <textarea rows="6" cols="40" name="pupilsachievement" id="pupilsachievement" value="<?php if (isset($_POST['pupilsachievement']) && !empty($_POST['pupilsachievement']))
    echo $_POST['pupilsachievement']; ?>" /></textarea>
    </div>
    <div>
    <label for="email">Your email address</label>
    <input type="text" class="text" name="email" id="email" size="30" value="<?php if (isset($_POST['email']) && !empty($_POST['email']))
    echo $_POST['pupilsachievement']; ?>" />
    </div>
    <div class="submit">
    <input type="submit" name="submit" id="submit" value="Submit" onclick="document.submitForm.submit();document.sub mitForm.reset();" />
    </div>
    </fieldset>
    </form>
    This is what I have.

  11. #26

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,698
    Thank Post
    335
    Thanked 516 Times in 484 Posts
    Rep Power
    180
    Code:
    <form name="sports"
    
    <input type="submit" name="submit" id="submit" value="Submit" onclick="document.submitForm.submit();document.sub mitForm.reset();" />
    :P that "should" be the issue"

    Replace submitForm with sports

    Code:
    <input type="submit" name="submit" id="submit" value="Submit" onclick="document.sports.submit();document.sports.reset();" />
    the document.sports is the form name you're submitting/resetting.

    Steve

  12. #27

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,161
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    Nope still not working.

    <div class="submit">
    <input type="submit" name="submit" id="submit" value="Submit" onclick="document.sports.submit();document.sports. reset();" />
    </div>

  13. #28

    CESIL's Avatar
    Join Date
    Nov 2006
    Location
    Hampshire
    Posts
    1,404
    Thank Post
    109
    Thanked 267 Times in 198 Posts
    Rep Power
    168
    Your form is submitting to the page that contains it...is that right?

    If so then as you are putting the $_POST data into the form fields then they will always be filled in...

    You need to clear out the $POST data after the data has been processed then the fields will be empty after form submissions.

  14. #29

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,161
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    How do I do that?

  15. #30

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,698
    Thank Post
    335
    Thanked 516 Times in 484 Posts
    Rep Power
    180
    Can you try:

    Code:
    <input type="submit" name="submit" id="submit" value="Submit" onclick="javascript:document.sports.submit();javascript:document.sports.reset();" />
    Didn't think it was fussy enough but maybe it's being silly O.o or I'm just missing something obvious.

    Steve

SHARE:
+ Post New Thread
Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. [PHP] Form to Email.php
    By tomgrindle in forum Web Development
    Replies: 4
    Last Post: 26th April 2011, 12:26 PM
  2. HTML/PHP form problem
    By glennda in forum Web Development
    Replies: 4
    Last Post: 17th November 2010, 10:22 AM
  3. PHP - Form POST script
    By BarryWAaMC in forum Coding
    Replies: 9
    Last Post: 31st March 2010, 11:32 AM
  4. [PHP] PHP Form Generator
    By _Bat_ in forum Web Development
    Replies: 1
    Last Post: 25th March 2009, 11:39 AM
  5. PHP form validation
    By thesk8rjesus in forum Web Development
    Replies: 10
    Last Post: 21st January 2009, 12:09 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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