Jump to content

[SOLVED] Can I approve someone that wants to login before they do?


energysuperstore09

Recommended Posts

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create a field in your admins table in the database called "active"

Have its default value of 0.

 

Then on your login page,

Only allow them in if their details are correct and active = 1

 

Then all you need to do is change the value to 1 in the database to allow them in.

 

For example,

On my site, when someone registers their account. Active =0 and it generates an auth code in the db also for that user.

 

They then have to read their e-mail and goto a link.

That link then verifys and changed active to 1 if their auth code matches whats in the database.

 

This not only stops robots from logging in, but also verifies that their e-mail is correct.

 

Link to comment
Share on other sites

I use the PHP mail function

http://us.php.net/manual/en/function.mail.php

 

what I do is take an MD5 hash of their username (but you could really use anything, their password, email address, etc.) and send store this "authentification" hash on the DB. Then I send them a link to a verification page, and set a get variable to their specific hash (a typical link in an email would look like: mysite.com/verify.php?hash=ahdf8a9fh39ahfe8h)

 

then, compare the get variable to the DB, and on whatever row the hash matches, verify the account. make sure that you don't verify twice tho

Link to comment
Share on other sites

I cant paste my code as its just faaaar to long.

Well on the login page you could do something like:

 

<?php

$result = mysql_query("SELECT * FROM admins where username = '$username' AND password = '$password'");

while($row = mysql_fetch_array($result))
  {
   $active = $row['active'];

if ($active == "0" {
     $error = "1";
}}

// then if error = 1 show them a SORRY not active page , you cant login.

?>

Link to comment
Share on other sites

OK, quick flowchart of what would happen.

 

Your user registers

Your script inserts the user into the database and assigns a random value to the auth field in their account

Your script sends a mail to them saying please visit, Blaa.com/verify.php?auth=AUTHCODE

They click the link.

Your verify.php will get loaded when they click it.

verify.php will set active to 1 where the authcode = the same code in the db. ( so ?auth=code  equals the same as the db auth code )

 

the account would now be verified.

 

Its a bit of code to get it working, but probably worth it.

 

-G

Link to comment
Share on other sites

heres my mail code

<?php
function send_email($from, $to, $subject, $message){
$headers = "From: ".$from."\r\n";
$headers .= "Reply-To: ".$from."\r\n";
$headers .= "Return-Path: ".$from."\r\n";
$headers .= "Content-type: text/html\r\n"; 

if (mail($to,$subject,$message,$headers) ) {
} else {
}
}


$messageee = "";
$subject = "Welcome to IMsupporting.com";
$messageee .= "<html><body>";
$messageee .= "<b>Thankyou for registering.<br></b>";
$messageee .= "<br>";
$messageee .= "<br>You need to activate your account. Please click the link below:<br>";
$messageee .= "<br><a href=\"http://imsupporting.com/register/confirm_account.php?username=$username&authcode=$authcode\">Click HERE</a>";
$messageee .= "<br><br>For your reference, Your auth code is : $authcode";
$messageee .= "<br><br>";
$messageee .= "<br>Please visit http://admin.imsupporting.com/getcodeindex.php?siteid=$randnum To get your website code<br>";
$messageee .= "<br>Regards, <br>IMsupporting.com";
$messageee .= "</body></html>";

send_email("IMsupporting System <support@imsupporting.com>", "$email", 
$subject , 
$messageee);

}



?>

 

Then on my verify page,

I use:

 

<?php

$authcode = $_POST['authcode'];  OR use $_GET ( depends how you pass the data )
$username = $_POST['username'];

// ( Stuff to remove bad chars and sql injections )

$result = mysql_query("SELECT authcode, active FROM admins where username = '$username' limit 1");
while($row = mysql_fetch_array($result))
  {
  $dbauthcode = $row['authcode'];
  $active = $row['active'];
  }
  
