Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 12th, 2001, 11:45 AM
vettracker vettracker is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 0 vettracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb

I am using a perl shopping cart (CommerceSQL)and would like to incorporate a login script into the program. Working similar to Amzon one-click shopping. I just want the user to be able to login and have thier information pulled out of the mysql database and into the check out form. I can get the information using php but I can get it to incorporate the shopping cart info. How can I do this using perl. Here is the code I am using for php how do I convert to use in perl.

<?
$connection = mysql_connect("mysql.xxxx.com","user","password")
or die (mysql_error());
$db = mysql_select_db("database", $connection) or die ("Unable to select database.");


if ($email == "")
{$email = '%';}

if ($password == "")
{$password = '%';}
$result = mysql_query ("SELECT * FROM register
WHERE email = '$email'
AND password = '$password'
");

if ($row = mysql_fetch_array($result)) {

do {
PRINT "<b><font color='green'>First Name:<input type='text' name='name' value='$row[1]'>";
} while($row = mysql_fetch_array($result));
} else {print "Sorry, your order was not found!";}

?>

Thanks

Reply With Quote
  #2  
Old March 12th, 2001, 12:47 PM
dsb dsb is offline
PerlGuy
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2001
Posts: 714 dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 15 h 44 m 20 sec
Reputation Power: 36
Send a message via AIM to dsb
Wink

I'd be glad to help you out except for one problem: That's not Perl. It looks like PHP, which I'm relatively new to, and haven't done any database work with it.

If you are in fact using Perl and you just posted the wrong code, then say so and I'll help you out.

The login happens in the connect. I'll go into more detail if you are using Perl.
__________________
- dsb -
Perl Guy

Reply With Quote
  #3  
Old March 12th, 2001, 01:01 PM
vettracker vettracker is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 0 vettracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sorry if my post was confusing. Yes it is in perl, the code I posted is what I was messing around with the in php just to see if I could acutally get it to get the data I have in my registration table and I was able to. What I really want is to do the same thing in perl.

I am using a perl shopping cart, what I would like to do is when my customer is done shopping he hits a check out button then it brings up a page with in the shopping cart program so they can login by submitting thier email and a password. If the email and password match then it will pull all the information on them that is in the registration table into the check out page.

They can then verify the information and check out.

if you would like to view the shopping cart it is at URL
just don't finalize your order this site is live.

I hope I have made myself a little more clear.

Thanks
Scott

Reply With Quote
  #4  
Old March 12th, 2001, 02:40 PM
dsb dsb is offline
PerlGuy
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2001
Posts: 714 dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 15 h 44 m 20 sec
Reputation Power: 36
Send a message via AIM to dsb
Wink

Let me make sure I'm clear.

The registration table is in a database and you want to connect to that table and check their record of registration for an email/password match. If it matches then you go ahead to the rest of the process.

If that's the case then you could just do a simple SQL query like you are doing in your PHP version.

If you are using their email and password to establish a connection to the database then you are going to have to create an account on the database for them, which is kind of silly, and a significant security issue. You should connect to the database using your own or a predetermined login/password to do any queries.

If the problem is that you don't how to use PerlDBI then that's another story. Let me know and I'll help you with that.

Reply With Quote
  #5  
Old March 12th, 2001, 02:57 PM
vettracker vettracker is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 0 vettracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
"The registration table is in a database and you want to connect to that table and check their record of registration for an email/password match. If it matches then you go ahead to the rest of the process."

You are correct on the above.

What do I need to do to make the connection in a perl script?

Thanks
Scott

Reply With Quote
  #6  
Old March 12th, 2001, 03:09 PM
dsb dsb is offline
PerlGuy
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2001
Posts: 714 dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 15 h 44 m 20 sec
Reputation Power: 36
Send a message via AIM to dsb
Wink

Okay,
You want to use the PerlDBI module. YOu don't want to connect to the database using the email/pass provided by the user. You want to establish a connection to the database using your own user info. All this is dependent on the fact that you have the DBI module installed along with the correct DBD for type of database(ie. Oracle, mysql, etc.).

Once you established a connection to the database you would prepare a statement and execute it. Then bind the results and process them as is necessary.

What kind of database are you using? Do you have DBI and the correct DBD(database driver) modules installed? Do you have an account or access to an account that can be used to establish a connection to the database? These are questions that must be answered before you can proceed.

Let me know if you need more help.

Reply With Quote
  #7  
Old March 12th, 2001, 03:15 PM
vettracker vettracker is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 0 vettracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ok I am using MySQL, it has dbi and correct DBD modules installed. Yes I have an account, I am currently using MySQL for my store.

Yes I need more help I do not know Perl very well at all and I need help to get the right code to do what we have been discussing.

Thanks

Reply With Quote
  #8  
Old March 12th, 2001, 03:54 PM
dsb dsb is offline
PerlGuy
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2001
Posts: 714 dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 15 h 44 m 20 sec
Reputation Power: 36
Send a message via AIM to dsb
Wink

Okay. Basically you're going to have to do a little research on DBI but this will get you started.

Code:
#!/usr/bin/perl -w      # ALWAYS ALWAYS ALWAYS use this

use DBI;       # loads the DBI module

$dbh = DBI->connect( "DBI:mysql:databasename:host", "username", "pass" ) || die $DBI::errstr, "\n";   # establishes connection or dies with error message

$sth = $dbh->prepare( "SELECT * FROM tablename WHERE email = ? AND password = ?" );  # prepare the SQL query - the '?'s are placeholders, when you execute you will fill them in
$sth->execute( $email, $pass );  # execute query filling in the placeholder with args passed to DBI::execute
$sth->bind_columns( \$var1, \$var2, \$var3 );   # binds the results to variables, you can use as many as are needed
$sth->fetch();  # fetches the results and assigns them to the variables in 'bind_columns' arg list

# after that you'll be processing the information you just got
.

I would do some research on DBI so you can get a better handle on it.

Good 'ol O'Reilly has a book called Programming the Perl DBI that is really good. Also from O'reilly is Perl in a Nutshell. That book has info on many of the commonly(and not so commonly) used modules for Perl.

Hope that helps.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > How do you a login script from perl to mysql.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway