Jump to content

Login / Signup System: DB Data Not Switching Tables, After Email Being Verified.


chazaaaXD

Recommended Posts

Hello I have a website www.europeanteens.byethost17.com

and if you navigate to the ‘Members’ page you'll see the login system, and if you click ‘Not a member? Signup now!’ It'll take you to the registration page.

I'm running into a few problems, basically what’s suppose to happen is when people signup it sends their info to a temporary database, then after they’ve verified their email their removed from the temporary table, and moved into the actual members table.

 

But you see, when someone gets put into the temp_members table I see all their information, that’s all good. But when they verify their email, and put into the members table all their information is blank, except from the id, username, and password. Although the username is displayed as my MySQL username instead of the username I inputted.

Here are some details to note:

My database is called b17_2102460_members, and the tables in it are called, members, and temp_members.

Here is the tutorial I followed: http://phpeasystep.com/phptu/24.html

 

and here are the codes for all of the pages, I CENSORED the passwords.

 

Signup.php

<form action="signup_ac.php" method="post" name="form1" id="form1">
                      <table width="100%" border="1" cellpadding="0" cellspacing="4" bordercolor="#000033">
                        <tr>
                          <td colspan="3" bgcolor="#000033"><span class="style30">Sign up</span></td>
                        </tr>
                        <tr>
                          <td width="76" bgcolor="#000033"><span class="style29">Name</span></td>
                          <td width="3" bgcolor="#000033"><span class="style31">:</span></td>
                          <td width="305" bgcolor="#000033"><input name="name" type="text" id="name" size="30" /></td>
                        </tr>
                        <tr>
                          <td bgcolor="#000033"><span class="style29">E-mail</span></td>
                          <td bgcolor="#000033"><span class="style31">:</span></td>
                          <td bgcolor="#000033"><input name="email" type="text" id="email" size="30" /></td>
                        </tr>
                        <tr>
                          <td bgcolor="#000033"><span class="style29">Password</span></td>
                          <td bgcolor="#000033"><span class="style31">:</span></td>
                          <td bgcolor="#000033"><input name="password" type="password" id="password" size="30" /></td>
                        </tr>
                        <tr>
                          <td bgcolor="#000033"><span class="style29">Country</span></td>
                          <td bgcolor="#000033"><span class="style31">:</span></td>
                          <td bgcolor="#000033"><input name="country" type="text" id="country" size="30" /></td>
                        </tr>
                        <tr>
                          <td bgcolor="#000033"><span class="style29">Username</span></td>
                          <td bgcolor="#000033"><span class="style31">:</span></td>
                          <td bgcolor="#000033"><input name="username" type="text" id="username" size="30" /></td>
                        </tr>
                        <tr>
                          <td bgcolor="#000033"><span class="style29">Profile</span></td>
                          <td bgcolor="#000033"><span class="style31">:</span></td>
                          <td bgcolor="#000033"><textarea name="profile" cols="27" rows="6" id="profile"></textarea></td>
                        </tr>
                        <tr>
                          <td bgcolor="#000033"><span class="style29">What do you love and hate about your country?</span></td>
                          <td bgcolor="#000033"><span class="style31">:</span></td>
                          <td bgcolor="#000033"><textarea name="lovehate" cols="27" rows="4" id="lovehate"></textarea></td>
                        </tr>
                        <tr>
                          <td bgcolor="#000033"><span class="style29">DOB</span></td>
                          <td bgcolor="#000033"><span class="style31">:</span></td>
                          <td bgcolor="#000033"><input name="dob" type="text" id="dob" value="DD/MM/YYYY" size="30" /></td>
                        </tr>
                        <tr>
                          <td bgcolor="#000033"><span class="style31"></span></td>
                          <td bgcolor="#000033"><span class="style31"></span></td>
                          <td bgcolor="#000033"><input type="submit" name="Submit" value="Submit" />
                             
                            <input type="reset" name="Reset" value="Reset" /></td>
                        </tr>
                      </table>
                  </form>

 

Config.php

<?

$host="sql207.byethost17.com"; // Host name
$username="b17_2102460"; // Mysql username
$password="CENSORED"; // Mysql password
$db_name="b17_2102460_members"; // Database name


//Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select DB");

?>

 

Checklogin.php

