Php register form help.

Dobby

Member
Nov 8, 2010
156
5
Im trying to make this add people to the database but i cant seem to get it to work.

Code:
<a href="#x" class="overlay" id="join_form"></a>
        <div class="popup">
            <h2>Sign Up</h2>
            <p>Please enter the details you would like to<br>
            register with here. You MUST be <br>atleast thirteen
            to register.</p><br>
            <form action="register.php" method="post">
            <div>
                <label for="email">Email</label>
                <input type="text" id="email" value="" />
            </div>
            <div>
                <label for="pass">Password</label>
                <input type="password" id="pass" value="" />
            </div>
            <div>
                <label for="firstname">First name</label>
                <input type="text" id="firstname" value="" />
            </div>
            <div>
                <label for="lastname">Last name</label>
                <input type="text" id="lastname" value="" />
            </div>
            <div>
            <label for="age">Sex</label>
            <input type="radio" name="sex" value="male">Male
            <input type="radio" name="sex" value="female">Female
            </div>
            </form>

I have a had a go at adding the PHP to it but nothing seems to work. Can someone help?
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
Try this:
PHP:
<head>
<title>Tekst</title>
</head>
<body>
<div class="header">
<div class="wrapper">
<div class="Logo"></div>
<div class="headernav"><font color="white"><b>
Please login or register to enter the Dobby's Network website.</b></font>
</div>
        </div>
        </div>
           
                <div id="wrapper_content">
                <div class="left">
                <div class="box">
                <center><br>
           
                <a href="#login_form" id="login_pop">
                <img src="images/login.png"/></a>
                <br><br>
                </center>
                </div>
                </div>
       
                    <div class="right">
                        <div class="box">
                        <center><br>
       
       
                <a href="#join_form" id="join_pop">
                <img src="images/register.png"/></a>
       
                <br><br>
                </center>
                </div>
                </div>
            <br><br><center>
                <font color="red"><b><p>Warning: This is just a DEMO. Nothing actually works here at the moment<p></b></font>
                <center>
           
                <!-- Popups -->
 
                <a href="#x" class="overlay" id="login_form"></a>
                <div class="popup">
           
            <h2>Welcome Guest!</h2>
            <p>Please login to gain access to the full website.</p><br>
            <div>
                <label for="login">Email</label>
                <input type="text" id="login" value="" />
            </div>
            <div>
                <label for="password">Password</label>
                <input type="password" id="password" value="" />
            </div>
            <center>
            <input type="button" name="login" value="Log In" />
       
            </center>
 
            <a class="close" href="#close"></a>
        </div>
 
      <!-- popup form #2 -->
 
   
        <a href="#x" class="overlay" id="join_form"></a>
        <div class="popup">
   
        <?php
require_once "config.php";
if (isset($_POST['submit'])) 
{
$email = $_POST['email'];
$password = $_POST['password'];
$firstname = strip_tags(mysql_real_escape_string($_POST['firstname']));
$lastname = strip_tags(mysql_real_escape_string($_POST['lastname']));
$memip = $_SERVER['REMOTE_ADDR'];
$date = date("d-m-Y");
$check_members = mysql_query("SELECT * FROM `members` WHERE `email` = '$email'") or die(mysql_error());
$final_report = '';
 
if (empty($email) || empty($password)) {
$final_report .= "Please complete the form below..";
}
else if (mysql_num_rows($check_members) != 0) {
$final_report .= "The username is already in use!";
}
 
else if (strlen($password) <= 6 || strlen($password) >= 12)
{
$final_report .= "Your password must be between 6 and 12 digits and characters..";
} 
 
else if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email))
{
$final_report .= "Your email address was not valid..";
} 
 
else 
{
mysql_query("INSERT INTO `members` (`email`, `password`, `firstname`, `lastname`, `ip`, `date`) VALUES('$email','$password','$firstname','$lastname','$memip','$date')") or die(mysql_error());
$final_report .= "Thank you for registering, you may login.";
}
}
else 
{
echo "I didn't set the register POST.";
}
 
if (isset($final_report) && $final_report != '')
{
echo $final_report;
}
else if (isset($final_report))
{
echo "Final report not set";
}
?>
   
            <h2>Sign Up</h2>
            <p>Please enter the details you would like to<br>
            register with here. You MUST be <br>atleast thirteen
            to register.</p><br>
            <form action="index.php" method="POST">
            <div>
                <label for="email">Email</label>
                <input type="text" name="email" value="" />
            </div>
            <div>
                <label for="pass">Password</label>
                <input type="password" name="password" value="" />
            </div>
            <div>
                <label for="firstname">First name</label>
                <input type="text" name="firstname" value="" />
            </div>
            <div>
                <label for="lastname">Last name</label>
                <input type="text" name="lastname" value="" />
            </div>
            <div>
            <label for="sex">Sex</label>
            <input type="radio" name="sex" value="male">Male</input>
            <input type="radio" name="sex" value="female">Female</input>
            </div>
            <input type="submit" id="submit" name="submit" value="Sign Up" />
            </form>
       
       
       
            <center>&nbsp;&nbsp;&nbsp;or&nbsp;&nbsp;&nbsp;<a href="#login_form" id="login_pop">Log In</a>
 
            <a class="close" href="#close"></a>
            </center>
        </div>
           
           
            </div>
        </div>
</body>
 

Users who are viewing this thread

Top