Jump to content

my register.php for custom site


Jack222

Recommended Posts

Hi I really need help coding my register.php 

please flag any mistakes and suggest additions to the code 

please help 

 

 

<html>
    <head>
        <title>______________</title>
    </head>
    <body>
        <h2>Registration Page</h2>
        <a href="index.php">Click here to go back<br/><br/>
        <form action="register.php" method="POST">
           Enter Company Name: <input type="text" name="Company_Name" required="required" /> <br/>
           Enter Unit: <input type="text" name="Unit" required="required" /> <br/>
           Enter Street: <input type="text" name="Street" required="required" /> <br/>
           Enter Town: <input type="text" name="Town" required="required" /> <br/>
           Enter County: <input type="text" name="County" required="required" /> <br/>
           Enter Postcode: <input type="text" name="Postcode" required="required" /> <br/>
           Enter Country: <input type="text" name="Country" required="required" /> <br/>
           Enter Phone Number: <input type="text" name="Phone_Number" required="required" /> <br/>
           Enter Email: <input type="text" name="Email" required="required" /> <br/>
           Enter Password: <input type="password" name="Password" required="required" /> <br/>
           <input type="submit" value="Register"/>
        </form>
    </body>
</html>


<?php
if($_SERVER["REQUEST_METHOD"]== "POST"){
    $Company_Name = mysql_real_escape_string($POST['Company Name']);
    $Unit = mysql_real_escape_string($POST['Unit']);
    $Street = mysql_real_escape_string($POST['Street']);
    $Town = mysql_real_escape_string($POST['Town']);
    $County = mysql_real_escape_string($POST['County']);
    $Postcode = mysql_real_escape_string($POST['Postcode']);
    $Country = mysql_real_escape_string($POST['Country']);
    $Phone_Number  = mysql_real_escape_string($POST['Phone Number']);
    $Email = mysql_real_escape_string($POST['Email']);
    $Password = mysql_real_escape_string($POST['Password']);


    echo "Company Name entered is: ". $Company_Name . "<br/>";
    echo "Unit entered is: ". $Unit . "<br/>";
    echo "Street entered is: ". $Street . "<br/>";
    echo "Town entered is: ". $Town . "<br/>";
    echo "County entered is: ". $County . "<br/>";
    echo "Postcode entered is: ". $Postcode . "<br/>";
    echo "Country entered is: ". $Country . "<br/>";
    echo "Phone Number entered is: ". $Phone_Number . "<br/>";
    echo "Email entered is: ". $Email. "<br/>";
    echo "Password entered is: ". $Password . "<br/>";
  }
  ?>
Edited by Ch0cu3r
Link to comment
Share on other sites

First on the list:  Please post your code properly for this forum (and any others you use).  Here it is square brackets surrounding 'code' and '/code' to open and close the code block.

 

One thing to do would be to move into the current decade and stop using the MySQL_* functions.  Check the manual.  They are marked in RED - Do Not Use

 

You should use label tags.  Look them up.

 

Currently (using deprecated escape function) you do an escape on an input but then you go and display it to the client.  Bad.  You s/b prepping those fields for safe display, not for safe usage in a query.  Read up on htmlspecialchars function.  Besides - if your escape function puts a slash in a var, do you really want to echo that back to the user?

PLUS - do you really want to pass the password back over the net to the user???

 

Also - I don't see a field for State or Province in your address fields.  That leaves out the US and Canada and probably many other users.

 

On the plus side - glad to see that you (unlike many other new users) avoided the pitfall of placing style attributes in every single one of your inputs.  Good to see.  Of course I do hope you will be using some CSS to style these later. 

 

One thing you might want to consider is adding value clauses with php vars in them so that you can re-send the form and the user's inputs back to him/her in the case of errors.  Otherwise they will have to re-enter the entire form.  This would of course mean that you should probably separate the password function to another screen so that you Don't send it back.

 

Keep on trucking!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.