| MySQL Help Post any question relating to MySQL here and hopefully someone can help |

2004-08-06, 05:30 PM
|
|
Junior Member
|
|
Join Date: Aug 2004
Posts: 7
|
|
Hi again,
This is my login page for current users. I'm not sure what extension to use in the form "action".
The page name is page6.html. Since I have the php code on the same page, do I use .html or .php?
//open connection
$connect = mysql_connect("localhost", "user", "password")
or die(mysql_error());
//which db
mysql_select_db("national_auth",$connect)
or die(mysql_error());
//make statement
$sql = "SELECT email, password from members where email = '$POST[email]' AND password =
password('$_POST[password]')";
$result = mysql_query($sql,$connect)
or die(mysql_error());
//get rows
if(mysql_num_rows($result) == 1){
$email = mysql_result($result, 0, 'email');
$password = mysql_result($result, 0, 'password');
//set cookie
setcookie("member", "1", 0, "/", "mydomainname.com",0);
//is okayed
$msg = "
Logged in as $email</p>";
}else{
$msg = "
You must be a member</p>";
//redirect to sign up page
header("Location: page7.html");
exit;
}
--><form action="page6.php" method="post">
<table summary="login"><tbody><tr><td>
<p align="left">Email </p><p align="left">
<input maxlength="75" size="30" name="email" /> </p>
<p align="left">Password</p><p align="left">
<input type="password" maxlength="12" name="pass" />
</p><p align="left"><input type="submit" />
</p></td></tr></tbody></table></form>
Thanks for your help
Pesty
|

2004-08-06, 05:36 PM
|
 |
Senior Member
|
|
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
|
|
what is the file name. That is your answer, since the other extension references a file that does not exist.
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
|

2004-08-06, 06:12 PM
|
|
Junior Member
|
|
Join Date: Aug 2004
Posts: 7
|
|
The public file shows the file name as page6.html
|

2004-08-07, 05:04 AM
|
|
Junior Member
|
|
Join Date: Aug 2004
Posts: 7
|
|
Ok, so I understand how to tell what extension to use. Thank you Xnuiem!
But my code is wrong. I need to use $_get instead of $_post
It is suppose to be checking for a current member. Not posting a new one.
Anyway, I can't get the message to echo or the redirect to work. Can anyone see what is wrong there?
Here the revised one. I am new to this. Learning from a book.
//open connection
$connect = mysql_connect("localhost", "user", "password")
or die(mysql_error());
//which db
mysql_select_db("national_pets",$connect)
or die(mysql_error());
//make statement
$sql = "SELECT email, password from members where email = '$_GET[email]' AND password =
password('$_GET[password]')";
$result = mysql_query($sql,$connect)
or die(mysql_error());
//get rows
if(mysql_num_rows($result) == 1){
$email = mysql_result($result, 0, 'email');
$password = mysql_result($result, 0, 'password');
//set cookie
setcookie("member", "1", 0, "/", "mydomainname.com",0);
//is okayed
echo "Logged in as $email";
}else{
echo "You must be a member";
//redirect to sign up page
header("Location: page6.html");
exit;
}
--><form action="page5.html" method="get">
<table summary="login"><tbody><tr><td>
<p align="left">Email </p><p align="left">
<input maxlength="75" size="30" name="email" />
</p>
<p align="left">Password</p><p align="left">
<input type="password" maxlength="12" name="pass" />
</p>
<p align="left">
<input type="submit" /></p></td></tr></tbody>
</table></form>
Thanks for the help
Pesty
|

2004-08-07, 08:58 AM
|
 |
Senior Member
|
|
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
|
|
GET and POST only refer to the way data is sent to the server, has nothing to do with what you do with it then. POST is usually better to use.
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
|

2004-08-07, 07:31 PM
|
|
Junior Member
|
|
Join Date: Aug 2004
Posts: 7
|
|
hmmm,
On my website, I used the first set of codes with the post. When I treid to test it, it came back with an error 405. Something about cannot use post in that manner.
So, I wrote my hosts tech support and they said I needed to use GET instead of POST. I changed the method to get and the error went away, but the form still isn't working.
I am really new to all this, but I am making some progress.
There is one more thing. Since I am using my hosts web builder, do I still need to upload the php.ini file?
As I said, I am a real novice, I thought since my host supports php I could type the code on the page, and it would work.
niave but learning,
Pesty
PS- so should I use the original form?
|

2004-08-08, 09:28 AM
|
 |
Senior Member
|
|
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
|
|
I would never use GET for forms, it is insecure and creates a lot of problems with unencoded URIs.
The real problem I see here, is password. In the form, the name of the field is "pass" but you are referring to the variable as $_POST["password"[, it should be $_POST["password"].
Another suggestion would be to find another host that allows POST to be used in forms. POST is used on this site, all my sites, and just about everysite I have ever done or use, it is completely unreasonable for your host to expect you to use GET for the form methods. It would get quite messy if any of your form element values were passed with any of these "&()'<> =
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
|
| Must read Review for Serious PHP Developers |
NuSphere PhpED 5.5
: The Staff of php-editors.com recently spent a few days working with NuSphere
PhpED 5.5
(a popular PHP IDE) and
NuCoder 2.0
(a PHP Encoding Utility), read up on all the details.
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:32 PM.
|