Jump to content

Need Help!!!


stem

Recommended Posts

login.php

[code]
<?php
session_start();
session_unset();
session_destroy();
?>
<?
session_start();
require('config.php');
include('mysql.php');
if(isset($_POST['username'])){
$username = $_POST['username'];
$password = md5($_POST['password']);
$getuser = "SELECT * from users WHERE username = '$username' AND password = '$password'";
  $result = mysql_query($getuser) or die (mysql_error());
    $r = mysql_fetch_array($result);
    $qualify = mysql_num_rows($result);
if($qualify > 0){
$_SESSION['username'] = $r['username'];
$_SESSION['ugroup'] = $r['type'];
?>
<head>
<title>Events Login</title>
<META HTTP-EQUIV="Refresh" content="3;url=eventlist.php">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="elder.css" rel="stylesheet" type="text/css" />
</head>
<body>
<p align=center>Please wait... you will now be redirected to your server page.</p>
</body>
</html>
<?
} else {
print '<p align=center>Bad username/password<br>Click <a href="login.php">here</a> to return to login page.';
}
} else {
include('login.html');
}
?>
[/code]


eventlist.php

[code]
<?php
session_start();
require('config.php');
include('mysql.php');
// Check if user is logged in
if(isset($_SESSION['username']) && $_SESSION['ugroup'] == 1){
$self = $_SERVER['PHP_SELF'];
echo "<table width=300 align=center>
      <tr>
      <td colspan=2 align=center>Add event here</td>
      </tr>
      <form action='changes.php' method=POST>
      <tr>
      <td width=100>Host:</td>
      <td width=200><input type=text name=ehost></td>
      </tr>
      <tr>
      <td width=150>Event:</td>
      <td width=250><input type=text name=event></td>
      </tr>
      <tr>
      <td width=150>Place:</td>
      <td width=250><input type=text name=place></td>
      </tr>
      <tr>
      <td colspan=2 align=center><input type=submit name=add value=\"Add Event\"></td>
      </tr>
      </form>
      </table><hr>";
include("elist.php");
} else {
print '<p align=center>Sorry... This is events Staff only Please login <a href="login.php">HERE</a></p>';
}
?>
</html>
[/code]

install.php
[Code]
<?php
if(isset($_POST['submit'])){
// Sql connection here
require('config.php');
include('mysql.php');
$password = md5($_POST['password']);
$sql = "INSERT INTO users SET
        username = '".$_POST['username']."',
        password = '".$password."',
        ugroup = '".$_POST['ugroup']."'";
$res = mysql_query($sql);
if(!$res){
echo "<b>could not insert new user!!</b><br>Error: ".mysql_error()."<br>SQL: ".$sql."<br>Click <a href=\"install.php\">HERE</a> to return to insert page";
} else {
echo "New user entered into database<br>Click <a href=\"install.php\">HERE</a> to return to insert page";
}
} else {
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Sign up</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="<?=$_SERVER['PHP_SELF']?>">
  <table width="143" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <th scope="col">Username:</th>
    </tr>
    <tr>
      <td><label>
        <input type="text" name="username" id="username" />
      </label></td>
    </tr>
    <tr>
      <th>Password:</th>
    </tr>
    <tr>
      <td><label>
        <input type="password" name="password" id="password" />
      </label></td>
    </tr>
    <tr>
      <th>Group:</th>
    </tr>
    <tr>
      <td><label>
        <div align="center">
          <select name="ugroup">
            <option value="1">Admin</option>
            <option value="2">Staff</option>
            <option value="3" selected="selected">Trainee</option>
          </select>
          </div>
      </label>
      </td>
    </tr>
    <tr>
      <td align=center><br><label>
        <input type="submit" name="submit" value="Submit" id="password" />
      </label></td>
    </tr>
  </table>
</form>
<?php
}
?>
</body>
</html>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/31246-need-help/page/2/#findComment-145988
Share on other sites

yes you need to change this on login.php

[code]$_SESSION['username'] = $r['username'];
$_SESSION['ugroup'] = $r['type'];[/code]

to this
[code]$_SESSION['username'] = $r['username'];
$_SESSION['ugroup'] = $r['ugroup'];[/code]

And put the 2 = signs back in and should be all set.

Ray
Link to comment
https://forums.phpfreaks.com/topic/31246-need-help/page/2/#findComment-146027
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.