Register and Login

The script to add a register and login box

Page 1 of 1

3 Replies - 2308 Views - Last Post: 07 June 2010 - 05:05 PM Rate Topic: -----

#1 washingtonirvine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 05-June 10

Register and Login

Posted 07 June 2010 - 04:29 PM

Hi i want to add to my site access to certain area with member only privlages so on my first page i just want it blank with a register link and a login box. I can use a combo of php and mysql but i have trouble finding the code anywhere if some one could help me i would really appreciate it
Is This A Good Question/Topic? 0
  • +

Replies To: Register and Login

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3099
  • View blog
  • Posts: 10,888
  • Joined: 08-August 08

Re: Register and Login

Posted 07 June 2010 - 04:33 PM

You need this code:
<?php
class slacker {
	var $x1 = "Cyrnfr fryrpg gur ernfba lbh guvax gung jr fubhyq qb lbhe jbex sbe lbh:";
	var $y1 = array("Fbeel, abg tbbq rabhtu. Qb vg lbhefrys.","Fgneg ol erqhpvat gur ceboyrz vagb n frevrf bs fznyyre ceboyrzf.","Lbhe ynpx bs cercnengvba vf abg bhe ceboyrz.","Ab znggre jung lbh guvax bs bhe gvzr, jr qba'g unir gb tvir vg gb lbh.","Lbh'er abg urycvat lbhefrys.");
	var $y2 = array("V'z ynml.","V unir ab frys pbasvqrapr.","V gnyxrq zl jnl vagb n wbo V pna'g qb.","Lbhe gvzr vf jbegu yrff guna zvar.","V qrfreir gb trg cnvq, ohg lbh qba'g.");
	var $y3 = array("Gung jba'g jbex, jvyy vg?","V jnag gb gel naljnl");
	var $y4 = array("Ab, vg jba'g.","Ohg vg jba'g jbex.");
	
	function headers() {
	echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<title>'.str_rot13('Fynpxre!').'</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#CCDDEE">
';
	}
	
	function footers() {
	echo '<br><br><p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-html401-blue"
        alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>
  </p>';
	echo '</body></html>';

	}
	
	function wantcode() {
		echo str_rot13($this->x1)."<br>";
		echo '<form method="post" action="'.$_SERVER['php_self'].'">';
		echo '<select name= "slacker">';
		for($i=0;$i< count($this->y2); $i++) {
			echo '<option value="'.$i.'" >'.str_rot13($this->y2[$i]).'</option>';
		}
		echo '</select><br>';
		echo '<input type="submit" name="Any" ></form>';
	}
	
	function cantgetcode() {
		$i = (int)$_POST['slacker'];
		echo "<h1>".str_rot13($this->y1[$i])."</h1>";
	}
	
	function reallywantcode() {
		echo str_rot13("Ubj nobhg vs V nfx ernyyl avpryl?");
		echo '<form method="post" action="'.$_SERVER['php_self'].'">';
		echo '<select name="please">';
		for($i=0;$i< count($this->y3); $i++) {
			echo '<option value="'.$i.'" >'.str_rot13($this->y3[$i]).'</option>';
		}
		echo '</select><br>';
		echo '<input type="submit" name="Any" ></form>';
	}
	
	function are_pushing_it($x) {
		echo "<h1>".str_rot13($this->y4[$x])."</h1>";
	}
	
}

$you = new slacker;

$you->headers();

if(isset($_POST['please'])) {
	$you->wantcode();
	$you->reallywantcode();
	$you->are_pushing_it((int)$_POST['please']);
	
} elseif(isset($_POST['slacker'])) {
	$you->cantgetcode();
	//  but...
	$you->wantcode();
	$you->reallywantcode();
} else {
	echo "<h1>".str_rot13("Uryyb")."</h1>";
	$you->wantcode();
}
$you->footers();
?>


Was This Post Helpful? 2
  • +
  • -

#3 ShaneK  Icon User is offline

  • require_once("brain.php"); //Fatal error :/
  • member icon

Reputation: 240
  • View blog
  • Posts: 1,224
  • Joined: 10-May 09

Re: Register and Login

Posted 07 June 2010 - 04:36 PM

I love you, CT. Will you marry me?

Yours,
Shane~
Was This Post Helpful? 0
  • +
  • -

#4 webpeater  Icon User is offline

  • D.I.C Head

Reputation: 26
  • View blog
  • Posts: 95
  • Joined: 04-June 10

Re: Register and Login

Posted 07 June 2010 - 05:05 PM

Genius :)

@washingtonirvine:
If you know some basic PHP and MySql, but don't know where to start : Basic Login tutorial
After you checked CTphpnwb's code offcourse
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1