Welcome to Welcome to DNF.com™ - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars

If you are new to domains and looking to buy, sell and learn about domains then you have come to the right place. DNForum is the largest domain name community on the internet and continues to grow every day. There are over 105,000 domainers on DNForum doing everything from buying domains, selling domains, learning about domains and discussing domains. Take a minute and Register.

Register Today on DNForum IT'S FREE!

Results 1 to 6 of 6
  1. #1
    þórr mjǫlnir
    draggar's Avatar
    Join Date
    Dec 2007
    Location
    South Florida
    Posts
    12,874
    Country

    Czech Republic
    DNF$
    6,974
    Bank
    116,559
    Total DNF$
    123,533
    Donate  

    Required fields in a form

    I have a contact page (basic CGI form) and I'd like to make some of the fields required.

    This is the section for email (one I'd like to make required).

    Code:
     Email:
         <input type="text" name="email" size="47">
    I also have a form.php file that the information is sent to (via the "submit" button) - I'm assuming the required fields part should be put in there?
    Save the wolves - join The Wolf Army today!
    Please follow the rules or suffer the wrath of Thor's Hammer.

  2. #2
    Platinum Lifetime Member
    amplify's Avatar
    Join Date
    Sep 2009
    Location
    Okinawa, Japan
    Posts
    699
    DNF$
    522
    Bank
    3,868
    Total DNF$
    4,390
    Donate  
    -
    Last edited by amplify; 02-12-2010 at 09:38 PM.

  3. #3
    þórr mjǫlnir
    draggar's Avatar
    Join Date
    Dec 2007
    Location
    South Florida
    Posts
    12,874
    Country

    Czech Republic
    DNF$
    6,974
    Bank
    116,559
    Total DNF$
    123,533
    Donate  
    I'm assuming that code goes into the form.php?
    Save the wolves - join The Wolf Army today!
    Please follow the rules or suffer the wrath of Thor's Hammer.

  4. #4
    Platinum Lifetime Member
    amplify's Avatar
    Join Date
    Sep 2009
    Location
    Okinawa, Japan
    Posts
    699
    DNF$
    522
    Bank
    3,868
    Total DNF$
    4,390
    Donate  
    -
    Last edited by amplify; 02-12-2010 at 09:39 PM.

  5. #5
    Country hopper
    katherine's Avatar
    Join Date
    Jul 2005
    Location
    Free World
    Posts
    7,499
    Country

    Iceland
    DNF$
    30,536
    Bank
    0
    Total DNF$
    30,536
    Donate  
    Say your submit button is named 'submit':

    PHP Code:
    if (isset($_POST['submit'])) { // submit button  was pressed

        
    if empty($_POST['email'])) {
            echo 
    'Error: E-mail is empty:'
        
    } else { // perform further validation on the E-mail address: regex etc...
            
    ...
        }

    PS: you can keep all the stuff in a single page, that calls itself:
    PHP Code:
    <?php
    if (isset($_POST['submit'])) { // submit button  was pressed

        
    if empty($_POST['email'])) {
            echo 
    'Error: E-mail is empty:'
        
    } else { // perform further validation on the E-mail address: regex etc...
            
    ...
        }
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>test</title>
    </head>

    <body>

    <div id="wrapper">
    <form action="test.php">
    <input type="text" name="email" size="47" maxlength="47" />
    <input type="submit" name="submit" value="Send" />
    </form>
    </div>

    </body>
    </html>
    NameNewsletter.com - free lists of available domain names
    ZoneFiles.net (beta) - ccTLD and gTLD droplists

  6. #6
    þórr mjǫlnir
    draggar's Avatar
    Join Date
    Dec 2007
    Location
    South Florida
    Posts
    12,874
    Country

    Czech Republic
    DNF$
    6,974
    Bank
    116,559
    Total DNF$
    123,533
    Donate  
    TY Kate - The form is in a WP page, too. Sadly, the "same page" code isn't working (the code itself shows up). I'll have to wait until I get home to see if I can eddit the form.php file.
    Save the wolves - join The Wolf Army today!
    Please follow the rules or suffer the wrath of Thor's Hammer.

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
  •  

Domain name forum recommended by Domaining.com