if ($dbauthcode != $authcode) {
$title = "  Sorry, That code is invalid.";
$bodymessage = "<br><br>Sorry, the code you entered was incorrect<br>Please check your mail again and doublecheck the code.<br>Click BACK on your browser to try again";

}else{
mysql_query("UPDATE admins SET active = '1' WHERE authcode = '$authcode' and username = '$username' LIMIT 1 ");
$title = " Congratulations";
$bodymessage = "Thank you for signing up.<br>";
$bodymessage .= "<br>Please login to your account <a href=\"http://admin.imsupporting.com\"> Here</a>";
$bodymessage .= "<br><br>Once logged in, Click get website code. This will allow you to add your STATUS icon to your webpage.";
}


mysql_close($con); 


ecco $bodymessge;
?>

 

Link to comment
Share on other sites

Sorry. LOL Here is the code for the registeration page:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registeration for Distributor Area - Go Where the Business Is!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="description" CONTENT="Texas Fluroescents' is a manufacturer of energy efficient linear pendant fluorescent lighting fixtures specifically T5 Industrial Fluorescent Lighting Fixtures, T8 Industrial Fluorescent Lighting Fixtures and T5HO Industrial Fluorescent Lighting Fixtures for industrial lighting, production floor lighting, warehouse lighting.">

<meta NAME="keywords" CONTENT="fluorescent lighting fixtures, T5 Industrial Fluorescent lighting fixtures, T5HO industrial fluorescent lighting fixtures, T8 industrial fluorescent lighting fixtures, T5 warehouse lighting fixtures, T5 warehouse fluorescent lighting fixtures">

<meta NAME="robots" CONTENT="index,follow">

<?php
function send_email($from, $to, $subject, $message){
$headers = "From: ".$from."\r\n";
$headers .= "Reply-To: ".$from."\r\n";
$headers .= "Return-Path: ".$from."\r\n";
$headers .= "Content-type: text/html\r\n"; 

if (mail($to,$subject,$message,$headers) ) {
} else {
}
}


$messageee = "";
$subject = "Welcome to Texas Fluorescents Distributor Area";
$messageee .= "<html><body>";
$messageee .= "<b>Thankyou for registering.<br></b>";
$messageee .= "<br>";
$messageee .= "<br>You need to activate your account. Please click the link below:<br>";
$messageee .= "<br><a href=\"http://imsupporting.com/register/confirm_account.php?username=$username&authcode=$authcode\">Click HERE</a>";
$messageee .= "<br><br>For your reference, Your auth code is : $authcode";
$messageee .= "<br><br>";
$messageee .= "<br>Please visit http://admin.imsupporting.com/getcodeindex.php?siteid=$randnum To get your website code<br>";
$messageee .= "<br>Regards, <br>IMsupporting.com";
$messageee .= "</body></html>";

send_email("TX Fluorescent <danielg@fleco.com>", "$email", 
$subject , 
$messageee);
?>

<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>


<div id="container">
<div id="header">
  
  <div id="logo"><a href="index.html"><img src="images/TxFluorescentslogo.jpg" border="0" /></a></div><h1>Texas Fluorescents - Fluorescent Lighting</h1><ul><li><a href="contact_us.html">Contact</a></li><li><a href="comingsoon.html">FAQ   |   </a></li><li><a href="comingsoon.html">Sitemap    |   </a></li><li><a href="comingsoon.html">Support   |   </a></li></ul></div><div id="subhead">your source for quality lighting</div><div id="phone">800-232-7407</div>

<div id="contain">
<div id="nav">
<ul>
<li><a href="index.html">HOME       |</a></li>
<li><a href="companyprofile.html">COMPANY       |</a></li>
<li><a href="products.html">PRODUCTS       |</a></li>
<li><a href="distributorlogin.html">DISTRIBUTOR       |</a></li>
<li><a href="internet_promotions.html">PROMOTIONS       |</a></li>
<li><a href="sales_representatives.html">FIND SALES REP       |</a></li>
<li><a href="contact_us.html">CONTACT US</a></li>
</ul>
</div>
<div id="main"></div>
<div class="beneath">
<div class="specification"><a href="downloadcenter.html"><img src="images/specification-download-center.jpg" border="0" /></a></div>
<div class="retrofitnew"><a href="retrofit.html"><img src="images/retrofit-center.jpg" border="0" /></a></div>
<div class="signup"><a href="internet_promotions.html"><img src="images/signup-now.jpg" border="0" /></a></div>
<div class="quote"><a href="request-quote.html"><img src="images/request-quote.jpg" border="0" /></a></div>
</div>
</div>


