RE: [PHP] How to open random Flash page with hyperlink?
| From: | Cody Phanekham | Date: | Mon, 25 Aug 2003 05:36:35 +0000 |
| Subject: | RE: [PHP] How to open random Flash page with hyperlink? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-160638@lists.php.net to get a copy of this message | ||
Murugesan,
I'll assume your redirecting the user to main.php because (s)he has passed the authentication
routine... in that case just store the username and password as a session variable that way you wont
need to pass the username and password via the url.
auth.php, [just before the call to header()]:
<?
session_register('empid');
session_register('pwd');
header ("Location: /main.php");
?>
then in main.php you need to start your session to access the session variables
<?
session_name("yoursessionname");
session_start();
// you now have access to $empid and $pwd
echo "<br>your employee id = $empid and the password you typed was $pwd";
?>
> -----Original Message-----
> From: murugesan [mailto:mukeshgct@hotmail.com]
> Sent: Monday, 25 August 2003 15:18
> To: Cody Phanekham; php-general@lists.php.net
> Subject: Re: [PHP] How to open random Flash page with hyperlink?
>
>
> Thanks for the information.
> In the code you provided
>
> ----if ((!$passwd) || (!$username)) // user hasnt logged in
> {
> .....
>
> Actually I have implemented this in a separate page.
>
> That is upon sign up of the <form> in the index page
> I call a new page auth.php
> In that file
> I have done this authentication and called the function
> header ("Location: /main.php?empid=$empid&pwd=$pwd");
>
> Actually when passing this URL the password appears in the
> address bar.
> How to over come this? It will be very much usefull if I get
> the answer.
>
> Thanks in advance
> -Murugesan
> --------------------------------------------------------------
> --------------
> --------------------------------------------------------------
> --------------
> -
> Ok lets say you want every user to login before they can
> access other parts
> of your site.
>
> index.php:
> <?
> session_name("mysessionname");
> session_start();
> session_register("s_authed");
> $s_authed = 0; // initialize session flag
>
> if ((!$passwd) || (!$username)) // user hasnt logged in
> {
> // display login form
> ...
> }
> else
> {
> // retrieve database username and password here
> ...
> // check if they match
> if (($db_passwd == $passwd) && ($db_username == $username))
> {
> $s_authed = 1; // user has been authorised
> // redirect to real page
> echo "
> <script>
> window.location='main.php'
> </script>";
> }
> }
> ?>
>
> main.php:
> <?
> session_name("mysessionname");
> session_start();
> if (!$s_authed) // check access
> {
> // user hasnt been authorised, therefore redirect to login page
> echo "
> <script>
> window.location='index.php'
> </script>";
> }
> else
> {
> // display page
> ...
> }
> ?>
>
>
> if a user tries to access main.php directly without logging
> in they will be
> redirected to index.php
>
> checkout http://www.php.net/manual/en/ref.session.php for
> more information
>
>
> >
> >
> > Thanks for the message.
> > Can you please tell me how to do session authentication?.
> >
> > -murugesan
>
*************************************************************************************
This e-mail, including any attachments to it, may contain confidential and/or personal information.
If you have received this e-mail in error, you must not copy, distribute, or disclose it, use or
take any action
based on the information contained within it.
Please notify the sender immediately by return e-mail of the error and then delete the original
e-mail.
The information contained within this e-mail may be solely the opinion of the sender and may not
necessarily
reflect the position, beliefs or opinions of Salmat on any issue.
This email has been swept for the presence of computer viruses known to Salmat's anti-virus
systems.
For more information, visit our website at www.salmat.com.au.
*************************************************************************************