|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I wanted to know if there is anyway to do this:
Create a table which stores Usernames Passwords, and Account #'s (I know this part). When you provide a valid username and password, it will redirect you to a certain page for example your account # with a .html added on to the end of it ("account#.html") Could you please post example code if possible instead of telling me how to do it. ------------------ -- Haafiz Dossa http://www.innovativewpd.com |
|
#2
|
||||
|
||||
|
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
<?php //assuming you've passed $username and $password by using a form... $link_id = mysql_connect("localhost","user","pass"); $db = mysql_select_db("your_db"); $result = mysql_query("SELECT acct_num FROM your_table WHERE username='$username' AND password='$password'"); if ($row = mysql_fetch_array($result)) { header("Location: <A HREF="http://www.yourhost.com/"" TARGET=_blank>http://www.yourhost.com/"</A> . $row["acct_num"] . ".html"); } ?> <html> <body> Cannot log in </body> </html> [/code] You'll have to check on that header syntax and make sure it's correct. I haven't used it before... You could also just include the file include($row["acct_num"] . ".html"); ---John Holmes... ------------------ ************************************************************* * The manual can probably answer 90% of your questions... * * PHP Manual. www.php.net/manual * MySQL Manual: www.mysql.com/documentation/mysql/bychapter ************************************************************* |
|
#3
|
|||
|
|||
|
Thanks for replying. That little tag saying about the header makes doesn't work, but screws everything up. when you actually log in properly, it will say something like trying to add a header to the submitted form. it thinks you are adding something like this: http://www.yourdomain.com/login.php3?user=xxxx&pass=xxx&acct_num=xxxxx
and it doesn't allow you to do that so you get an error message. ------------------ -- Haafiz Dossa http://www.innovativewpd.com |
|
#4
|
||||
|
||||
|
See if one of the following work better for you...I need to look into that header function I guess....
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> <?php //make sure no one tries to pass page in the //url and sneak in... unset($page); //assuming you've passed $username and $password by using a form... $link_id = mysql_connect("localhost","user","pass"); $db = mysql_select_db("your_db"); $result = mysql_query("SELECT acct_num FROM your_table WHERE username='$username' AND password='$password'"); if ($row = mysql_fetch_array($result)) { $page = $row["acct_num"] . ".html"; } ?> <html> <body> <?php if (isset($page)) { include($page); } ?> Cannot log in </body> </html> [/code] or... <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> <?php //make sure no one tries to pass page in the //url and sneak in... unset($page); //assuming you've passed $username and $password by using a form... $link_id = mysql_connect("localhost","user","pass"); $db = mysql_select_db("your_db"); $result = mysql_query("SELECT acct_num FROM your_table WHERE username='$username' AND password='$password'"); if ($row = mysql_fetch_array($result)) { $page = $row["acct_num"] . ".html"; } ?> <html> <body> <?php if (isset($page)) { echo "<script language="javascript">location.href='$page';</script>"; } ?> Cannot log in </body> </html> [/code] ---John Holmes... |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > Password protection |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|