Registration HELP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
NeonKraze
Forum Newbie
Posts: 1
Joined: Wed Nov 30, 2011 12:34 pm

Registration HELP

Post by NeonKraze »

So for some reason when someone registers for my website they aren't imputed into my php users table so when people check there email it and click the activation code it says datas missing.
heres my website to seee for yourself
http://www.thedreamflow.com

Code: Select all

<?php
session_start();

?>
<html>
<head>
<link href="Style_Sheet.css" rel="stylesheet" type="text/css">
</head>
<title>The Dream Flow</title>
<body>
<body STYLE="background-image: url(flow.png)"></body>
<div id="login">
<center>
<?php

echo "<h1>Register</h1>";

$submit = $_POST['submit'];

//form data
$fullname = strip_tags($_POST['fullname']);
$username = strtolower(strip_tags($_POST['username']));
$password =strip_tags($_POST['password']);
$confirmpassword =strip_tags($_POST['confirmpassword']);
$date = date("Y-m-d");
$email = strip_tags($_POST['email']);
if ($submit)
{
   //open database
$connect = mysql_connect("localhost","bagobone_Peter","boomerdog222") or die ("Couldn't connect!");
mysql_select_db("bagobone_phplogin") or die ("couldn't find database!");    

$namecheck = mysql_query("SELECT username FROM users WHERE username='$username'");
$count = mysql_num_rows($namecheck);

if ($count!=0)

{
die('Username already taken');   
}
//check for existance

if($fullname&&$username&&$email&&$password&&$confirmpassword)
{
   
   
if ($password==$confirmpassword)
{
//check char length of username and fullname
if (strlen($username)>25||strlen($fullname)>25)
{
echo "Length of Username or Full Name has reached it's limit";   
}
else
{
//check password length
if (strlen($password)>25||strlen($password)<6)
{
echo "Password must be more then 6 and less then 25";
}
else 
{
//register the user!

$connect = mysql_connect("localhost","bagobone_Peter","boomerdog222") or die ("Couldn't connect!");
mysql_select_db("bagobone_phplogin") or die ("couldn't find database!");    

$namecheck = mysql_query("SELECT username FROM users WHERE username='$username'");
$count = mysql_num_rows($namecheck);

//encrypt password
   $password = md5($password);
   $confirmpassword = md5($confirmpassword);
   
   //open database
   $random = rand(23456789,98765432);
$queryreg = mysql_query("INSERT INTO users VALUES 

('','$fullname','$username','$password','$email','$date','$random','0')

");

//Generate random number for activation




//send acctivation e-mail

$lastid = mysql_insert_id();


//send activation e-mail
$to = $email;
$subject = "Activate your account!";
$headers = "From: admin@thedreamflow.com ";
$server = "gator1716.hostgator.com";

ini_set("SMTP",$server);

$body = "
Hello $fullname,\n\n
You need to activate your account with the link below
http://www.thedreamflow.com/activate.php?id=$lastid&code=$random\n\n
Keep in mind this website is still a work in progress so Don't mind the bugs. I'm hoping to have it up and running in the next few months. any suggestions please email me at, 
bagobone225@gmail.com.

Thanks!
Love, Admin.

";

//function to send email
mail($to, $subject, $body, $headers);
die("you have been registered plesase check your email to activate it");
}
}


   
}
else
   echo "Your passwords do not match.";

   
}
else 
   echo "Please fill in all fields!";
   
}

?>

<form action='register.php' method='POST'>
     <table> 
      <tr>
      <td>
      Your full name:
      </td>
      <td>
      <input type='text' name='fullname' value='<?php echo $fullname; ?>'>
      </td>
      </tr>
       <tr>
      <td>
      Choose a Username:
      </td>
      <td>
      <input type='text' name='username' value='<?php echo $username; ?>'>
      </td>
      </tr>
      <tr>
      <td>
      E-mail:
      </td>
      <td>
      <input type='text' name='email' value='<?php echo $email; ?>'>
      </td>
      </tr>
       <tr>
      <td>
      Choose a Password:
      </td>
      <td>
      <input type='password' name='password'>
      </td>
      </tr>
       <tr>
      <td>
      Confirm Password:
      </td>
      <td>
      <input type='password' name='confirmpassword'>
      </td>
      </tr>
      </table>
      <p>
      <input type='submit' name='submit' value='Register'>
      </center>
        </p>
      </form>
</div>
</body>
</html>
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Registration HELP

Post by social_experiment »

The INSERT query the script is using is incorrect it should be like the one below. If you enter 4 values for example, you need to have 4 corresponding column values or it won't work either

Code: Select all

INSERT INTO table (field1, field2) VALUES ('value1', 'value2')
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply