Jump to content

[SOLVED] Client Area Login Script Help... Please :)


Recommended Posts

OK, I have looked at several options, including

 

Login-Redirect v1.31 FULL

From

http://www.mpdolan.com/login_redirect.htm

 

and

 

phpcollab-2.4

from

http://www.php-collab.com/blog/

 

The problem, They do to much, I want something light weight that does what Login-Redirect does as far as redirecting users after they login to their own pages.

 

so structurally i guess my db would look like this

 

table clients

 

then fields as

 

uid

f_name

l_name

email

phone

u_name

u_pass

client_url

 

then with a php auth script they could log into there account through a form, then be redirected to their own personal page.

on there personal page they would be able to submit work to be down, check on work being down, upload files, download files etc all linked to their uid.

 

I guess my big question is I could most likely get the auth script up and going, could get the user pages set up (unless someone can walk me through being able to automatically create these pages when a user registers) I can set the databases up with no problem.. I am still learning how to upload files to the database, but I think I can even figure that out, what I would need help with is, how would I once the user logs in, automatically redirect them to their specific page?

 

Any help with this would be really apreciated.

 

Thanks..

 

Intodesi

 

 

 

/* SQL stuff here */
$user = $_POST['user'];
$pass = $_POST['pass'];
$sql = "SELECT * FROM `clients` WHERE `u_name`={$user} AND `u_pass`={$pass} LIMIT 1;";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0){
$row = mysql_fetch_assoc($result)
/* Session Data Here */
$_SESSION['is_valid'] = true;
$_SESSION['user'] = $row['u_name'];
$_SESSION['full_name' = $row['f_name'].$row['l_name'];
$_SESSION['uid'] = $row['uid'];
header("location:".$row['client_url']);
}
else{
//redirect them somewhere, or output an error, or whatever
?>

Thanks for the quick reply,

 

I stuck what you wrote in and get this

Parse error: syntax error, unexpected T_VARIABLE in /home/techurch/public_html/zinto/clients/login.php on line 13

 

line 13 would be

 

$_SESSION['is_valid'] = true;

 

any idea's?

<?php
/* SQL stuff here */
$user = $_POST['user'];
$pass = $_POST['pass'];
$sql = "SELECT * FROM `clients` WHERE `u_name`={$user} AND `u_pass`={$pass} LIMIT 1;";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0){
$row = mysql_fetch_assoc($result); /* Forgot the semicolon here */
/* Session Data Here */
$_SESSION['is_valid'] = true;
$_SESSION['user'] = $row['u_name'];
$_SESSION['full_name' = $row['f_name'].$row['l_name'];
$_SESSION['uid'] = $row['uid'];
header("location:".$row['client_url']);
}
else{
//redirect them somewhere, or output an error, or whatever
?>

another I dont understand.. I know, its probably something easy...

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/techurch/public_html/zinto/clients/login.php on line 10

 

 

line 10 is

if (mysql_num_rows($result) > 0){

 

I did fix one error though on line 15 which was this

 

$_SESSION['full_name' = $row['f_name'].$row['l_name'];

 

needed a ] after [full_name'

 

just want you to know I am trying to do some work on my own.

<?php
/* SQL stuff here */
$user = $_POST['user'];
$pass = $_POST['pass'];
$sql = "SELECT * FROM `clients` WHERE `u_name`={$user} AND `u_pass`={$pass};";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0){
$row = mysql_fetch_assoc($result); /* Forgot the semicolon here */
/* Session Data Here */
$_SESSION['is_valid'] = true;
$_SESSION['user'] = $row['u_name'];
$_SESSION['full_name'] = $row['f_name'].$row['l_name'];
$_SESSION['uid'] = $row['uid'];
header("location:".$row['client_url']);
}
else{
//redirect them somewhere, or output an error, or whatever
}
?>

and if that doesn't work, run this code:

<?php
/* SQL stuff here */
$user = $_POST['user'];
$pass = $_POST['pass'];
$sql = "SELECT * FROM `clients` WHERE `u_name`={$user} AND `u_pass`={$pass};";
$result = mysql_query($sql);
$numbers = mysql_num_rows($result);
print $numbers;
?>

If it comes back with errors, that means that the sql is bad, and I wrote that on a hunch on how your stuff is built. If it comes back zero, that explains why as well, because you can't have an array off of no data.  I'm starting to not make sense....maybe I should sleep...........

It all looks good, and I really appreciate the help, I have one test user in the database, and I am pretty sure I am connecting properly.. I will give the new code you wrote a try.. and again I really appreciate your help.

 

Intodesi

Still the same error

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/techurch/public_html/zinto/clients/login.php on line 10

 

for both bits of code you supplied

 

and this is my sql

 

-- Table structure for table `clients`
--

CREATE TABLE `clients` (
  `uid` mediumint( unsigned NOT NULL auto_increment,
  `f_name` varchar(60) NOT NULL,
  `l_name` varchar(60) NOT NULL,
  `c_name` varchar(60) NOT NULL,
  `email` varchar(60) NOT NULL,
  `phone` varchar(60) NOT NULL,
  `u_name` varchar(60) NOT NULL,
  `u_pass` varchar(60) NOT NULL,
  `client_url` varchar(60) NOT NULL,
  PRIMARY KEY  (`uid`),
  UNIQUE KEY `u_name` (`u_name`),
  UNIQUE KEY `client_url` (`client_url`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

Ok not sure what I did, but I got it to work.. i replaced

 

$sql = "SELECT * FROM `clients` WHERE `u_name`={$user} AND `u_pass`={$pass};";

 

with

 

$sql = "SELECT * FROM clients "."WHERE u_name='$_POST[u_name]' "." AND u_pass='$_POST[u_pass]' ";

 

so I guess it all worked out.. you just needed some sleep :)

haha.. no worries, I am sorry I didnt show them to you, and even sorrier i didnt catch them untill now..

 

now for another question.. for the client pages.. how do i restrict access to them unless the user is logged in? the code you wrote redirects just fine, but how can i tell that page to only allow that particular client

 

kinda like this code here

 

<?php

$abs = getcwd();
$viewer = $HTTP_USER_AGENT;

echo "<?php<br><br>
//prevents caching<br>
header(\"Expires: Sat, 01 Jan 2000 00:00:00 GMT\");<br>
header(\"Last-Modified: \".gmdate(\"D, d M Y H:i:s\").\" GMT\");<br>
header(\"Cache-Control: post-check=0, pre-check=0\",false);<br>
session_cache_limiter();<br>
session_start();<br>
<br>";

if (preg_match("/Windows NT/", $viewer))
{
echo "require('$abs\config.php');<br>
<br>
require('$abs\functions.php'); <br>
<br>";
}
else
{
echo "require('$abs/config.php');<br>
<br>
require('$abs/functions.php'); <br>
<br>";
}

echo "
//this is group name or username of the group or person that you wish to allow access to<br>
// - please be advise that the Administrators Groups has access to all pages.<br>
if (allow_access(Administrators) != \"yes\")<br>
{                       <br>
";
if (preg_match("/Windows NT/", $viewer))
{
echo "
include ('$abs\\no_access.html'); <br>
";
}
else
{
echo "include ('$abs/no_access.html'); <br>";
}
echo "
exit;<br>
}<br>
?>";

?>

 

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.