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?
 

Dobby

Member
Nov 8, 2010
156
5
The code i have been using just dosent work with this form the code i use is actually part of a free thing i downlaoded and it not working :(

<?
// This simple PHP / Mysql membership script was created by
// You are free to use this script at your own risk
// Please visit our website for more updates..
include_once"config.php";
if(isset($_POST['register'])){
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$memip = $_SERVER['REMOTE_ADDR'];
$date = date("d-m-Y");
if($username == NULL OR $password == NULL OR $email == NULL){
$final_report.= "Please complete the form below..";
}else{
if(strlen($username) <= 3 || strlen($username) >= 30){
$final_report.="Your username must be between 3 and 30 characters..";
}else{
$check_members = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'");
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{
$create_member = mysql_query("INSERT INTO `members` (`id`,`username`, `password`, `email`, `ip`, `date`)
VALUES('','$username','$password','$email','$memip','$date')");
$final_report.="Thank you for registering, you may login.";
}}}}}}
?>

This is the default thing but even this dosent work when i made the form work to this
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
PHP:
<?
// This simple PHP / Mysql membership script was created by www.funkyvision.co.uk
// You are free to use this script at your own risk
// Please visit our website for more updates..
include_once"config.php";
if (isset($_POST['register'])) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    $email = $_POST['email'];
    $memip = $_SERVER['REMOTE_ADDR'];
    $date = date("d-m-Y");
    if (empty($username) OR empty($password) OR empty($email)) {
        $final_report.= "Please complete the form below..";
    } else if (strlen($username) <= 3 || strlen($username) >= 30) {
            $final_report.="Your username must be between 3 and 30 characters..";
        } else {
            $check_members = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error());
            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 {
                        $create_member = mysql_query("INSERT INTO `members` (`id`,`username`, `password`, `email`, `ip`, `date`)
VALUES('','$username','$password','$email','$memip','$date')");
                        $final_report.="Thank you for registering, you may login.";
                    }
                }
            }
 
?>

Please post the error it gives.
 

Dobby

Member
Nov 8, 2010
156
5
There is no error. This is what the actual php and html looks like

Code:
<a href="#x" class="overlay" id="join_form"></a>
        <div class="popup">
       
       
       
        <?
 
include_once"config.php";
if (isset($_POST['register'])) {
    $email = $_POST['email'];
    $password = $_POST['password'];
    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];
    $memip = $_SERVER['REMOTE_ADDR'];
    $date = date("d-m-Y");
    if (empty($email) OR empty($password)) {
        $final_report.= "Please complete the form below..";
    } else if (strlen($username) <= 3 || strlen($username) >= 30) {
            $final_report.="Your username must be between 3 and 30 characters..";
        } else {
            $check_members = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error());
            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 {
                        $create_member = mysql_query("INSERT INTO `members` (`id`,`email`, `password`, `firstname`, `lastname`, `ip`, `date`)
VALUES('','$email','$password','$firstname','$lastname','$memip','$date')");
                        $final_report.="Thank you for registering, you may login.";
                    }
                }
            }
 
?>
       
       
       
       
       
       
       
       
       
       
       
            <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>
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
Replace PHP code with this:
PHP:
<?
// This simple PHP / Mysql membership script was created by www.funkyvision.co.uk
// You are free to use this script at your own risk
// Please visit our website for more updates..
include_once"config.php";
if (isset($_POST['register'])) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    $email = $_POST['email'];
    $memip = $_SERVER['REMOTE_ADDR'];
    $date = date("d-m-Y");
    if (empty($username) OR empty($password) OR empty($email)) {
        $final_report.= "Please complete the form below..";
    } else if (strlen($username) <= 3 || strlen($username) >= 30) {
            $final_report.="Your username must be between 3 and 30 characters..";
        } else {
            $check_members = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error());
            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 {
                        $create_member = mysql_query("INSERT INTO `members` (`id`,`username`, `password`, `email`, `ip`, `date`)
VALUES('','$username','$password','$email','$memip','$date')");
                        $final_report.="Thank you for registering, you may login.";
                    }
                }
            }
else
{
echo "I didn't set the register POST."
}
 
?>
 

Dobby

Member
Nov 8, 2010
156
5
Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/a8732736/public_html/index.html on line 135

If you want to see what im trying to do go to and click register
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/a8732736/public_html/index.html on line 135

If you want to see what im trying to do go to and click register
My fault, search this line:
echo "I didn't set the register POST."

and add an ; at the end.
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
Like said... you can't execute PHP code in an .HTML file... ofcourse it isn't working. Change it to index.php
 

TesoMayn

Boredom, it vexes me.
Oct 30, 2011
1,482
1,482
tg3WQdq.jpg
 

Users who are viewing this thread

Top