<div class="left_pan">

    <ul>
                <span class="style66">  PRODUCTS</span>
	<li><a href="hibay-fluorescents.html">HiBay Fluorescents</a></li>
        <li><a href="linear-pendant-fluorescents.html">Linear Pendant Fluorescents</a></li>
        <li><a href="recessed-fluorescents.html">Recessed Fluorescents</a></li>
        <li><a href="retrofit_refit_kits.html">Retrofit Kits</a></li>
        <li><a href="surfacemounts.html">Surface Fluorescents</a></li>
        <li><a href="wraparounds.html">Wraparounds</a></li>
        <li><a href="fluorescentstrips.html">Fluorescent Strips</a></li>
        <li><a href="closetoceilingCFL.html">Close-to-Ceiling - CFL</a></li>
        <li><a href="wallfixtures.html">Wall Fluorescents</a></li>
        <li><a href="wallpacks.html">HID Wall Packs</a></li>
        <li><a href="floodlights.html">HID Flood Lights</a></li>
        <li><a href="HighBays.html">HID High Bays</a></li>
        <li><a href="comingsoon.html">HID Vandaliers</a></li>
        <li><a href="Essentials.html">Essentials</a></li>
        <li><a href="RecessedDownlights.html">Recessed Downlights</a></li>
        <li><a href="exit_emergency.html">Exit & Emergency Lighting</a></li>
        <li><a href="Ballast_Transformers.html">Ballast & Transformers</a></li>
        <li><a href="NeptunDimmableCFLs.html">Fluorescent Lamps</a></li>
        <li><a href="comingsoon.html">LED Lighting</a></li>
      </ul><ul><span class="style66">  SUPPORT</span> 
            <li><a href="feedback.html">Feedback Form</a></li>
             <li><a href="comingsoon.html">Instruction Sheets</a></li>
             <li><a href="customerservice.html">Customer Service</a></li>
             <li><a href="salesdepartment.html">Sales Department</a></li>
             <li><a href="technicalsupport.html">Technical Support</a></li>
             <li><a href="productinquiry.html">Product Inquiry</a></li>
             <li><a href="comingsoon.html">Returns</a><br />
  </li>
      </ul>
</div>
            
<div class="content">
<h2>Register for Distributor Area</h2>
<p>Please fill out the following form to get your login information to access our distributor area. If you do not know your rep number please contact us at 214-884-1162.</p>
<div class="catagory">
  <div class="green25"><form action="registered-distributors.php" method="post" name="form1" class="dress"><br /><br /><br /><br />
            <label for="repnumber"><span class="algin"><span class="login">Rep Number</span></span></label>
          <input name="repnumber" type="text" class="rep" size="5" />
<br />
            <label for="fname"><span class="algin"><span class="login">First Name</span></span></label>
            <input name="fname" type="text" class="field" />
          <br>
            <label for="lname" class="li1"><span class="algin"><span class="login">Last Name</span></span></label>
            <input name="lname" type="text" class="field" />
          <br>
            <label for="cname"><span class="algin"><span class="login">Company Name</span></span></label>
            <input name="cname" type="text" class="field" />
          <br>
            <label for="phone"><span class="algin"><span class="login">Phone Number</span></span></label>
            <input name="phone" type="text" class="field" />
          <br>
            <label for="email"><span class="algin"><span class="login">Email Address</span></span></label>
          <input name="email" type="text" class="field" />
          <br>
            <span class="formtext">You will use your email address as your username            </span>
            <br><br><label for="password"><span class="algin"><span class="login">Password</span></span></label>
          <input name="pass" type="password" class="field" />
          <br>
            <label for="password" class="login"><span class="algin">Verify Password</span></label>
        <input name="pass2" type="password" class="field" /><br><br />
            <input type="image" src="images/register-button.jpg" class="login-submit" value="Regsiter"/>
            
          <br>
            <br>
  <br />
	    <br />
	    <br />
	    <br />
        <br />
	    <br />
  </form>
   
   
  </div>
  <div class="green30">

  </div>
  <div id="green30">
   
  </div>
