if i could understand sessions more.. my site would probably be finished.
but alright,
aside from my css, and the main look of the site, i'll just tell you what my php coding is for each site.. and maybe someone can help me with my problem..
/register.php
-------------------
<?php include("signup.php");?>
/signup.php
-------------------
this page has my table with the register fields [name, lastname, email, password, etc...]
the form action goes to signup_ac.php
/signup_ac.php
-----------------------
this page has all php coding that sends an activation link to the persons email, they click the activation link, the data gets sent from 'temp_members' table, in which is in the members database, and it gets sent to the 'registered_members' table.
so my register ordeal works.
now for the login.
/login.php
--------------
this is another table asking for the users email and password only.
the form action goes to login2.php
/login2.php
-----------------
<?php
include("config.php");
$tbl_name1="registered_members";
$match = "select id from $tbl_name1 where email = '".$_POST['email']."'
and password = '".$_POST['password']."';";
$qry = mysql_query($match)
or die ("Could not match data because ".mysql_error());
$num_rows = mysql_num_rows($qry);
if ($num_rows <= 0) {
echo "Sorry, there is no email $email with the specified password.<br>";
echo "<a href=login.php>Try again</a>";
exit;
} else {
$query = "SELECT * FROM $tbl_name1 WHERE name = '$name'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
session_start();
$_SESSION['email'] = $row['email'];
$_SESSION['name'] = $row['name'];
include("index2.php");
}
?>
index2.php is basically the members area page for now, it will change in the future.
in the above, the following code was never there, but i recently added it to try it out.
$query = "SELECT * FROM $tbl_name1 WHERE name = '$name'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
session_start();
$_SESSION['email'] = $row['email'];
$_SESSION['name'] = $row['name'];
/index2.php
------------------
Welcome: <?php include("logged.php") ;?>
/logged.php
------------------
<?php
session_start();
echo $_SESSION['name']
?>
so basically, when they log in.. it should go to index2.php instead of echoing "login succesfull... and index2.php including logged, and the session starting in login2.php, the session should stay and it should grab 'name' from the members database, and from the registered_members table.. and it should print "Welcome 'users name'"
right?
what am i doing wrong?
what should i fix on what page and what will work for a fact.
i've been trying to fix this for weeks now and i can't get around it.
please help!
thanks!
Tags: