?
Solved

Redirect a login script

Posted on 2012-03-17
6
Medium Priority
?
240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 83

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 111

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
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

 
LVL 83

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

770 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