Bagiin langsung script nya aje ya gan :D
di mysql jangka
kemudian buat file baru yang disebut activate.php
di yang menempatkan
PHP Code:
<?php // signup.php
include_once 'header.php' ;
include 'checkemail.js' ;
include 'checkfname.js' ;
include 'checkpass.js' ;
include 'checklname.js' ;
include 'checkgender.js' ;
echo <<<_END <link rel="stylesheet" type="text/css" href="styles.css" />
_END;
{
function isValidEmail ( $Email ){ $pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[az]{2,3})$" ;
if ( eregi ( $pattern , $Email )){
return true ;
}
else {
return false ;
}
}
} $error = $Email = $pass = $firstname = $lastname = $sex = $birthdaymonth = $birthdayday = $birthdayyear = "" ;
if (isset( $_SESSION [ 'email' ])) destroySession ();
if (isset( $_POST [ 'email' ]))
{ $Email = sanitizeString ( $_POST [ 'email' ]); $pass = sanitizeString ( $_POST [ 'pass' ]); $firstname = sanitizeString ( $_POST [ 'firstname' ]); $lastname = sanitizeString ( $_POST [ 'lastname' ]); $pattern = sanitizeString ( $_POST [ 'email' ]); $sex = $_POST [ 'sex' ]; $birthdaymonth = sanitizeString ( $_POST [ 'birthdaymonth' ]); $birthdayday = sanitizeString ( $_POST [ 'birthdayday' ]); $birthdayyear = sanitizeString ( $_POST [ 'birthdayyear' ]);
if ( $Email == "" || $pass == "" || $firstname == "" || $lastname == "" )
{ $error = "<h3><img src='img/errorfields.png'><br /></h3>" ;
}
else
{ $query = "SELECT * FROM members WHERE email=' $Email '" ;
if ( mysql_num_rows ( queryMysql ( $query )))
{ $error = "<img src='img/erroremailalreadyexists.png'>" ;
}
else
if(! $_POST [ 'firstname' ] || strlen ( $_POST [ 'firstname' ])< 3 || strlen ( $_POST [ 'firstname' ])> 20 )
{ $error = '<img src="img/errorfirstname.png">' ;
}
else
if(! $_POST [ 'lastname' ] || strlen ( $_POST [ 'lastname' ])< 2 || strlen ( $_POST [ 'lastname' ])> 20 )
{ $error = '<img src="img/errorlastname.png">' ;
}
else
if ( $sex == "0" )
{ $error = "<img src='img/errorgender.png'>" ;
}
else
if ( $birthdaymonth == "0" )
{ $error = "<img src='img/errormonth.png>'" ;
}
else
if ( $birthdayday == "0" )
{ $error = "<img src='img/errorday.png>'" ;
}
else
if ( $birthdayyear == "0" )
{ $error = "<img src='img/erroryear.png>'" ;
}
else
{
{
if ( isValidEmail ( $_POST [ 'email' ])){
echo "" ;
}else
{
die ( '<br><br><br><br><div class="fieldContainer">Invalid Email! Click <a href="http://localhost/PHP%20lesson/signup1test.php">HERE</a> :(</div>' );
} $string = round ( rand ( 1 , 100 ) * rand ( 1 , 100 ) - rand ( 1 , 100 ) / rand ( 1 , 100 ) * rand ( 1 , 100 ) + rand ( 1 , 100 )); $activate = md5 ( $string );
$to = $Email ; $from = "admin@yousite.com" ; $subject = "Welcome to yoursite.com" ; $message = "Welcome to yoursite.com to begin using you account please click <A href='http://www.yousite.com/activate.php?email= $Email &hash= $activate '>Here</a>" ; $headers = "From: $from \r\n" ; $headers .= "Content-type: text/html\r\n" ;
mail ( $to , $subject , $message , $headers );
$query = "INSERT INTO members VALUES('id',' $firstname ',' $lastname ',' $Email ',' $pass ',' $sex ',' $birthdaymonth ',' $birthdayday ',' $birthdayyear ',' $activate ','accountstatus')" ; queryMysql ( $query ); $result = mysql_query ( $query );
die( "<h4><br><br><br><h2><div class='fieldContainer'>CONGRATS!</h2><br>Before you can login , check your email for a verification email!</div>" );
}
}
}}
echo <<<_END <head>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<script type="text/javascript" src="js/script.js"></script>
</head>
<body>
<div id="divcontent">
<div id="divlink">
<span class="spLeft">Have an account?</span>
<span class="spUnclicked" id="spLink">
<a href="" id="textSignin" class="text_link" onclick="showHideLogin(); return false;">
Sign In
</a>
</span>
</div>
<div style="clear:both;"></div>
<div id="divlogin">
<form action="login.php" method="post">
<label for="Email" class="formLabel">Email</label>
<input type="text" name="Email" class="field"/>
<label for="password" class="formLabel">Password</label>
<input type="password" name="passord" class="field"/>
<div class="submit">
<input type="submit" value="Sign In" id="signin_submit"/>
<input type="checkbox" name="remember" id="remember"/>
<label for="remember" id="labelInline">Remember Me</label>
</div>
<div class="forgot">
<a href="#" class="link_bottom">Forgot Password?</a>
</div>
</form>
</div>
</div>
<link rel="stylesheet" type="text/css" href="styles.css" />
<script type="text/javascript" src="script.js"></script>
<body>
<div id="carbonForm">
<h1>Signup</h1>
<form action="signup1test.php" method="post" id="signupForm"> $error
<div class="fieldContainer">
<div class="formRow">
<div class="label">
<label for="name">FirstName:</label>
</div>
<div class="field">
<input type="text" name="firstname" id=" $firstname " onBlur='checkfirstname(this)'/><span id='info1'></span>
</div>
</div>
<div class="formRow">
<div class="label">
<label for="name">LastName:</label>
</div>
<div class="field">
<input type="text" name="lastname" id=" $lastname " onBlur='checklast(this)' /><span id='info3'></span>
</div>
</div>
<div class="formRow">
<div class="label">
<label for="email">Email:</label>
</div>
<div class="field">
<input type="text" name="email" id=" $Email " onBlur='checkEmail(this)'/><span id='info'></span>
</div>
</div>
<div class="formRow">
<div class="label">
<label for="pass">Password:</label>
</div>
<div class="field">
<input type="password" name="pass" id=" $pass " onBlur='checkpass(this)' /><span id='info2'></span>
</div>
</div>
<div class="formrow">
<div class="label">
<label for="sex">Gender:</label>
</div><div align="left"><select class="select" name="sex" id=" $sex " onBlur='checksex(this)' /><span id='infosex'></span>
<option id='sex[]' value="0">Select Gender</option>
<option id='sex[]' value="1">Female</option>
<option id='sex[]' value="2">Male</option></select></div></div>
<div class="formrow">
<div class="label">
<label for="birthdaymonth">Birthday:</label>
</div><div align="left"> <select class="select2" name="birthdaymonth" id=" $birthdaymonth " />
<option id='birthdaymonth[]' value="0">Month:</option>
<option id='birthdaymonth[]' value="1">Jan</option>
<option id='birthdaymonth[]' value="2">Feb</option>
<option id='birthdaymonth[]' value="3">Mar</option>
<option id='birthdaymonth[]' value="4">Apr</option>
<option id='birthdaymonth[]' value="5">May</option>
<option id='birthdaymonth[]' value="6">Jun</option>
<option id='birthdaymonth[]' value="7">Jul</option>
<option id='birthdaymonth[]' value="8">Aug</option>
<option id='birthdaymonth[]' value="9">Sep</option>
<option id='birthdaymonth[]' value="10">Oct</option>
<option id='birthdaymonth[]' value="11">Nov</option>
<option id='birthdaymonth[]' value="12">Dec</option>
</select>
<select class="select2" name="birthdayday" id=" $birthdayday " />
<option id='birthdayday[]' value="0">Day:</option>
<option id='birthdayday[]' value="1">1</option>
<option id='birthdayday[]' value="2">2</option>
<option id='birthdayday[]' value="3">3</option>
<option id='birthdayday[]' value="4">4</option>
<option id='birthdayday[]' value="5">5</option>
<option id='birthdayday[]' value="6">6</option>
<option id='birthdayday[]' value="7">7</option>
<option id='birthdayday[]' value="8">8</option>
<option id='birthdayday[]' value="9">9</option>
<option id='birthdayday[]' value="10">10</option>
<option id='birthdayday[]' value="11">11</option>
<option id='birthdayday[]' value="12">12</option>
<option id='birthdayday[]' value="13">13</option>
<option id='birthdayday[]' value="14">14</option>
<option id='birthdayday[]' value="15">15</option>
<option id='birthdayday[]' value="16">16</option>
<option id='birthdayday[]' value="17">17</option>
<option id='birthdayday[]' value="18">18</option>
<option id='birthdayday[]' value="19">19</option>
<option id='birthdayday[]' value="20">20</option>
<option id='birthdayday[]' value="21">21</option>
<option id='birthdayday[]' value="22">22</option>
<option id='birthdayday[]' value="23">23</option>
<option id='birthdayday[]' value="24">24</option>
<option id='birthdayday[]' value="25">25</option>
<option id='birthdayday[]' value="26">26</option>
<option id='birthdayday[]' value="27">27</option>
<option id='birthdayday[]' value="28">28</option>
<option id='birthdayday[]' value="29">29</option>
<option id='birthdayday[]' value="30">30</option>
<option id='birthdayday[]' value="31">31</option>
</select>
<select class="select2" name="birthdayyear" id=" $birthdayyear " />
<option id='birthdayyear[]' value="0">Year:</option>
<option id='birthdayyear[]' value="2010">2010</option>
<option id='birthdayyear[]' value="2009">2009</option>
<option id='birthdayyear[]' value="2008">2008</option>
<option id='birthdayyear[]' value="2007">2007</option>
<option id='birthdayyear[]' value="2006">2006</option>
<option id='birthdayyear[]' value="2005">2005</option>
<option id='birthdayyear[]' value="2004">2004</option>
<option id='birthdayyear[]' value="2003">2003</option>
<option id='birthdayyear[]' value="2002">2002</option>
<option id='birthdayyear[]' value="2001">2001</option>
<option id='birthdayyear[]' value="2000">2000</option>
<option id='birthdayyear[]' value="1999">1999</option>
<option id='birthdayyear[]' value="1998">1998</option>
<option id='birthdayyear[]' value="1997">1997</option>
<option id='birthdayyear[]' value="1996">1996</option>
<option id='birthdayyear[]' value="1995">1995</option>
<option id='birthdayyear[]' value="1994">1994</option>
<option id='birthdayyear[]' value="1993">1993</option>
<option id='birthdayyear[]' value="1992">1992</option>
<option id='birthdayyear[]' value="1991">1991</option>
<option id='birthdayyear[]' value="1990">1990</option>
<option id='birthdayyear[]' value="1989">1989</option>
<option id='birthdayyear[]' value="1988">1988</option>
<option id='birthdayyear[]' value="1987">1987</option>
<option id='birthdayyear[]' value="1986">1986</option>
<option id='birthdayyear[]' value="1985">1985</option>
<option id='birthdayyear[]' value="1984">1984</option>
<option id='birthdayyear[]' value="1983">1983</option>
<option id='birthdayyear[]' value="1982">1982</option>
<option id='birthdayyear[]' value="1981">1981</option>
<option id='birthdayyear[]' value="1980">1980</option>
<option id='birthdayyear[]' value="1979">1979</option>
<option id='birthdayyear[]' value="1978">1978</option>
<option id='birthdayyear[]' value="1977">1977</option>
<option id='birthdayyear[]' value="1976">1976</option>
<option id='birthdayyear[]' value="1975">1975</option>
<option id='birthdayyear[]' value="1974">1974</option>
<option id='birthdayyear[]' value="1973">1973</option>
<option id='birthdayyear[]' value="1972">1972</option>
<option id='birthdayyear[]' value="1971">1971</option>
<option id='birthdayyear[]' value="1970">1970</option>
<option id='birthdayyear[]' value="1969">1969</option>
<option id='birthdayyear[]' value="1968">1968</option>
<option id='birthdayyear[]' value="1967">1967</option>
<option id='birthdayyear[]' value="1966">1966</option>
<option id='birthdayyear[]' value="1965">1965</option>
<option id='birthdayyear[]' value="1964">1964</option>
<option id='birthdayyear[]' value="1963">1963</option>
<option id='birthdayyear[]' value="1962">1962</option>
<option id='birthdayyear[]' value="1961">1961</option>
<option id='birthdayyear[]' value="1960">1960</option>
<option id='birthdayyear[]' value="1959">1959</option>
<option id='birthdayyear[]' value="1958">1958</option>
<option id='birthdayyear[]' value="1957">1957</option>
<option id='birthdayyear[]' value="1956">1956</option>
<option id='birthdayyear[]' value="1955">1955</option>
<option id='birthdayyear[]' value="1954">1954</option>
<option id='birthdayyear[]' value="1953">1953</option>
<option id='birthdayyear[]' value="1952">1952</option>
<option id='birthdayyear[]' value="1951">1951</option>
<option id='birthdayyear[]' value="1950">1950</option>
<option id='birthdayyear[]' value="1949">1949</option>
<option id='birthdayyear[]' value="1948">1948</option>
<option id='birthdayyear[]' value="1947">1947</option>
<option id='birthdayyear[]' value="1946">1946</option>
<option id='birthdayyear[]' value="1945">1945</option>
<option id='birthdayyear[]' value="1944">1944</option>
<option id='birthdayyear[]' value="1943">1943</option>
<option id='birthdayyear[]' value="1942">1942</option>
<option id='birthdayyear[]' value="1941">1941</option>
<option id='birthdayyear[]' value="1940">1940</option>
<option id='birthdayyear[]' value="1939">1939</option>
<option id='birthdayyear[]' value="1938">1938</option>
<option id='birthdayyear[]' value="1937">1937</option>
<option id='birthdayyear[]' value="1936">1936</option>
<option id='birthdayyear[]' value="1935">1935</option>
<option id='birthdayyear[]' value="1934">1934</option>
<option id='birthdayyear[]' value="1933">1933</option>
<option id='birthdayyear[]' value="1932">1932</option>
<option id='birthdayyear[]' value="1931">1931</option>
<option id='birthdayyear[]' value="1930">1930</option>
<option id='birthdayyear[]' value="1929">1929</option>
<option id='birthdayyear[]' value="1928">1928</option>
<option id='birthdayyear[]' value="1927">1927</option>
<option id='birthdayyear[]' value="1926">1926</option>
<option id='birthdayyear[]' value="1925">1925</option>
<option id='birthdayyear[]' value="1924">1924</option>
<option id='birthdayyear[]' value="1923">1923</option>
<option id='birthdayyear[]' value="1922">1922</option>
<option id='birthdayyear[]' value="1921">1921</option>
<option id='birthdayyear[]' value="1920">1920</option>
<option id='birthdayyear[]' value="1919">1919</option>
<option id='birthdayyear[]' value="1918">1918</option>
<option id='birthdayyear[]' value="1917">1917</option>
<option id='birthdayyear[]' value="1916">1916</option>
<option id='birthdayyear[]' value="1915">1915</option>
<option id='birthdayyear[]' value="1914">1914</option>
<option id='birthdayyear[]' value="1913">1913</option>
<option id='birthdayyear[]' value="1912">1912</option>
<option id='birthdayyear[]' value="1911">1911</option>
<option id='birthdayyear[]' value="1910">1910</option>
<option id='birthdayyear[]' value="1909">1909</option>
<option id='birthdayyear[]' value="1908">1908</option>
<option id='birthdayyear[]' value="1907">1907</option>
<option id='birthdayyear[]' value="1906">1906</option>
<option id='birthdayyear[]' value="1905">1905</option>
</select>
</div>
</div>
<!-- Closing fieldContainer -->
<div class="signupButton">
<input type="submit" name="submit" id="submit" value="Signup" />
</div>
</form>
</div>
_END; ?>
PHP Code:
ALTER TABLE members ADD hash TEXT ; ALTER TABLE members ADD accountstatus TINYINT ( 1 ) default 0 ;
di yang menempatkan
PHP Code:
<?php // activate.php
include_once 'header.php' ;
include 'checkemail.js' ;
echo <<<_END <link rel="stylesheet" type="text/css" href="styles.css" />
_END;
if (isset( $_GET [ 'email' ]))
{ $Email = sanitizeString ( $_GET [ 'email' ]); $hash = sanitizeString ( $_GET [ 'hash' ]);
if ( $Email == "" || $hash == "" )
{ $error = "<h3><img src='img/errorfields.png'><br /></h3>" ;
}
else
{ $query = "SELECT * FROM members WHERE email=' $Email ' and hash=' $hash ' and accountstatus='0'" ;
if ( mysql_num_rows ( queryMysql ( $query )))
{ $query = "UPDATE members SET accountstatus = '1'" ; queryMysql ( $query ); $result = mysql_query ( $query ); $success = "<h3>Your account has now bee successfully activated, You can now login.</h3>" ;
}
else
{ $error = "<img src='img/error.png'>" ;
}
}
echo <<<_END <head>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<script type="text/javascript" src="js/script.js"></script>
</head>
<body>
<div id="divcontent">
<div id="divlink">
<span class="spLeft">Have an account?</span>
<span class="spUnclicked" id="spLink">
<a href="" id="textSignin" class="text_link" onclick="showHideLogin(); return false;">
Sign In
</a>
</span>
</div>
<div style="clear:both;"></div>
<div id="divlogin">
<form action="login.php" method="post">
<label for="Email" class="formLabel">Email</label>
<input type="text" name="Email" class="field"/>
<label for="password" class="formLabel">Password</label>
<input type="password" name="passord" class="field"/>
<div class="submit">
<input type="submit" value="Sign In" id="signin_submit"/>
<input type="checkbox" name="remember" id="remember"/>
<label for="remember" id="labelInline">Remember Me</label>
</div>
<div class="forgot">
<a href="#" class="link_bottom">Forgot Password?</a>
</div>
</form>
</div>
</div>
<link rel="stylesheet" type="text/css" href="styles.css" />
<script type="text/javascript" src="script.js"></script>
<body>
<div id="carbonForm"> $error ; $success ;
</div>
_END;
?>