I’ve been asked by a client in construction to build a customer login section where each customer will have access to their own set of pdfs (certificates, job specs etc) when they login.
Accounts will be created manually so no real need for a front end registration.
Does anybody know of a script that can handle this?
It’s quite a simple thing to do to be fair, you might as well give it a go - more so if you’re charging to do it…
Essentially, you want something along the lines of…
<?php
if('POST' === $_SERVER['REQUEST_METHOD']){
#connect to database
$con = mysqli_connect('localhost', 'username', 'password', 'database', 3306);
#check if connect properly
if(false === is_resource($con)){
die('Cannot connect to database.');
}
#create list
$files = array();
#execute query
$res = mysql_query(
sprintf(
"SELECT name, path FROM files WHERE client_id = (SELECT id FROM clients WHERE username = '%s' AND password = '%s')",
mysqli_real_escape_string($con, (string)$_POST['username']),
mysqli_real_escape_string($con, (string)$_POST['password'])
)
);
#check if query executed
if(false === is_resource($res)){
die('Cannot query database.');
}
#build list
while($file = mysqli_fetch_assoc($res)){
array_push($files, $file);
}
#print list
foreach($files as $file){
printf('<a href="%s">%s</a><br />', $file['path'], $file['name']);
}
}
?>
Ha! You’re talking to a front-end guy who is always comforted by the sight of an install.php
I think I get what you are saying but I could spend hours my boss wouldn’t give me trying to figure stuff out if I went solo on this one.
system
February 13, 2010, 10:43am
4
Well, you choose wrong forum to post then.
“Scripts and Online Services” or Marketplace section would be more suitable.
This section merely discuss how to make scripts, not how to find them
Fair enough. Apologies for the mistake.