Link to home
Start Free TrialLog in
Avatar of ToreJohn
ToreJohnFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Redirect a login script

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
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

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
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.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_2391-PHP-login-logout-and-easy-access-control.html

HTH, ~Ray
Avatar of ToreJohn

ASKER

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?
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
ASKER CERTIFIED SOLUTION
Avatar of ToreJohn
ToreJohn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.