Free Web Hosting Forum
Go Back   Free Web Hosting Forum > Website Building > Web Programming
Reload this Page MySQL database user login not working
Reply
 
Thread Tools Display Modes
(#11 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 762
Join Date: Dec 2010
Default 04-24-2012, 09:25 AM

I saw the video tutorial. In index.php file of the video, form action="login.php" while in your code
it's 'logintest.php'. Which one is correct? What's your file name of php script, where database
connection script is included. Please put consistently double quotes around values.
Reply With Quote
Sponsored Links
(#12 (permalink))
Old
Junior Member
aqcheryl is on a distinguished road
 
Posts: 23
Join Date: Mar 2009
Default 04-24-2012, 06:23 PM

Quote:
Originally Posted by grace1004 View Post
Please put consistently double quotes around values.

No that is incorrect and that is where I had erred - double quotes are used primarily for statements and I had forgotton that. In all other cases it should be apostrophes. I hadn't realized I had put quotation marks around both logintest.php and POST in the index.php file in the form action. I think I was getting thrown off because in HTML you do use quotation marks and so I had forgotton I was working in PHP rather than HTML.

I changed the quotation marks to apostrophes and everything started working fine. So there was nothing wrong with my code in the logintest.php file.

I would not have realized that I had made that error (in the index.php file) without your help though as I was looking in the wrong area.
Reply With Quote
(#13 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 762
Join Date: Dec 2010
Default 04-24-2012, 09:46 PM

In html form tag, it doesn't matter whether the values are enclosed with single quotes (' ') or
double quotes(" "). My suggestion is that keep the consistency. When I started learning php/form
tag, the example code used double quotes around values. So, I am acccustomed in using double
quotes. However, as far as values are strings it's OK to use single quotes, and it is known that
using single quotes takes less time than double quotes in parsing/interpreting codes.

To test mixed using of single/double quotes, try the following code after saving it "logintest.php"
as file name. When I test this code, it works fine. This shows that your original code is OK as it is.
I don't know why it didn't work; may be it should have worked if you cleared browser cache .

PHP Code:
<html> 
    <form action='logintest.php' method="POST"> 
        Username: <input type="text" name="username"><br> 
        Password: <input type="password" name="password"><br> 
        <input type="submit" value="Log in"><br> 
        </form> 
</html>

<?php
$username 
$_POST['username'];
$password $_POST['password'];

echo 
$username."<br>";
echo 
$password
?>

Last edited by grace1004; 04-24-2012 at 10:46 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com