newsletter

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zmurf
Forum Newbie
Posts: 10
Joined: Wed Jan 26, 2005 8:15 am
Location: romania
Contact:

newsletter

Post 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
bfsog
Forum Newbie
Posts: 8
Joined: Thu Feb 10, 2005 6:14 am
Location: UK

Post 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&#1111;'username'] || $_POST&#1111;'passw'])
&#123;
   if(!get_magic_quotes_gpc())
   &#123;
   $username = addslashes($_POST&#1111;'username']);
   $passw = addslashes($_POST&#1111;'passw']);
   &#125;else&#123;
   $username = $_POST&#1111;'username'];
   $passw = $_POST&#1111;'passw'];
   &#125;
$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)
 &#123;
$_SESSION&#1111;'name'] = $username;
  header("Location: admin.php");
 &#125;
if($username && mysql_num_rows($res)<1)&#123;echo "Invalid username or password";&#125;
&#125;
?>
<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&#1111;'name']))
&#123;
echo 'your logged on';
&#125;
else &#123;
echo 'You have to sign in first ';
echo '<a href="login.php" title="Login">Login</a>';
&#125;
?>
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
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post 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
:)
zmurf
Forum Newbie
Posts: 10
Joined: Wed Jan 26, 2005 8:15 am
Location: romania
Contact:

uffff

Post 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.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Post Reply