What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » javascript POST?

Pages: (2): « First « 1 [ 2 ] Last »
javascript POST?
Author: Message:
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: javascript POST?
quote:
Originally posted by KeyStorm
Remember you can read and set cookies in PHP ;)
Who are you replying to? As my post is right above yours, and above my post is another one of your posts, I'll assume you're replying to me, but that doesn't make sense... I'm well aware of the fact that PHP can read and set cookies... :p
02-20-2004 05:10 PM
Profile PM Web Find Quote Report
KeyStorm
Elite Member
*****

Avatar
Inn-sewer-ants-pollie-sea

Posts: 2156
Reputation: 45
38 / Male / –
Joined: Jan 2003
RE: javascript POST?
quote:
Originally posted by WDZ
I'm well aware of the fact that PHP can read and set cookies... :P
Obviously ;)

Well... Sessions are very useful for defining and logging in, similar to what bach wants to do. But... yeah, maybe overkill :P
02-20-2004 05:13 PM
Profile E-Mail PM Web Find Quote Report
bach_m
Veteran Member
*****

Avatar
4837 :P

Posts: 2863
Reputation: 7
37 / Male / –
Joined: Feb 2003
O.P. RE: javascript POST?
quote:
Originally posted by KeyStorm


Well... Sessions are very useful for defining and logging in, similar to what bach wants to do. But... yeah, maybe overkill


i didn't say they would log in ^o)

i wanna get their name and then store it in a batabase along with their IP address :D:D


but i think i'm just too lazy to want to do that :P
02-20-2004 08:21 PM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: javascript POST?
Well, use the method I described, but convert it into PHP and put it on top of your php page. And instead of a cookie, use the database.... It can't be simpler then that...

Get_Current_IP
if (Current_IP isin Database) {
  Get_Name_Out_of_Database
} else {
  Ask_Name
  Store_Name_In_Database
  Store_Current_IP_In_Database
}

print_name_with_some_welcome_msg
do_rest_of_page
yadda_yadda
:D

This post was edited on 02-20-2004 at 09:25 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
02-20-2004 09:25 PM
Profile PM Find Quote Report
bach_m
Veteran Member
*****

Avatar
4837 :P

Posts: 2863
Reputation: 7
37 / Male / –
Joined: Feb 2003
O.P. RE: javascript POST?
and just use ur script for getting the name?? makes sence....

or shud it just be a form?? such as:
code:
<?php
look_for_IP_in_database;
if not there, pop up form as a web page;
   once submitted, procede to main page.
if yes there, then popup the main page;
?>


and cookie. u forgot the semicolons :P
02-20-2004 11:20 PM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: javascript POST?
No, you don't need a form to do what you want I think. Unless you can't popup an inputbox with PHP to get a name from the user. I don't know PHP. It was just an workflow idea how you could do it in pure javascript, which you can convert to PHP I thought. But you need a function in PHP where you can popup an inputbox for it to work...


Here is the javascript version of it. This time I tested it, and as you can see, not much had to be changed (only had to add [1] and replace "" with null):
code:
<html>

  <head>
    <title>Main Page</title>
    <script language="JavaScript">
      function GetName() {
        var username = unescape(document.cookie)
        username = username.split("=")[1]
        if (username == null) {
          username = prompt("What is your name?","")
          var expiredate = new Date()
          expiredate.setMonth(expiredate.getMonth() + 1)
          document.cookie = "Name=" + username + ";expires=" + expiredate.toGMTString() + ";path=/"
        }
        return username
      }
      function ClearName() {
        var expiredate = new Date()
        document.cookie = "Name=;expires=" + expiredate.toGMTString() + ";path=/"
      }
    </script>
  </head>

  <body onLoad="javascript:alert(GetName() + ', welcome...');">
    <input type="button" value="Clear cookie..." onClick="ClearName()">
    <br>main page
  </body>

</html>
So this is the concept, I guess. I'm sure this can be done in PHP also, but instead of cookies, use a database... BTW, this is only a very crude example.


PS: about the semicolons, you don't need them in javascript. But it is indeed a good habbit to put them there...

.zip File Attachment: poc.zip (514 bytes)
This file has been downloaded 292 time(s).

This post was edited on 02-21-2004 at 08:22 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
02-21-2004 08:12 AM
Profile PM Find Quote Report
KeyStorm
Elite Member
*****

Avatar
Inn-sewer-ants-pollie-sea

Posts: 2156
Reputation: 45
38 / Male / –
Joined: Jan 2003
RE: javascript POST?
quote:
Well, use the method I described, but convert it into PHP and put it on top of your php page. And instead of a cookie, use the database.... It can't be simpler then that...

The IP's are dynamical... In many cases more unexpectable than cookies.

Cookies can be deleted by the user, but the user has no control over the IP's. Some countries may have fixed IP's, but, as the number of free IP's is becoming very little (while IPv6 is not implemented) they are rapidly changing to the dynamic IP connection. In Spain for example (I'm sure many other countries do so) your IP can be changed even while you're online (when the modem/router notices there is no connection through its gateway it reports itself as idle to the ISP and the ISP may change its IP)

So, the best solution is to set cookies, because normal people (no nerds like us ;)) do not keep deleting their cookies constantly (well, neither do I)

This post was edited on 02-21-2004 at 01:07 PM by KeyStorm.
02-21-2004 12:33 PM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On