![]() javascript POST? - Printable Version -Shoutbox (https://shoutbox.menthix.net) +-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58) +--- Forum: Skype & Technology (/forumdisplay.php?fid=9) +---- Forum: Tech Talk (/forumdisplay.php?fid=17) +----- Thread: javascript POST? (/showthread.php?tid=21608) javascript POST? by bach_m on 02-20-2004 at 03:02 AM i'm looking for a javascript box to popup and ask for a name, and then pass that to my website as POST data, for use in a PHP script. can it be done??? i dont know the first thing about PHP... RE: javascript POST? by WDZ on 02-20-2004 at 04:32 AM
Why can't you use GET? I think that would be easier... RE: javascript POST? by fluffy_lobster on 02-20-2004 at 09:31 AM
You can also do it without changing the main page's navigation by using an iframe. I'll do a quick dummy example: code:Once you've done that, you can stick it on the following page with all the relevant javascript: code:And you're done
RE: javascript POST? by CookieRevised on 02-20-2004 at 10:55 AM
There is no need for an iframe at all if you just want to popup a inputbox and then redirect the current page to your website... If you do want that the main page (where the popup is launched) to stay, then you can use Lobster's method... RE: javascript POST? by KeyStorm on 02-20-2004 at 11:57 AM
If you know sessions you can use them, they're very confortable. Although I don't really know how to manage them RE: javascript POST? by bach_m on 02-20-2004 at 12:04 PM
quote: this one.. i'd prefer to not divulge WHY i need it. but i need it to be processed by a PHP script. for instance. they open a page. checks whether thay have a cookie saying that they have given their name (and what ), and if not, then it pops up a box saying"whats ur name?", and then submits that to my main page, which proceces that.i'd prefer not to use get, but if absolutely necesary, i guess i can RE: javascript POST? by CookieRevised on 02-20-2004 at 01:41 PM
It still isn't exactly clear what you want to do. Explain in clear steps and give each page/link a name code:not tested RE: javascript POST? by KeyStorm on 02-20-2004 at 02:45 PM
quote:Sessions are perfect for this kind of thing: That's variabales that are stores in the server and are kept alive while the session is alive (like in these forums) and they can be accessed from any php in the server. So you can store the data from your pop-up to the session-vars and retrieve it from the main-page. All this occurs in the darkness so nobody has control over it (php-sessions is the most secure way to send and recieve data). RE: javascript POST? by WDZ on 02-20-2004 at 03:39 PM
quote:I dunno about that... seems kinda overkill... ![]() If you're just passing one variable to one other page, you should just use the JavaScript POST thing as shown above. Even if you used sessions, you'd still have to do the same thing to get the value from JavaScript to PHP. Also, sessions expire (default time is like half an hour), and are designed to exist only during one visit to the site. If you want your users' data to still be available when they return tomorrow, you should use cookies. If for some reason you don't want the data stored in cookies, store it in a database with some kind of ID associated with it, then put the ID in a cookie. RE: javascript POST? by KeyStorm on 02-20-2004 at 04:19 PM
Remember you can read and set cookies in PHP RE: javascript POST? by WDZ on 02-20-2004 at 05:10 PM
quote: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...
RE: javascript POST? by KeyStorm on 02-20-2004 at 05:13 PM
quote:Obviously ![]() Well... Sessions are very useful for defining and logging in, similar to what bach wants to do. But... yeah, maybe overkill
RE: javascript POST? by bach_m on 02-20-2004 at 08:21 PM
quote: i didn't say they would log in ![]() i wanna get their name and then store it in a batabase along with their IP address ![]() ![]() but i think i'm just too lazy to want to do that
RE: javascript POST? by CookieRevised on 02-20-2004 at 09:25 PM
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... RE: javascript POST? by bach_m on 02-20-2004 at 11:20 PM
and just use ur script for getting the name?? makes sence.... code: and cookie. u forgot the semicolons
RE: javascript POST? by CookieRevised on 02-21-2004 at 08:12 AM
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... RE: javascript POST? by KeyStorm on 02-21-2004 at 12:33 PM
quote: 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)
|