View Full Version : Sitewide Registration
WebStyles
Wed 26th Apr '00, 1:12pm
Well, we've got this great board now, and I'm just getting started rewriting our other scripts to integrate with the registration. I had everything working great with the UBB since all the scripts were in perl, so they were much easier to integrate with each other. Unfortunately, I don't have any knowledge of php (yet), I know what quotemeta does, and that's about it. ;)
What I'm really stuck on is how to grab the username info from the mySQL database and verify it with the password in perl, I found this tutorial (http://www.thescripts.com/perl/tutorials/perlandmysql/) from thescripts.com, but it said I needed all kinds of modules. I was just wondering if there was an easy way of doing this. If there are any perl/php gurus that could help a poor girl out, I would appreciate it! :D
wandrer
Wed 26th Apr '00, 9:54pm
As soon as I get payment from clients, I'll grab a copy of the code and begin working on it... Never really liked perl, but I LOVE PHP... And the first thing I need to write is an Active Topics type program if anyone hasn't already done it...
Menno
Thu 27th Apr '00, 1:25am
That would be nice. And what about a program (or code) that lets you see vB info on other pages of one's site? :)
bigsoccer tech
Tue 2nd May '00, 10:11pm
is it possible to create a standard sort of api for authenticating users against the vb db. that way you can have any other prog or script on your site access that api for authentication as well as registration.
H
WebStyles
Tue 2nd May '00, 11:54pm
I actually have figured it out since I posted this Huss. Here's the code I used:
----------------------------------------
function process_form($action){
global $username,$password;
// Make sure neither $username or $password is left blank
if (empty($username) || empty($password)){
echo "You must fill out both the username, and password fields";
} else {
mysql_connect("hostname", "username", "password") or die ("Unable to connect to database.");
// select database on MySQL server
mysql_select_db("forum") or die ("Unable to select database.");
// Store the query in $sql
$sql = "SELECT *
FROM user
WHERE username='$username' and password='$password'";
// Execute the query and put results in $result
$result = mysql_query($sql);
// Get number of rows in $result. 0 if invalid, 1 if valid.
$num = mysql_numrows($result);
if ($num >= "1") {
echo "You're Authorized!";
exit;
} else {
echo "Invalid Username/Password";
exit;
}
}
}
----------------------------------------
Way easier than in perl! Also note that this is my very first PHP script, so there may be mistakes in there. :D
bigsoccer tech
Thu 11th May '00, 1:28am
can you give a url where you use this?
thanks,
j
WebStyles
Thu 11th May '00, 2:00am
Well, I was using it for all the functions that required a password on http://www.were-here.com (in the Career Center and Flash Directory mostly), but then we finally got the DBI module for perl installed, so I rewrote it in perl, put it back in the form and eliminated the extra login script.
I haven't deleted the old login script off of the server yet so you can test it out here (http://www.were-here.com/Talent/login.php) if you want. :)
bigsoccer tech
Thu 11th May '00, 2:12am
can you post the entire login.php code, or is that it above?
WebStyles
Thu 11th May '00, 4:35am
There's one more function that displays the form, then some code that decides whether to display the form or process it. This code goes below the code that I gave before:
----------------------------
function display_form() {
global $PHP_SELF,$username,$password;
?>
<p> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Please
enter your username and password below. If you aren't already a
member, <a href="http://www.were-here.com/forums/member.php?action=signup">sign
up now</a>! It's free and easy.</font></p>
<form method="post" action="<?php $PHP_SELF; ?>">
<table border=0 cellspacing=2 cellpadding=2 align="center">
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Username:</font></td>
<td><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
<input type="text" name="username" size="25" maxlength="25"> <a href="http://www.were-here.com/forums/member.php?action=signup">Want to register?</a></font></td>
</tr>
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Password:</font></td>
<td><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
<input type="password" name="password" size="13" maxlength="13"> <a href="http://www.were-here.com/forums/member.php?action=lostpw">Forgotten your password?</a></font></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="Login" value="Login"></td>
</tr>
</table>
</form>
<?php
}
if (empty($Login)) {
display_form();
} else {
process_form(); }
?>
----------------------------
Just put all that code where you want the form to be in a regular HTML page (with a php extension of course :)).
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.