-
Aug 14th, 2013, 07:03 AM
#1
Thread Starter
Addicted Member
[RESOLVED] PHP/MYSQL: can"t get Login page to work
I am trying to set-p a chechlogin page but I can't get it to work. I have been trying for more than a week now. This is my first PhP, if you have a better idea how to do this, I will appreciate your help. here is my code. when I run this code it tells me page not found. Thank you for your time
AL code
Here is the code [HT<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>ML][/HTML]
-
Aug 14th, 2013, 07:25 AM
#2
Re: PHP/MYSQL: can"t get Login page to work
Does checklogin.php exist?
You haven't posted any PHP code, just the HTML.
At current, all you have shown is that your form will POST the field "myusername" and "mypassword" to checklogin.php.
-
Aug 14th, 2013, 08:28 AM
#3
Thread Starter
Addicted Member
Re: PHP/MYSQL: can"t get Login page to work
Originally Posted by kfcSmitty
Does checklogin.php exist?
You haven't posted any PHP code, just the HTML.
At current, all you have shown is that your form will POST the field "myusername" and "mypassword" to checklogin.php.
I am sorry
checklogin.php
HTML Code:
<?php
$host="ftp.xyz.com"; // Host name
$username="John"; // Mysql username
$password="zzww99"; // Mysql password
$db_name="testdb"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$axyz", "$john")or die("cannot connect");
mysql_select_db("$testdb")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $member WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>
Here is my code for login_success.php
[HTML<?php
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>][/HTML]
-
Aug 14th, 2013, 09:09 AM
#4
Re: PHP/MYSQL: can"t get Login page to work
What error are you getting and on what page?
The only big thing I can see from your code is that you're using $member in your SELECT statement, but that variable has never been declared.
-
Aug 14th, 2013, 10:17 AM
#5
Thread Starter
Addicted Member
Re: PHP/MYSQL: can"t get Login page to work
Originally Posted by kfcSmitty
What error are you getting and on what page?
The only big thing I can see from your code is that you're using $member in your SELECT statement, but that variable has never been declared.
When I try to do previel, I get 'Page Not found'
-
Aug 14th, 2013, 10:38 AM
#6
Re: PHP/MYSQL: can"t get Login page to work
Do you get that when you first try to load up you page (before your login form)?
Do you get that after you've clicked "Login" on your login form?
If you remove the 'header("Location:login_success.php");' from your checklogin.php page does it still give the error?
If it hits your checklogin.php page, have you tried echoing out along the path to see where it is crapping out?
Sounds more like "you've tried nothing, but you're all out of ideas" so to speak. What kind of debugging have you tried?
-
Aug 14th, 2013, 11:12 AM
#7
Thread Starter
Addicted Member
Re: PHP/MYSQL: can"t get Login page to work
Originally Posted by kfcSmitty
Do you get that when you first try to load up you page (before your login form)?
Do you get that after you've clicked "Login" on your login form?
If you remove the 'header("Location:login_success.php");' from your checklogin.php page does it still give the error?
If it hits your checklogin.php page, have you tried echoing out along the path to see where it is crapping out?
Sounds more like "you've tried nothing, but you're all out of ideas" so to speak. What kind of debugging have you tried?
I get it when I first try to load up the page, before the login form. I will go and try your suggestions and get back in the forum. Thanks for your time
-
Aug 14th, 2013, 11:41 AM
#8
Re: PHP/MYSQL: can"t get Login page to work
Maybe a screenshot would help... I don't see how you can get a "page not found" error before the login page... a screenshot along with the address (in the screenshot) would probably help... I foresee a couple things... but I'll wait for the screenshot to comment furhter.
-tg
-
Aug 15th, 2013, 08:52 AM
#9
Thread Starter
Addicted Member
Re: PHP/MYSQL: can"t get Login page to work
Originally Posted by techgnome
Maybe a screenshot would help... I don't see how you can get a "page not found" error before the login page... a screenshot along with the address (in the screenshot) would probably help... I foresee a couple things... but I'll wait for the screenshot to comment furhter.
-tg
I am sorry for not responding yesterday, my system crashed on me, but this what the page says "Page Not Found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable. Please try the following:
If you typed the page address in the Address bar, make sure that it is spelled correctly.
Click the Back button in your browser to try another link.
Use a search engine like Google to look for information on the Internet.
"
-
Aug 15th, 2013, 09:02 AM
#10
Re: PHP/MYSQL: can"t get Login page to work
Yeah, I KNOW what a 404 page not found error looks like... and for the reason for it... but that's not what I asked for was it?
Originally Posted by me
a screenshot along with the address (in the screenshot)
-tg
-
Aug 15th, 2013, 10:21 AM
#11
Thread Starter
Addicted Member
Re: PHP/MYSQL: can"t get Login page to work
Originally Posted by techgnome
Yeah, I KNOW what a 404 page not found error looks like... and for the reason for it... but that's not what I asked for was it?
-tg
tg,
-
Aug 15th, 2013, 10:48 AM
#12
Re: PHP/MYSQL: can"t get Login page to work
You're accessing the FTP URL which is not correct for your site.
StartLogic doesn't appear to offer a DNS for you when you sign up for their hosting. You're going to have to get a domain and point it to their nameservers. Or, you could get a domain through them.
I would suggest using their support for this, as this is more that you don't seem to understand their hosting services.
The first step in their registration process is asking for a domain. Did you check off "Do not register a domain"? If so, you need one.
-
Aug 18th, 2013, 11:34 AM
#13
Thread Starter
Addicted Member
Re: PHP/MYSQL: can"t get Login page to work
Thanks everybody that took time to offer some help. The problem was that the files on the server was not updating, so when I changed a file name it will not update. But once this get corrected everything works fine.
AL
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|