hi i wont to change the activatet value of user log in in database example:when i log in in the page the value must change from 0 to 1 any idea

Recommended Answers

All 13 Replies

Member Avatar for diafol

Show your code. Need data structure. What have you tried?

you have change my code in a way that is correct but i have to send you the register code and the login code they are a lot of tell me if i have to send them or not?

Member Avatar for diafol

?
Is this related to a different thread? Apologies if it is - I tend to lose track of who asks fo what.

this is the database:
id
name
username
password
email
date
random
activated is boolean default is as defined 0

this is the register:
<?php
$submit = @$_POST['submit'];
//form data
$fullname = strip_tags (@$_POST['fullname']);
$username = strtolower(strip_tags (@$_POST['username']));
$password= strip_tags(@$_POST['password']);
$repeatpassword = strip_tags(@$_POST['repeatpassword']);
$date =date("Y-m-d");
$email = @$_POST['email'];
if ($submit)
// open database
$connect = mysql_connect("localhost","root","");
mysql_select_db("phplogin");  // select database
$namecheck = mysql_query("SELECT username FROM users WHERE username='$username'");
$count = mysql_num_rows(@$namecheck);
if ($count !=0)
{
die ("Username is already taken!");

}



{
// check for existance
if($fullname&&$username&&$password&&$repeatpassword)
{

if($password==$repeatpassword)
{

//chechk char length of username and fullname
if (strlen($username)>25||strlen ($fullname)>25)
{
echo ("Length of username or fullname is too long!");
}
else
{
//check password length
if(strlen($password)>25||strlen ($password)<6)
{
 echo ("Password must be  between 6 and 25 characters");
}
else
{
//register the user!

//encrypt password
$password = md5($password);
$repeatpassword = md5($repeatpassword);

//generate random number for activation process
$random = rand(23456789,98765432);


$queryreg =mysql_query("
INSERT INTO users VALUES ('','$fullname','$username','$password','$email','$date','$random','0')
");
die ("You have been registered!<a href='index.php'> Return to Login page</a>");

}


}

}
else
 echo ("Your password do nat match!");
}
else
 echo("<b>Please fill in all</b> fields!");


}
?>
this is the login:
<?php
session_start();
$username =@$_POST['username'];
$password =@$_POST['password'] ;
if($username&&$password)
{
$connect = mysql_connect("localhost","root","") or ("Couldn't connect!");
mysql_select_db("phplogin") or die ("Couldn't find db");
$query = mysql_query("Select * FROM users WHERE username='$username'");
$numrow= mysql_num_rows($query);
if ($numrow!=0)
{
while($row = mysql_fetch_assoc($query))
{
$dbusername = @$row['username'];
$dbpassword = @$row['password'];
$acivated = $row=['activated'];

if(@$activated=='0')
{
die("your accoun si not activate.Please check your email!");
}
}
// check to see if they match
if($username==$dbusername&&md5($password)==$dbpassword)
{
  echo("You are in!<a href='member.php'>Click</a>here to enter in member page.");
  @$_SESSION['username']=$username;
  if(@$activated=='0')
{
die("your accoun si not activate.Please check your email!");

}
}
else
    echo ("Incorrect password!");
}
else
     die ("That user doesn't exist!");
}
else
echo ("Please enter a username and a password!");
?>
this is the activated page:
<?php
$connect = mysql_connect("localhost","root","") or ("Couldn't connect!");
mysql_select_db("phplogin") or die ("Couldn't find db");

$id = @$_GET['id'];
$code=@$_GET['code'];
if($id&&$code)
{
$check =mysql_query("SELECT * FROM users WHERE id='$id' AND random='$code'");
$checknum =mysql_num_rows($check);

if($checknum==1)
{
//run a query to activate the account
$acti=mysql_query ("UPDATE users SET activated='1' WHERE id='$id'");
die ("Your account is activated.You may now log in.");


}
else 
 die ("Invalid ID or Activation code.");
}
else 
 die("DATA MISING");

so when i have to log in the value of activated in database have to change from 0 to 1

how about the page prior to reaching the activated page?

ok but explain me the line of codes i have to understand them i am a a biginer let's say like this

Hi andyy121,

Do you have an example of the activation link that the user will receive in their mailbox?

no i dont have becaouse firstly it will change automaticly when i click register and login
so the 0 must be 1 and then is the link if you wont it i will gave you

hey i wont help why i have to wait 5 days for a info help gayiz why so... i dont how to call

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.