<?php
$host="sql207.byethost17.com"; // Host name
$username="b17_2102460"; // Mysql username
$password="CENSORED"; // Mysql password
$db_name="b17_2102460_members"; // Database name
$tbl_name="members"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Login was unsuccessful, please try again or contact webmaster.";
}
?>

 

Confirmation.php

<?php
include('config.php');

// Passkey that got from link
$passkey=$_GET['passkey'];

$tbl_name1="temp_members_db";

// Retrieve data from table where row that match this passkey
$sql1="SELECT * FROM $tbl_name1 WHERE confirm_code ='$passkey'";
$result1=mysql_query($sql1);

// If successfully queried
if($result1){

// Count how many row has this passkey
$count=mysql_num_rows($result1);

// if found this passkey in our database, retrieve data from table "temp_members_db"
if($count==1){

while ($rows = mysql_fetch_array($result))
{
   $name=$rows['name'];
   $email=$rows['email'];
   $country=$rows['country'];
   $password=$rows['password'];
   $username=$rows['username'];
   $profile=$rows['profile'];
   $lovehate=$rows['lovehate'];
   $dob=$rows['dob'];
}

$tbl_name2="members";

// Insert data that retrieves from "temp_members_db" into table "members"
$sql2="INSERT INTO $tbl_name2(name, email, password, country, username, profile, lovehate, dob)VALUES('$name', '$email', '$password', '$country', '$username', '$profile', '$lovehate', '$dob')";
$result2=mysql_query($sql2);
}

// if not found passkey, display message "Wrong Confirmation code"
else {
echo "Wrong Confirmation code";
}

// if successfully moved data from table"temp_members_db" to table "members" displays message "Your account has been activated" and don't forget to delete confirmation code from table "temp_members_db"
if($result2){

echo "Your account has been activated";

// Delete information of this user from table "temp_members_db" that has this passkey
$sql3="DELETE FROM $tbl_name1 WHERE confirm_code = '$passkey'";
$result3=mysql_query($sql3);

}

}
?> 

 

Signup_ac.php

<?
include('config.php');

// table name
$tbl_name=temp_members_db;

// Random confirmation code
$confirm_code=md5(uniqid(rand()));

// values sent from form
$name=$_POST['name'];
$email=$_POST['email'];
$country=$_POST['country'];
$password=$_POST['password'];
$username=$_POST['username'];
$profile=$_POST['profile'];
$lovehate=$_POST['lovehate'];
$dob=$_POST['dob'];

// Insert data into database
$sql="INSERT INTO $tbl_name(confirm_code, name, email, password, country, username, profile, lovehate, dob)VALUES('$confirm_code', '$name', '$email', '$password', '$country', '$username', '$profile', '$lovehate', '$dob')";
$result=mysql_query($sql);

// if suceesfully inserted data into database, send confirmation link to email
if($result){

// ---------------- SEND MAIL FORM ----------------

// send e-mail to ...
$to=$email;

// Your subject
$subject="Confirm your EuRoPeAn TeEnS Registration";

// From
$header="from: Charlie <charliebobgordon@hotmail.com>";

// Your message
$message="Hello thanks for signing upto EuRoPeAn TeEnS \r\n";
$message.="Click on this link to activate your account now \r\n";
$message.="http://www.europeanteens.byethost17.com/confirmation.php?passkey=$confirm_code";

// send email
$sentmail = mail($to,$subject,$message,$header);

}

// if not found
else {
echo "Not found your email in our database";
}

// if your email succesfully sent
if($sentmail){
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send Confirmation link to your e-mail address";
}

?>

 

Login form code

<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" bordercolor="#003399" bgcolor="#FFFFFF">

<tr>
<td width="78" bgcolor="#003399"><span class="style33">Username</span></td>
<td width="6" bgcolor="#003399"><span class="style33">:</span></td>
<td width="294" bgcolor="#003399"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td bgcolor="#003399"><span class="style33">Password</span></td>
<td bgcolor="#003399"><span class="style33">:</span></td>
<td bgcolor="#003399"><input name="mypassword" type="password" id="mypassword" /></td>
</tr>
<tr>
<td bgcolor="#003399"><span class="style34"></span></td>
<td bgcolor="#003399"><span class="style34"></span></td>
<td bgcolor="#003399"><input name="Submit" type="submit" value="Login"></td>
</tr>
</table></td>
</form>

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.