Help with a PHP Register script!
07-07-2010, 08:12 PM, (This post was last modified: 07-07-2010, 11:35 PM by RichardGv.)
#8
RE: Help with a PHP Register script!
(07-07-2010, 03:47 PM)Cameron Wrote: Anyway your code was bust, got some syntax errors. I moved on to a different script I recieved from a friend. Thanks for the help though!

Sorry, somehow I added an extra "(". The error has been corrected.
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>

<
html xmlns="http://www.w3.org/1999/xhtml" lang="en-us" xml:lang="en-us">

<
head>
    <
title>Registration</title>
    
    <
meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
    <
meta name="robots" content="noindex, nofollow" />
</
head>

<
body>
<?
php
define
('FULLNAME_MAX'25);
define('FULLNAME_MIN'3);
define('USERNAME_MAX'25);
define('USERNAME_MIN'3);
define('PASSWORD_MAX'25);
define('PASSWORD_MIN'6);

if(empty(
$_POST['submit'])
        || empty(
$_POST['fullname'])
        || empty(
$_POST['username'])
        || empty(
$_POST['password'])
        || empty(
$_POST['repeatpwd'])
        || !(
$fullname trim($_POST['fullname']))
        || !(
$username trim($_POST['username']))
        || !(
$password trim($_POST['password']))
        || !(
$repeatpwd trim($_POST['repeatpwd']))
        || 
$password != $repeatpwd
        
|| strlen($fullname) >= FULLNAME_MAX
        
|| strlen($fullname) <= FULLNAME_MIN
        
|| strlen($username) >= USERNAME_MAX
        
|| strlen($username) <= USERNAME_MIN
        
|| strlen($password) >= PASSWORD_MAX
        
|| strlen($password) <= PASSWORD_MIN
        
) {
?>
    <h2>Registration</h2>
    <form action='register.php' method='POST'>
        <table>
            <tr>
                <td>Full Name:</td>
                <td>
                    <input type='text' name='fullname' value='' />
                </td>
            </tr>
            <tr>
                <td>Username:</td>
                <td>
                    <input type='text' name='username' value='' />
                </td>
            </tr>
            <tr>
                <td>Password:</td>
                <td>
                    <input type='password' name='password' value='' />
                </td>
            </tr>
            <tr>
                <td>Repeat Password:</td>
                <td>
                    <input type='password' name='repeatpwd' />
                </td>
            </tr>
        </table>
        <p><input type='submit' name='submit' value='Register' /></p>
    </form>
<?php
}
else {
    if(!
get_magic_quotes_gpc()) {
        
$username addslashes(strip_tags($username));
        
$fullname addslashes(strip_tags($fullname));
    }
    
$date date ("Y-m-d");
    
$password md5($password);
    
    
$connect mysqli_connect ("localhost","cameron_cameron","MYPASSHERE"'cameron_user');
    if(
mysqli_connect_errno()) {
        
// Connection error handling
    
}
    
$result mysqli_query ($db,
    
"INSERT INTO users VALUES ('','$fullname','$username','$password','$date')"
    
);
    echo 
"<p>Congrats! You've been registered! You may now <a href='index.php'>login</a></p>";
}

?>
</body>

</html> 
It's absolutely a problem that you can fix easily, though, that every person knowing a bit about PHP can fix easily.
Gentoo Linux User (w/ fvwm) / Loyal Firefox User / Owner of a Stupid Old Computer - My PGP Public Key

No man is an island, entire of itself; every man is a piece of the continent, a part of the main; if a clod be washed away by the sea, Europe is the less, as well as if a promontory were, as well as if a manor of thy friends or of thine own were; any man's death diminishes me, because I am involved in mankind; and therefore never send to know for whom the bell tolls; it tolls for thee.
-- Devotions Upon Emergent Occasions (1624), John Donn
Reply


Messages In This Thread
Help with a PHP Register script! - by Cameron - 07-07-2010, 08:56 AM
RE: Help with a PHP Register script! - by Zach - 07-07-2010, 09:38 AM
RE: Help with a PHP Register script! - by Cameron - 07-07-2010, 09:44 AM
RE: Help with a PHP Register script! - by Cameron - 07-07-2010, 01:46 PM
RE: Help with a PHP Register script! - by Cameron - 07-07-2010, 03:47 PM
RE: Help with a PHP Register script! - by RichardGv - 07-07-2010, 08:12 PM
RE: Help with a PHP Register script! - by Matt - 07-07-2010, 11:00 PM
RE: Help with a PHP Register script! - by Cameron - 07-10-2010, 02:11 PM
RE: Help with a PHP Register script! - by Zavoo - 07-10-2010, 06:44 PM
RE: Help with a PHP Register script! - by jahiy - 05-27-2011, 12:52 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [SOLV'D] PHP Login/Register Tutorial Soldier 9 2,739 12-04-2010, 02:31 AM
Last Post: Vanilla

Forum Jump: