Here's my footer.php:
Code: Select all
<?php
if(empty($_SESSION['user_name'])) {
die('<div id="login"><form name="login"
method="post" action="validate.php">
username:<input type="text" name="user_name"><br>
password:<input type="password" name="password"><br>
<input type="submit" value="submit">
</form>An error has ocurred. It may be that you have not
logged in, or that your session has expired. Please try <a href="login.php">logging in</a> again or contact the <a href="mailto:admin@example.com">system administrator</a></div>');
}
else
{
print "Welcome $user_name";
}
?>Code: Select all
<?php
$db_user = 'mysql_username';
$db_pass = 'mysql_password';
$user_name = $_POSTї'user_name'];
$password = $_POSTї'password'];
//connect to the DB and select the "e;login"e; database
$connection = mysql_connect('host','user','pass') or die(mysql_error());
mysql_select_db('database', $connection) or die(mysql_error());
//set up the query
$query = "e;SELECT * FROM users
WHERE user_name='$user_name' AND password='$password'"e;;
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making query');
$affected_rows = mysql_num_r everything static on my page. Now it seems that the session variables aren't registering, it shows me logged in when I'm at the validation page but once I go back to the index it's just asking me to log back in.
Here's my footer.php:Code: Select all
<?php
if(empty($_SESSION['user_name'])) {
die('<div id="e;login"e;><form name="e;login"e;
method="e;post"e; action="e;validate.php"e;>
username:<input type="e;text"e; name="e;user_name"e;><br>
password:<input type="e;password"e; name="e;password"e;><br>
<input type="e;submit"e; value="e;submit"e;>
</form>An error has ocurred. It may be that you have not
logged in, or that your session has expired. Please try <a href="e;login.php"e;>logging in</a> again or contact the <a href="e;mailto:admin@example.com"e;>system administrator</a></div>');
}
else
{
print "e;Welcome $user_name"e;;
}
?>Code: Select all
<?php
$db_user = 'mysql_username';
$db_pass = 'mysql_password';
$user_name = $_POSTї'user_name'];
$password = $_POSTї'password'];
//connect to the DB and select the "e;login"e; database
$connection = mysql_connect('host','user','pass') or die(mysql_error());
mysql_select_db('database', $connection) or die(mysql_error());
//set up the query
$query = "e;SELECT * FROM users
WHERE user_name='$user_name' AND password='$password'"e;;
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making query');
$affected_rows = mysql_num_rows($result);
$_SESSIONї'affected_rows'] = $affected_rows;
//if there's exactly one result, the user is validated. Otherwise, he's invalid
if($affected_rows == 1) {
print 'validated';
//add the user to our session variables
$_SESSIONї'user_name'] og back in.
Here's my footer.php:Code: Select all
<?php
if(empty($_SESSION['user_name'])) {
die('<div id="e;login"e;><form name="e;login"e;
method="e;post"e; action="e;validate.php"e;>
username:<input type="e;text"e; name="e;user_name"e;><br>
password:<input type="e;password"e; name="e;password"e;><br>
<input type="e;submit"e; value="e;submit"e;>
</form>An error has ocurred. It may be that you have not
logged in, or that your session has expired. Please try <a href="e;login.php"e;>logging in</a> again or contact the <a href="e;mailto:admin@example.com"e;>system administrator</a></div>');
}
else
{
print "e;Welcome $user_name"e;;
}
?>Code: Select all
<?php
$db_user = 'mysql_username';
$db_pass = 'mysql_password';
$user_name = $_POSTї'user_name'];
$password = $_POSTї'password'];
//connect to the DB and select the "e;login"e; database
$connection = mysql_connect('host','user','pass') or die(mysql_error());
mysql_select_db('database', $connection) or die(mysql_error());
//set up the query
$query = "e;SELECT * FROM users
WHERE user_name='$user_name' AND password='$password'"e;;
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making query');
$affected_rows = mysql_num_rows($result);
$_SESSIONї'affected_rows'] = $affected_rows;
//if there's exseems that the session variables aren't registering, it shows me logged in when I'm at the validation page but once I go back to the index it's just asking me to log back in.
Here's my footer.php:Code: Select all
<?php
if(empty($_SESSION['user_name'])) {
die('<div id="login"e;><form name="e;login"e;
method="e;post"e; action="e;validate.php"e;>
username:<input type="e;text"e; name="e;user_name"e;><br>
password:<input type="e;password"e; name="e;password"e;><br>
<input type="e;submit"e; value="e;submit"e;>
</form>An error has ocurred. It may be that you have not
logged in, or that your session has expired. Please try <a href="e;login.php"e;>logging in</a> again or contact the <a href="e;mailto:admin@example.com"e;>system administrator</a></div>');
}
else
{
print "e;Welcome $user_name"e;;
}
?>Code: Select all
<?php
$db_user = 'mysql_username';
$db_pass = 'mysql_password';
$user_name = $_POSTї'user_name'];
$password = $_POSTї'password'];
//connect to the DB and select the "e;login"e; database
$connection = mysql_connect('host','user','pass') or die(mysql_error());
mysql_select_db('database', $connection) or die(mysql_error());
//set up the query
$query = "e;SELECT * FROM users
WHERE user_name='$user_name' AND password='$password'"e;;
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making query');
$affecte a generic template using PHP includes for everything static on my page. Now it seems that the session variables aren't registering, it shows me logged in when I'm at the validation page but once I go back to the index it's just asking me to log back in.
Here's my footer.php:Code: Select all
<?php
if(empty($_SESSIONї'user_name'])) {
die('<div id="e;login"e;><form name="e;login"e;
method="e;post"e; action="e;validate.php"e;>
username:<input type="e;text"e; name="e;user_name"e;><br>
password:<input type="e;password"e; name="e;password"e;><br>
<input type="e;submit"e; value="e;submit"e;>
</form>An error has ocurred. It may be that you have not
logged in, or that your session has expired. Please try <a href="e;login.php"e;>logging in</a> again or contact the <a href="e;mailto:admin@example.com"e;>system administrator</a></div>');
}
else
{
print "e;Welcome $user_name"e;;
}
?>Code: Select all
<?php
$db_user = 'mysql_username';
$db_pass = 'mysql_password';
$user_name = $_POSTї'user_name'];
$password = $_POSTї'password'];
//connect to the DB and select the "e;login"e; database
$connection = mysql_connect('host','user','pass') or die(mysql_error());
mysql_select_db('database', $connection) or die(mysql_error());
//set up the query
$query = "e;SELECT * FROM users
WHERE user_name='$user_name' AND password='$password'"e;;
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making query');
$affected_rows = mysql_num_rows($result);
$_SESSIONї'affected_rows'] = $affected_rows;
//if there's exacin was working until I wanted to make a generic template using PHP includes for everything static on my page. Now it seems that the session variables aren't registering, it shows me logged in when I'm at the validation page but once I go back to the index it's just asking me to log back in.
Here's my footer.php:Code: Select all
<?php
if(empty($_SESSIONї'user_name'])) {
die('<div id="e;login"e;><form name="e;login"e;
method="e;post"e; action="e;validate.php"e;>
username:<input type="e;text"e; name="e;user_name"e;><br>
password:<input type="e;password"e; name="e;password"e;><br>
<input type="e;submit"e; value="e;submit"e;>
</form>An error has ocurred. It may be that you have not
logged in, or that your session has expired. Please try <a href="e;login.php"e;>logging in</a> again or contact the <a href="e;mailto:admin@example.com"e;>system administrator</a></div>');
}
else
{
print "e;Welcome $user_name"e;;
}
?>Code: Select all
<?php
$db_user = 'mysql_username';
$db_pass = 'mysql_password';
$user_name = $_POSTї'user_name'];
$password = $_POSTї'password'];
//connect to the DB and select the "e;login"e; database
$connection = mysql_connect('host','user','pass') or die(mysql_error());
mysql_select_db('database', $connection) or die(mysql_error());
//set up the query
$query = "e;SELECT * FROM users
WHERE user_name='$user_name' AND password='$password'"e;;
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making query');
$affected_rows = mysql_num_rows($result);
$_SESSIONї'affected_rows'] = $affected_rows;
//if there's exactly one result, the user is validated. Oin was working until I wanted to make a generic template using PHP includes for everything static on my page. Now it seems that the session variables aren't registering, it shows me logged in when I'm at the validation page but once I go back to the index it's just asking me to log back in.
Here's my footer.php:Code: Select all
<?php
if(empty($_SESSIONї'user_name'])) {
die('<div id="e;login"e;><form name="e;login"e;
method="e;post"e; action="e;validate.php"e;>
username:<input type="e;text"e; name="e;user_name"e;><br>
password:<input type="e;password"e; name="e;password"e;><br>
<input type="e;submit"e; value="e;submit"e;>
</form>An error has ocurred. It may be that you have not
logged in, or that your session has expired. Please try <a href="e;login.php"e;>logging in</a> again or contact the <a href="e;mailto:admin@example.com"e;>system administrator</a></div>');
}
else
{
print "e;Welcome $user_name"e;;
}
?>Code: Select all
<?php
$db_user = 'mysql_username';
$db_pass = 'mysql_password';
$user_name = $_POSTї'user_name'];
$password = $_POSTї'password'];
//connect to the DB and select the "e;login"e; database
$connection = mysql_connect('host','user','pass') or die(mysql_error());
mysql_select_db('database', $connection) or die(mysql_error());
//set up the query
$query = "e;SELECT * FROM users
WHERE user_name='$user_name' AND password='$password'"e;;
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making query');
$affected_rows = mysql_num_rows($result);
$_SESSIONї'affected_rows'] = $affected_rows;
//if there's exactly one result, the user is validated. Otherwise, he's invalid
if($affected_rows == 1) {
print 'static on my page. Now it seems that the session variables aren't registering, it shows me logged in when I'm at the validation page but once I go back to the index it's just asking me to log back in.
Here's my footer.php:Code: Select all
<?php
if(empty($_SESSION['user_name'])) {
die('<div id="login"><form name="login"
method="post" action="validate.php">
username:<input type="text" name="user_name"><br>
password:<input type="password" name="password"><br>
<input type="submit" value="submit">
</form>An error has ocurred. It may be that you have not
logged in, or that your session has expired. Please try <a href="login.php">logging in</a> again or contact the <a href="mailto:admin@example.com">system administrator</a></div>');
}
else
{
print "Welcome $user_name";
}
?>Here's my footer.php:
Code: Select all
<?php
if(empty($_SESSION['user_name'])) {
die('<div id="login"><form name="login"
method="post" action="validate.php">
username:<input type="text" name="user_name"><br>
password:<input type="password" name="password"><br>
<input type="submit" value="submit">
</form>An error has ocurred. It may be that you have not
logged in, or that your session has expired. Please try <a href="login.php">logging in</a> again or contact the <a href="mailto:admin@example.com">system administrator</a></div>');
}
else
{
print "Welcome $user_name";
}
?>Code: Select all
<?php
$db_user = 'mysql_username';
$db_pass = 'mysql_password';
$user_name = $_POSTї'user_name'];
$password = $_POSTї'password'];
//connect to the DB and select the "e;login"e; database
$connection = mysql_connect('host','user','pass') or die(mysql_error());
mysql_select_db('database', $connection) or die(mysql_error());
//set up the query
$query = "e;SELECT * FROM users
WHERE user_name='$user_name' AND password='$password'"e;;
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making query');
$il I wanted to make a generic template using PHP includes for everything static on my page. Now it seems that the session variables aren't registering, it shows me logged in when I'm at the validation page but once I go back to the index it's just asking me to log back in.
Here's my footer.php:Code: Select all
<?php
if(empty($_SESSIONї'user_name'])) {
die('<div id="login"><form name="e;login"e;
method="e;post"e; action="validate.php">
username:<input type="text" name="user_name"><br>
password:<input type="e;password"e; name="e;password"e;><br>
<input type="e;submit"e; value="e;submit"e;>
</form>An error has ocurred. It may be that you have not
logged in, or that your session has expired. Please try <a href="e;login.php"e;>logging in</a> again or contact the <a href="e;mailto:admin@example.com"e;>system administrator</a></div>');
}
else
{
print "e;Welcome $user_name"e;;
}
?>Code: Select all
<?php
$db_user = 'mysql_username';
$db_pass = 'mysql_password';
$user_name = $_POST['user_name'];
$password = $_POST['password'];
//connect to the DB and select the "login" database
$connection = mysql_connect('host','user','pass') or die(mysql_error());
mysql_select_db('database', $connection) or die(mysql_error());
//set up the query
$query = "SELECT * FROM users
WHERE user_name='$user_name' AND password='$password'";
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making query');
$affected_rows = mysql_num_rows($resul
<?php
if(empty($_SESSION['user_name'])) {
die('<div id="login"><form name="login"
method="post" action="validate.php">
username:<input type="text" name="user_name"><br>
password:<input type="password" name="password"><br>
<input type="submit" value="submit">
</form>An error has ocurred. It may be that you have not
logged in, or that your session has expired. Please try <a href="login.php">logging in</a> again or contact the <a href="mailto:admin@example.com">system administrator</a></div>');
}
else
{
print "Welcome $user_name";
}
?>Code: Select all
<?php
$db_user = 'mysql_username';
$db_pass = 'mysql_password';
$user_name = $_POST['user_name'];
$password = $_POST['password'];
//connect to the DB and select the "login" database
$connection = mysql_connect('host','user','pass') or die(mysql_error());
mysql_select_db('database', $connection) or die(mysql_error());
//set up the query
$query = "SELECT * FROM users
WHERE user_name='$user_name' AND password='$password'";
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making query');
$affected_rows = mysql_num_rows($result);
$_SESSION['affected_rows'] = $affected_rows;
//if there's exactly one result, the user is validated. Otherwise, he's invalid
if($affected_rows == 1) {
print 'validated';
//add the user to our session variables
$_SESSION['user_name'] = $user_name;
}
else {
print 'not valid';
}
?>