Page 1 of 1
newsletter
Posted: Sat Feb 12, 2005 4:41 pm
by zmurf
hi, i want to log in as admin, get to an area or say admin.php, from where to compose(maybe) send email to the users in my database.
any tips or useful links on this ?????
10x in advance
Posted: Sat Feb 12, 2005 5:32 pm
by bfsog
I dont know what you want help with. If you want to have an admin area, ...
Code: Select all
// login.php
<?php session_start();
header("Cache-control: private"); //IE 6 Fix
include ("connect.php"); // database connection settings in this file
if($_POSTї'username'] || $_POSTї'passw'])
{
if(!get_magic_quotes_gpc())
{
$username = addslashes($_POSTї'username']);
$passw = addslashes($_POSTї'passw']);
}else{
$username = $_POSTї'username'];
$passw = $_POSTї'passw'];
}
$sql="SELECT * FROM users WHERE username='".$username."' AND password='".md5($passw)."'";
$res=mysql_query($sql) or die("Error: ".mysql_error());
if(mysql_num_rows($res)>0)
{
$_SESSIONї'name'] = $username;
header("Location: admin.php");
}
if($username && mysql_num_rows($res)<1){echo "Invalid username or password";}
}
?>
<html>
<head>
<?php
echo"<title>$SiteTitle</title>";
echo"<link rel="stylesheet" href="$cssfile" type="text/css">"
?>
</head>
<body>
<p>Please login:</p>
<form name="form1" method="post" action="<?php echo $PHP_SELF ?>">
<p>
<input type="text" name="username">
Username</p>
<p>
<input type="password" name="passw">
Password
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
// admin.php
<?php
session_start();
header("Cache-control: private");
?>
<html>
<head>
</head>
<body>
<h1 style="font-family: verdana;"><?php echo "$SiteTitle"; ?></h1><br><br>
<p>You are in the admin section</p>
<?php
if (isset($_SESSIONї'name']))
{
echo 'your logged on';
}
else {
echo 'You have to sign in first ';
echo '<a href="login.php" title="Login">Login</a>';
}
?>
that is a basic way of having an admin area.
note in login.php it chekcs the submitted variables against a table, this way you can have more than one user able to log on (good for blogs with multiple authors).
Hope this helps
Posted: Sat Feb 12, 2005 11:37 pm
by d3ad1ysp0rk
Using my psychic powers, I feel as if the next post may revolve around
Warning: main(general.php): failed to open stream: No such file or directory in /var/www/html/user/admin.php on line 3
or maybe
Cannot send headers, output already sent on line 1

uffff
Posted: Sun Feb 13, 2005 4:32 am
by zmurf
sry 4 not making me understood, not the admin area is the problem, i want to compose 1 mail and send it to all the users / email in my data.
Posted: Sun Feb 13, 2005 6:33 am
by d3ad1ysp0rk