Jump to content

user login combine with second table PHP for user to list mutiple entries


ET

Recommended Posts

I would appreciate your assistance, there are tons of login scripts and they work just fine. However I need my operators to login and then list their activities for the other operators who are logged in to see and if desired send their clients on the desired activity. I have the login working like a charm and the activities are listed just beautifully. How do I combine the two tables in the MySQL with PHP so the operator Logged in can only make changes to his listing but see the others.

 

FIRST THE ONE script the member logges in here to the one table in MSQL:

<?php

session_start();

 

require_once('config.php');

 

$errmsg_arr = array();

 

$errflag = false;

 

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

if(!$link) {

die('Failed to connect to server: ' . mysql_error());

}

 

$db = mysql_select_db(DB_DATABASE);

if(!$db) {

die("Unable to select database");

}

 

function clean($str) {

$str = @trim($str);

if(get_magic_quotes_gpc()) {

$str = stripslashes($str);

}

return mysql_real_escape_string($str);

}

 

$login = clean($_POST['login']);

$password = clean($_POST['password']);

 

if($login == '') {

$errmsg_arr[] = 'Login ID missing';

$errflag = true;

}

if($password == '') {

$errmsg_arr[] = 'Password missing';

$errflag = true;

}

 

if($errflag) {

$_SESSION['ERRMSG_ARR'] = $errmsg_arr;

session_write_close();

header("location: login-form.php");

exit();

}

 

$qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'";

$result=mysql_query($qry);

 

if($result) {

if(mysql_num_rows($result) == 1) {

session_regenerate_id();

$member = mysql_fetch_assoc($result);

$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];

$_SESSION['SESS_FIRST_NAME'] = $member['firstname'];

$_SESSION['SESS_LAST_NAME'] = $member['lastname'];

session_write_close();

header("location: member-index.php");

exit();

}else {

header("location: login-failed.php");

exit();

}

}else {

die("Query failed");

}

?>

 

.................................................................................

Now I need the person who logged in to the table above to be able to make multiple entries to the table below

 

<?

$ID=$_POST['ID'];

$title=$_POST['title'];

$cost=$_POST['cost'];

$activity=$_POST['activity'];

$ayear=$_POST['aday'];

$aday=$_POST['ayear'];

$seats=$_POST['special'];

$special=$_POST['seats'];

mysql_connect("xxxxxx", "xxx350234427", "========") or die(mysql_error());

mysql_select_db("xxxx") or die(mysql_error());

mysql_query("INSERT INTO `activity` VALUES ('ID','$title', '$cost','$activity', '$aday', '$ayear', '$special', '$seats')");

Print "Your information has been successfully added to the database!"

?>

Click <a href="member-profile.php">HERE</a> to return to the main menu

  <?php

?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.