Solved

Redirect a login script

Posted on 2012-03-17
6
234 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 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 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

932 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

19 Experts available now in Live!

Get 1:1 Help Now