Need help with a registration form

Discussion in 'PHP' started by dougvcd, May 23, 2007.

  1. #1

    i have this registration form but what i need to do is make some of the fields
    required such as name username password and email
    also to check if the email is valid
    can any one advise me
    thanks Doug

    <title>Register</title>
    </head>
    
    <body bgcolor="#FF0000">
    <form action="insert.php" method="post">
    
    <table border="0" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <td><h3 style="border-bottom:1px solid black;">Registration Form</h3></td>
    </tr>
    <tr>
    <td>
    
    <label for="name" style="float:left;width:140px;">Name:</label><input type="text" name="name" id="name" value="" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>
    
    <label for="username" style="float:left;width:140px;">Username</label><input type="text" name="username" id="username" value="" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>
    
    <label for="password" style="float:left;width:140px;">Password</label><input type="password" name="password" id="password" value="" maxlength="" style="width:200px;">
    <div style="clear:left;height:20px;"> </div>
    
    <label for="email" style="float:left;width:140px;">E-Mail Address:</label><input type="text" name="email" id="email" value="" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>
    
    <label for="parkname" style="float:left;width:140px;">Caravan Park Name</label><input type="text" name="parkname" id="parkname" value="" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>
    
    <label for="parklocation" style="float:left;width:140px;">Park Location</label><input type="text" name="parklocation" id="parklocation" value="" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>
    
    <label for="caravandetails" style="float:left;width:140px;">Caravan Details</label><textarea name="caravandetails" id="caravandetails" style="width:200px;height:100px;"></textarea><div style="clear:left;height:20px;"> </div>
    
    
    </td>
    <tr>
    <td align="right">
    <!-- YOU CAN MODIFY THE TEXT WITHIN VALUE="" TO MODIFY YOUR BUTTON TEXT-->
    <input type="submit" value=" Register "> <input type="reset" value=" Reset ">
    </td>
    </tr>
    </table>
    </form> 
    PHP:

     
    dougvcd, May 23, 2007 IP
  2. turiel

    turiel Peon

    Messages:
    148
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Have a look at this link, it explains how to do form validation via Javascript, which is your best option - it means instantaneous validation rather than waiting for a submit.

    http://www.w3schools.com/js/js_form_validation.asp
     
    turiel, May 23, 2007 IP
  3. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #3
    You can code that portion in javascript.
     
    it career, May 23, 2007 IP
  4. dougvcd

    dougvcd Peon

    Messages:
    267
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you for info
     
    dougvcd, May 23, 2007 IP
  5. Subikar

    Subikar Active Member

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #5
    As well as give check in insert.php

    Suppose you want username mandatory

    if($_POST['username'] != '')
    {
    // Register
    }

    Otherwise user can disable javascript and registered in your site without the username.
     
    Subikar, May 23, 2007 IP
  6. dougvcd

    dougvcd Peon

    Messages:
    267
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    ok tried the javascript and that didnt work
    i put an email address that was wrong but it still inserted it
    i put instead of .co.uk
    tried to email with hot mail to blueyonder.com and came back as no delivery
    cheers
    Doug
     
    dougvcd, May 23, 2007 IP
  7. turiel

    turiel Peon

    Messages:
    148
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hey,

    The script wasn't meant to do that - it was just meant to check the FORMAT of the field. - i.e. make sure it was

    You can't realistically verify if an email address is correct. There are a number of methods you can use such as connect to the MX for the domain specified which will eliminate some level of error, but nothing definitive. Usually not worth the effort to do - using your example, the validation would have still passed because blueyonder.com is a valid domain, even though your email account isn't hosted there.

    But basically, thats why sites send you a verification email that you have to click to open your account when you register - because they can't definitely check themselves if your email account exists.
     
    turiel, May 23, 2007 IP