PHP login help!
Posted: Mon Mar 12, 2007 12:37 pm
feyd | Please use
***EDIT: Ok, this is the whole thing except for the info to connect to the database***
Right now when I login with the correct credentials I get redirected to "checklogin.php" which is the name of this php page. Any ideas?
Again, I'm new to PHP so if there is any other information you need to help, let me know.
Thanks!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello all! This is my first post here. Let me also note that I'm very new to PHP but want to learn more because of it's integration with Flash. Anyways, on to my question.
So I'm building a login for my website with Flash. In my sql database I have a table with username, password, and most importantly, for this question, page. This value I'm hoping will allow the user to login and be redirected to this predefined page on my site. So for test purposes my value for "page" on the database is "admin.php."
Here is the portion of my code that redirects:Code: Select all
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST['username'];
$mypassword=$_POST['pass'];
$sql="SELECT * FROM $tbl_name WHERE Username='$myusername' and Password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
$dbarray = mysql_fetch_array($result);
if($count==1)
{
session_register("myusername");
session_register("mypassword");
if($myusername == "myusername")
{
header("location:".$page);
}
}
else
{
header("location:index.php?badlogin=true");
}***EDIT: Ok, this is the whole thing except for the info to connect to the database***
Right now when I login with the correct credentials I get redirected to "checklogin.php" which is the name of this php page. Any ideas?
Again, I'm new to PHP so if there is any other information you need to help, let me know.
Thanks!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]