Link to home
Start Free TrialLog in
Avatar of Sam Sung
Sam SungFlag for Denmark

asked on

Website Programming very simple

Dear Experts
I would like to follow my success with asking questions at experts-exchange.. Everytime I asked a question i got the best possible answer and i have the best impression of Expert-exchange now.
My question is, i have a website with a login interface where my family members can login .. and in that i want a function so everytime someone tries to login then a mail should be sended to my e-mail.
The script i use now is :

<FORM name=adgang>Tast password og tryk ok, <BR>ikke enter! <INPUT type=password size=12 name=kode> <INPUT onclick=loadpage() type=button value=OK> </FORM>
<SCRIPT language=javascript>
        function loadpage()
        { document.location.href=document.adgang.kode.value + ".html"}
</SCRIPT>


Translation from Danish to English  : Adgang = access
                                                     Tast Password og tryk ok ikke Enter = Type Password and press ok, dont press enter

Thankyou very much for your help guys. I hope I can make something smart
                 

Avatar of bubbledragon
bubbledragon

send email function?
only use HTML and Javascript?
Avatar of Sam Sung

ASKER

well its ok to use php or what ever needed to be done.. just if i can get the function to work.. if u guys feel 50 points is too less for this task your welcome to ask more..
I viewing the code, you need the user input the password and press OK button to redirect the page to the password + ".html" ?

If php i will change the code below

<SCRIPT language=javascript>
        function loadpage()
         { document.adgang.submit(); }
</SCRIPT>
<FORM name=adgang action=redirect.php method=post>Tast password og tryk ok, <BR>ikke enter!
<INPUT type=password size=12 name=kode>
<INPUT onclick=loadpage() type=button value=OK>
</FORM>

redirect.php
<?
  mail('abc@abc.com', 'Subject', 'Try Login')          // send the mail
  header("Location: http://" . $_SERVER['HTTP_HOST']   // redirect to user page
                     . dirname($_SERVER['PHP_SELF'])
                     . "/" . $HTTP_POST_VARS["kode"].".html");
?>

mail() function allows you to send mail, but web hosting need to support this function.
lets say my site name is thilan.com and the host allows smtp mails.. then how should fill in, i am really newbie to this please  help me out :)

location = is that the page which is protected ?

 mail('abc@abc.com', 'Subject', 'Try Login')          // send the mail  ( is this function enough to send the mail without using getting a outlook to open ... cause i prefer it sends auto so users does not know a mail has been sended
the location can use the hardcode path

i don't know you page location before, so use the following function to handle
$_SERVER['HTTP_HOST']               get the host name, here is thilan.com

if the page is under the directory like http://www.thilan.com/folder/abc.html
dirname($_SERVER['PHP_SELF'])       get the directory name "folder"

$HTTP_POST_VARS["kode"].".html");   received the password value

the mail function only action on the server, the users don't know a mail is sent.
so all what i have to do is insert this script in the page where i had the other script ...

SCRIPT language=javascript>
        function loadpage()
         { document.adgang.submit(); }
</SCRIPT>
<FORM name=adgang action=redirect.php method=post>Tast password og tryk ok, <BR>ikke enter!
<INPUT type=password size=12 name=kode>
<INPUT onclick=loadpage() type=button value=OK>
</FORM>

redirect.php
<?
  mail('mymail@thilan.com', 'Subject', 'Try Login')          // send the mail
  header("Location: http://" . $_SERVER['HTTP_HOST']   // redirect to user page   .... I dont understand what i have to fill in here.. lets say it should show www.thilan.com/photo.htm then what should i fill in
                     . dirname($_SERVER['PHP_SELF'])
                     . "/" . $HTTP_POST_VARS["kode"].".html");
?>
can u fillin the details for me and give please ?? I hope i dont give too much trouble to you brother
ASKER CERTIFIED SOLUTION
Avatar of bubbledragon
bubbledragon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
perfect, i think i got it now, its perfectttt :D I am so happy, i will try this code as soon as i am home, i am sooooooo happy now, thanks for ur wonderful expert help :D its so cool
SCRIPT language=javascript>
        function loadpage()
         { document.adgang.submit(); }
</SCRIPT>
<FORM name=adgang action=redirect.php method=post>Tast password og tryk ok, <BR>ikke enter!
<INPUT type=password size=12 name=kode>
<INPUT onclick=loadpage() type=button value=OK>
</FORM>

redirect.php
<?
  mail('admin@thilan.dk', 'hjemmeside', 'en person logger ind')          
  header("Location: http://www.thilan.dk/" . $_SERVER['HTTP_HOST']      
                     . dirname($_SERVER['PHP_SELF'])
                     . "/" . $HTTP_POST_VARS["kode"].".html");
?>

so this is the complet script..do u want more than 50 points ?