</div>
</div>

</div>
<div class="footer"><img src="images/TX-Fluorescent-Footer-Image.gif" />
<p align="center">© Copyright 2009 Texas Fluorescents All Rights Reserved. Developed by <a href="http://www.wired2design.com" target="_blank">WIRED2DESIGN</a> Studios</p></div>
</body>
</html>

Link to comment
Share on other sites

Here is the page they go to once they register:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Distributor Login - Go Where the Business Is!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="description" CONTENT="Texas Fluroescents' is a manufacturer of energy efficient linear pendant fluorescent lighting fixtures specifically T5 Industrial Fluorescent Lighting Fixtures, T8 Industrial Fluorescent Lighting Fixtures and T5HO Industrial Fluorescent Lighting Fixtures for industrial lighting, production floor lighting, warehouse lighting.">

<meta NAME="keywords" CONTENT="fluorescent lighting fixtures, T5 Industrial Fluorescent lighting fixtures, T5HO industrial fluorescent lighting fixtures, T8 industrial fluorescent lighting fixtures, T5 warehouse lighting fixtures, T5 warehouse fluorescent lighting fixtures">

<meta NAME="robots" CONTENT="index,follow">



<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<?php

$email = $_POST['email'];
$password = $_POST['pass'];
$password2 = $_POST['pass2'];

@mysql_connect("205.178.146.75","fleco2008","xxxxxx") or die("Error: unable to connect to database");
@mysql_select_db("test09");

$result = mysql_query("SELECT * FROM `loginreg` WHERE `email`='$email'");
if (mysql_num_rows($result) != 0) {
die("Another account is already using that email");
}
if ($password != $password2) {
die("The two passwords did not match");
}
$password = md5($password);
mysql_query("INSERT INTO `loginreg` (`email`, `password`, `fname`, `lname`, `repnumber`, `cname`, `phone`) VALUES ('$email', '$password', '$fname', '$lname', '$repnumber', '$cname', '$phone')") or die(mysql_error());
echo "";

?>

</head>


<div id="container">
<div id="header">
  
  <div id="logo"><a href="index.html"><img src="images/TxFluorescentslogo.jpg" border="0" /></a></div><h1>Texas Fluorescents - Fluorescent Lighting</h1><ul><li><a href="contact_us.html">Contact</a></li><li><a href="comingsoon.html">FAQ   |   </a></li><li><a href="comingsoon.html">Sitemap    |   </a></li><li><a href="comingsoon.html">Support   |   </a></li></ul></div><div id="subhead">your source for quality lighting</div><div id="phone">800-232-7407</div>

<div id="contain">
<div id="nav">
<ul>
<li><a href="index.html">HOME       |</a></li>
<li><a href="companyprofile.html">COMPANY       |</a></li>
<li><a href="products.html">PRODUCTS       |</a></li>
<li><a href="distributorlogin.html">DISTRIBUTOR       |</a></li>
<li><a href="internet_promotions.html">PROMOTIONS       |</a></li>
<li><a href="sales_representatives.html">FIND SALES REP       |</a></li>
<li><a href="contact_us.html">CONTACT US</a></li>
</ul>
</div>
<div id="main"></div>
<div class="beneath">
<div class="specification"><a href="downloadcenter.html"><img src="images/specification-download-center.jpg" border="0" /></a></div>
<div class="retrofitnew"><a href="retrofit.html"><img src="images/retrofit-center.jpg" border="0" /></a></div>
<div class="signup"><a href="internet_promotions.html"><img src="images/signup-now.jpg" border="0" /></a></div>
<div class="quote"><a href="request-quote.html"><img src="images/request-quote.jpg" border="0" /></a></div>
</div>
</div>


