Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

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

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2004-08-06, 05:30 PM
Junior Member
 
Join Date: Aug 2004
Posts: 7
pesty
Default

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
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2004-08-06, 05:36 PM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

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.
Reply With Quote
  #3 (permalink)  
Old 2004-08-06, 06:12 PM
Junior Member
 
Join Date: Aug 2004
Posts: 7
pesty
Default

The public file shows the file name as page6.html
Reply With Quote
  #4 (permalink)  
Old 2004-08-07, 05:04 AM
Junior Member
 
Join Date: Aug 2004
Posts: 7
pesty
Default

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
Reply With Quote
  #5 (permalink)  
Old 2004-08-07, 08:58 AM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

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.
Reply With Quote
  #6 (permalink)  
Old 2004-08-07, 07:31 PM
Junior Member
 
Join Date: Aug 2004
Posts: 7
pesty
Default

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?
Reply With Quote
  #7 (permalink)  
Old 2004-08-08, 09:28 AM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

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.
Reply With Quote
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.

Sponsored Links
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 On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 11:32 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.