Location: PHPKode > scripts > phpEmailUser > login_reg_form.inc.php
<?php
/* phpemailuser by georgfly
* File: login_reg_form.inc.php
* Desc: Contains the code for a Web page that displays
* two HTML forms, side by side. One is a login
* form, and the second is a registration form.
*/
?>
<html><head><title>User Login Page</title>

<!-- java script to submit link for resend password and activation email -->
<script language="Javascript">
  function procLink(currentform,hiddenfield,sendvalue) {
    document.getElementById(currentform)[hiddenfield].value = sendvalue;
    document.getElementById(currentform).submit();
}
</script>

<style type='text/css'>
<!--
label {
font-size:85%;
float: left;
width:40%;
margin-right: .5em;
text-align: right;
clear:left;
}
legend {
font-weight: bold;
font-size: 1em;
margin-bottom: .5em;
}
#wrapper {
margin: 0;
padding: 0;
}
#login {
position: absolute;
left: 0;
width: 350px;
padding: 1em 0;
}
#reg {
position: absolute;
left: 350px;
width: 450px;
padding: 1em 0;
}

#field {padding-bottom: .5em;}
.errors {
font-weight: bold;
font-style: italic;
font-size: 90%;
color: red;
margin-top: 0;
}
-->
</style>
</head>
<body style="margin: 0">


<?php

/* -------------------------------------------------------------------------------------
set fields for the forms
---------------------------------------------------------------------------------------*/

// the fields for login form
$fields_1 = array("fuseremail" => $fieldnames['user_email'][0], "fpassword" => $fieldnames['password'][0]);

// the fields for registration form
$fields_2 = array();
foreach ($fieldnames as $key => $value)
{
	if ($value[1] == "yes")
	{
		$fields_2[$key] = $value[0];
		if ($value[2] == "yes")
		{
			$fields_2[$key] .= "<font color='red'>*</font>";
		}
		if ($key == "password")
		{
			$fields_2["passwordrep"] = "Repeat ".$value[0]."<font color='red'>*</font>";
		}
	}
}
?>



<div id="wrapper">
<!--------------------------------------------------------------------------------------
LOGIN FORM
// ------------------------------------------------------------------------------------->

<div id="login">
<form id="loginform" action=<?php echo $_SERVER['PHP_SELF'].' '?> method="POST">
<fieldset style='border: 1px solid #000000'>
<legend>Login Form</legend>

<?php
if (isset($message_1))
	echo "<p class='errors'>$message_1</p>\n";
	
foreach($fields_1 as $field => $value)
{
	if($field == "fpassword" && !@$resendpass && !@$resendact) // we dont show password field if we display resend-form
	{
		$type = "password";
		echo "<div id='field'>
		<label for='$field'>$value</label>
		<input id='$field' name='$field' type='$type'
		value='' size='20' maxlength='50' />
		</div>\n";
		
		// submit-link for resending password / activation email with javascript
		echo "<input type='hidden' name='resendlink' value=''>";
		echo "<div id='field'>";
		if ($needactivation)
			echo "<div style='margin-left:12%; float:left; padding-right:1em; font-size:75%'>";
		else
			echo "<div style='margin-left:12%; padding-right:1em; font-size:75%'>";
		echo "<a href=\"javascript:procLink('loginform','resendlink','resendpass')\">Password forgotten?</a>
		</div>";
		if ($needactivation)
		{
			echo "<div style='font-size:75%;'>
			<a href=\"javascript:procLink('loginform','resendlink','resendact')\">Lost activation link?</a>
			</div>";
		}
		echo "</div>";
	}
	elseif ($field == "fuseremail") // field for user email address
	{
		$type = "text";
			echo "<div id='field'>
		<label for='$field'>$value</label>
		<input id='$field' name='$field' type='$type'
		value='".@$fuseremail."' size='20' maxlength='50' />
		</div>\n";
	}
}


if (@$resendpass || @$resendact)
{
	// and now the captcha
	if ($inclmathcaptcha){
		$mynobots =  mathscaptcha();
		echo "<div id='field'>
		<label for='$field'>
		<SCRIPT type='text/javascript'>function returnmathnobots(){
		return ['".$mynobots[1][0]."','".$mynobots[1][1]."','".$mynobots[1][2]."'];}
		mynobots = returnmathnobots()
		document.write(mynobots[0]+' '+mynobots[1]+' '+mynobots[2]+' =')</SCRIPT>
		</label>
		<input id='nobots' name='nobots' type='text'
		value='a number (not letters)' size='20' maxlength='50'
		style='background-color: #FFD47F;'
		onfocus=\"if(this.value==this.defaultValue){this.value='';}\" onblur=\"if(this.value==''){this.value=this.defaultValue;}\"
		/>
		</div>\n";
		echo "<input type='hidden' name='nobotsresult' value='".md5($mynobots[0])."'>";
	}

	echo "<input type='submit' name='Button'
	style='margin-bottom: .5em'";
	if (@$resendpass)
		echo "value='Send me a new password' />";
	elseif (@$resendact)
		echo "value='Send me a new activation link' />";
	echo "<div style='font-size:80%; float:right;'>";
	echo "<a href=\"login_reg.php\">Get me out of here!</a>";
	echo "</div>";
}
else
{
	echo "<input type='submit' name='Button'
	style='margin-left: 40%; margin-bottom: .5em'
	value='Login' />";
}
?>

</fieldset>
</form>

</div>



<!--------------------------------------------------------------------------------------
REGISTRATION FORM
// ------------------------------------------------------------------------------------->

<div id="reg">
<form action=<?php echo $_SERVER['PHP_SELF'].' '?> method="POST">
<fieldset style='border: 1px solid #000000'>
<legend>Registration Form</legend>

<?php
if(isset($message_2))
	echo "<p class='errors'>$message_2</p>\n";

foreach($fields_2 as $field => $value)
{
	if(@$unsetfields)
		if (isset($strippedpost[$field]))
			unset ($strippedpost[$field]);
			
	if($field == "password" || $field == "passwordrep")
	{
		$type = "password";
		$defaultval = '';
	}
	else
	{
		$type = "text";
		$defaultval = @$strippedpost[$field];
	}
	echo "<div id='field'>
	<label for='$field'>$value</label>
	<input id='$field' name='$field' type='$type'
	value='$defaultval' size='30' maxlength='50' />
	</div>\n";
} // end foreach field


// and now the captcha
if ($inclmathcaptcha){
	$mynobots =  mathscaptcha();
	echo "<div id='field'>
	<label for='$field'>
	<SCRIPT type='text/javascript'>function returnmathnobots(){
	return ['".$mynobots[1][0]."','".$mynobots[1][1]."','".$mynobots[1][2]."'];}
	mynobots = returnmathnobots()
	document.write(mynobots[0]+' '+mynobots[1]+' '+mynobots[2]+' =')</SCRIPT>
	</label>
	<input id='nobots' name='nobots' type='text'
	style='background-color: #FFD47F;'
	value='enter a number (not letters)' size='30' maxlength='50' 
	onfocus=\"if(this.value==this.defaultValue){this.value='';}\" onblur=\"if(this.value==''){this.value=this.defaultValue;}\"
	/>
	</div>\n";
	echo "<input type='hidden' name='nobotsresult' value='".md5($mynobots[0])."'>";
}

?>


<input type="submit" name="Button"
style='margin-left: 45%; margin-bottom: .5em'
value="Register">
</fieldset>
</form>
</div>
</div>
</body></html>
Return current item: phpEmailUser