Login / Signup System: Database Data Not Switching Tables, After Email

I need help! I wasnt sure whether this should be in PHP or Databas

Page 1 of 1

1 Replies - 3013 Views - Last Post: 14 July 2008 - 01:40 PM Rate Topic: -----

#1 cbgfilms  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 14-July 08

Login / Signup System: Database Data Not Switching Tables, After Email

Posted 14 July 2008 - 12:25 PM

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

Screenshot of what the missing data looks like is attached.

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>

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Login / Signup System: Database Data Not Switching Tables, After Email

#2 Dancia  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 60
  • Joined: 15-June 08

Re: Login / Signup System: Database Data Not Switching Tables, After Email

Posted 14 July 2008 - 01:40 PM

$tbl_name=temp_members_db;

Try this:
$tbl_name='temp_members_db';

I think you forgot ' '

This post has been edited by Dancia: 14 July 2008 - 01:41 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1