<div class="left_pan">

    <ul>
                <span class="style66">  PRODUCTS</span>
	<li><a href="hibay-fluorescents.html">HiBay Fluorescents</a></li>
        <li><a href="linear-pendant-fluorescents.html">Linear Pendant Fluorescents</a></li>
        <li><a href="recessed-fluorescents.html">Recessed Fluorescents</a></li>
        <li><a href="retrofit_refit_kits.html">Retrofit Kits</a></li>
        <li><a href="surfacemounts.html">Surface Fluorescents</a></li>
        <li><a href="wraparounds.html">Wraparounds</a></li>
        <li><a href="fluorescentstrips.html">Fluorescent Strips</a></li>
        <li><a href="closetoceilingCFL.html">Close-to-Ceiling - CFL</a></li>
        <li><a href="wallfixtures.html">Wall Fluorescents</a></li>
        <li><a href="wallpacks.html">HID Wall Packs</a></li>
        <li><a href="floodlights.html">HID Flood Lights</a></li>
        <li><a href="HighBays.html">HID High Bays</a></li>
        <li><a href="comingsoon.html">HID Vandaliers</a></li>
        <li><a href="Essentials.html">Essentials</a></li>
        <li><a href="RecessedDownlights.html">Recessed Downlights</a></li>
        <li><a href="exit_emergency.html">Exit & Emergency Lighting</a></li>
        <li><a href="Ballast_Transformers.html">Ballast & Transformers</a></li>
        <li><a href="NeptunDimmableCFLs.html">Fluorescent Lamps</a></li>
        <li><a href="comingsoon.html">LED Lighting</a></li>
      </ul><ul><span class="style66">  SUPPORT</span> 
            <li><a href="feedback.html">Feedback Form</a></li>
             <li><a href="comingsoon.html">Instruction Sheets</a></li>
             <li><a href="customerservice.html">Customer Service</a></li>
             <li><a href="salesdepartment.html">Sales Department</a></li>
             <li><a href="technicalsupport.html">Technical Support</a></li>
             <li><a href="productinquiry.html">Product Inquiry</a></li>
             <li><a href="comingsoon.html">Returns</a><br />
  </li>
      </ul>
</div>
            
<div class="content">
<h2>Thank you for registering.</h2>
<p>Thank you for registering with Texas Fluorescents as a Distributor. Please login below using the information from when you registered. You will find great resources and pricing as well.</p>
<div class="catagory">
  <div class="green25"><form action='distributor-area.php' method='post' class="dress"><br /><br /><br /><br />
      <span class="login">Email:</span><br /> <input name='email' type='text' class="input" size="20"><br><br />
      <span class="login">Password:</span><br /> <input name='pass' type='password' class="input"><br><br>
      <input type='image' src="images/login.jpg" value='Login' class="login-submit">
      <br />
      <br>
      <a href="#">Forgot Password?</a><br />
      <a href="register.php">Register Now </a><br />
      <br />
<br>
        </form>
   
   
  </div>
  <div class="green30">
    <img src="images/distributor.jpg"/>
     <img src="images/hot-sheets.jpg"/>
  </div>
  <div id="green30">
   
  </div>
</div>
</div>

</div>
<div class="footer"><img src="images/TX-Fluorescent-Footer-Image.gif" />
<p align="center">© Copyright 2009 Texas Fluorescents All Rights Reserved. Developed by <a href="http://www.wired2design.com" target="_blank">WIRED2DESIGN</a> Studios</p></div>
</body>
</html>

Link to comment
Share on other sites

and your email is not sending right? try making your from email address just the static address, not with the name information and stuff like that. Im not sure whether or not the mail function will accept a to address that is like that, and that may be screwing up the headers

 

send_email("danielg@fleco.com", "$email", 
   $subject , 
   $messageee);
   ?>

 

and have your function echo an error or something if the mail fails.

Link to comment
Share on other sites

I am trying to put this code in the login script and I keep getting a syntax error:

 

<?php

$result = mysql_query("SELECT * FROM admins where username = '$username' AND password = '$password'");

while($row = mysql_fetch_array($result))
  {
   $active = $row['active'];

if ($active == "0" { //here is where i am getting the syntax error
     $error = "1";
}}

// then if error = 1 show them a SORRY not active page , you cant login.

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.