Ok i am making a new login system and i dont know a lot about variables,
heres my login code:
code:
<?php
session_start();
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
if (isset ($_POST['submit'])) {
if ( (!empty ($_POST['username'])) && (!empty ($_POST['password'])) ) {
if ( ($_POST['username'] == 'moo') && ($_POST['password'] == 'meow') ) {
$_SESSION['Nathan'] = 'Nathan';
echo '<a href="<!--Link goes here-->">Go here</a>';
header ('Location: edit12345.php');
exit();
} else {
echo '<p>Sorry this is not the correct password or username, Go back and try again</p>';
}
} else {
echo '<p>Make sure password/username are correct</p>';
}
} else {
echo '<form action="index.php" method="post">
Username:<input type="text" name="username" size="20" /> <br />
Password:<input type="password" name="password" size="20" /> <br />
<input type="submit" name="submit" value="Log In" />
</form>';
}
?>
and I have tried loads of times to put sessions in there but i have failed
heres the page i want it to deny access to if theres no session/username is wrong.
code:
<?php
session_start();
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
if ($dbc = mysql_connect ('hostname', 'username', 'password')) {
if (!@mysql_select_db ('nathan1')) {
die ('<p>coud not select ' . mysql_error() . '</p>');
}
} else {
die ('<p>could not connect</p>');
}
$query = 'SELECT * FROM blog_entries ORDER
BY date_entered DESC';
if ($r = mysql_query ($query)) {
while ($row = mysql_fetch_array ($r)) {
echo "<h3 align='center'>{$row['title']}</h3><p>Date Entered: {$row['date_entered']}</p><div align='center' style='border: 1px solid white; width: 40%; margin-left: 25%;'>{$row['entry']}</div><br />
<div align='right' style='float: right;'><a href=\"edit_entry.php?id={$row['blog_id']}\">Edit</a></div>
<div align='left' style='float: left;'><a href=\"delete_entry.php?id={$row['blog_id']}\">Delete</a></div>
<hr color='black' />\n";
}
} else {
echo 'MOOOO';
}
mysql_close();
?>
So can you help please
Ill be so greatful! Cheers.
Nathan