Solved

Redirect a login script

Posted on 2012-03-17
6
233 Views
Last Modified: 2012-03-23
Hi,
I try to modify a script produced by Dreamweaver to make each user login to his/hers own page. I have a MySQL database called login with username, password and URL (to the page the individual user will land after login) - but I cannot make it work. So, what is wrong with this code?

mysql_select_db($database_Liquid_FSteer, $Liquid_FSteer);
$query_Recordset1 = "SELECT username, password, URL FROM login";
$GLOBALS['MM_UserGroup'] = $loginStrGroup;
$MM_redirectLoginSuccess = mysql_result($LoginRS,0,'URL');
$Recordset1 = mysql_query($query_Recordset1, $Liquid_FSteer) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

When I try to run it, I get the following error message:
Warning: mysql_result() expects parameter 1 to be resource, null given in /home/fsteer/public_html/index.php on line 37
0
Comment
Question by:ToreJohn
  • 3
  • 2
6 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 37734338
I don't know what you're expecting with

$MM_redirectLoginSuccess = mysql_result($LoginRS,0,'URL');

but mysql_result() is supposed to get the results of a mysql_query() and you haven't run one yet in your code above.

http://us3.php.net/manual/en/function.mysql-result.php
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37734597
Sorry to have to tell you this, but I think you're starting your PHP learning in the wrong place.  Dreamweaver contains some of the worst PHP code ever written, and trying to learn from it,  use it, or modify it for specialized applications is a fools errand.  Instead, buy this little book and give yourself a few weeks to work through the examples.  It is very readable and comes with its own code library.  And it covers many of the kinds of things that you will be interested in.  It will not make you a pro, but it will help you get a good foundation in how PHP and MySQL work together.
http://www.sitepoint.com/books/phpmysql4/

The general design of a PHP client authentication system (login) is given in this article.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_2391-PHP-login-logout-and-easy-access-control.html

HTH, ~Ray
0
 

Author Comment

by:ToreJohn
ID: 37734916
I am not trying to learn PHP and I am happy with Dreamweaver. In this case I want to add  a field to the login username and password called URL = so that I could redirect each user to its own page. I want to use Dreamweaver's login script and add the URL field to each record. I found this Micromedia article explaing how to do it:

Re: User Login to Redirect using PHP
Hi SoeedRacer21,

Try doing this:

Go back to the original code inserted by the login server behavior. You
don't need to create another recordset to get the page that you should
redirect to. That information can be pulled from the recordset that checks
the username/password. Add 'redirect' to the list of fields being retrieved
"username,password,redirect".

add this code below "$GLOBALS['MM_UserGroup'] = $loginStrGroup;"

$MM_redirectLoginSuccess = mysql_result($LoginRS,0,'redirect');

Hope this helps
Jaybee Reyes
Macromedia Technical Support

But I did not make it work. Can anyone give me the solution?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 37735079
At the very least, that line Must come After you have run the query, not before.  When you run it before, there is nothing for it to get.  And '$LoginRS' is supposed to be the results pointer from a query.  I don't see a query that is setting that value.  This link shows how it is supposed to work:

http://us3.php.net/manual/en/function.mysql-result.php
0
 

Accepted Solution

by:
ToreJohn earned 0 total points
ID: 37735204
So it was that simple. Thanks a lot.
0
 

Author Closing Comment

by:ToreJohn
ID: 37756265
I do not know .php and I do not want to learn it, hence the reason for using Dreamweaver. I therefore did not understand your answer first time.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now