Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

[JavaScript] How to make a Javascript prompt dialog post to PHP?

How would I go abouts making a JavaScript show_prompt dialog post to a PHP file on the server?

To help better explain, I mean a username and password field much like cPanels login; but I need it to instantly post the data inputed to a server sided php file. Thanks in advance! 🤝
ow It Works

Most providers who allow developers to embed JavaScript within their domain force developers to use IFrames to sandbox their code. Facebook has taken a different approach to this problem. JavaScript that you give us gets parsed, and any identifiers (function and variable names) get prepended with your application ID. For example, the following code block:

function foo(bar) {
var obj = {property: bar};
return obj.property;
}

becomes:

function a12345_foo(a12345_bar) {
var a12345_obj = {property: a12345_bar};
return a12345_obj.property;
}

This creates a virtual scope for every application that runs within Facebook. From there we expose certain functionality through a collection of JavaScript objects that allow you to modify your content on Facebook. Our objects are made to mimic the functionality of JavaScript as closely as possible, but it may take some getting used to for people who are already adept with JavaScript.
That that was completely unrelated to the thread.. thanks for the though O.o
BUMP. Do none of you know programming? -.-
What kind of prompt are you talking about? Anyway, as long as you can get user input stored in a variable you can POST it to a PHP file on the same domain using AJAX. You can do AJAX manually but it's easier if you use jQuery or a similar library. Look it up.
'<html>
<head>
<script type="text/javascript">
function show_prompt()
{
var name=prompt("Please enter your name","Harry Potter");
if (name!=null && name!="")
{
document.write("Hello " + name + "! How are you today?");
}
}
</script>
</head>
<body>

<input type="button" onclick="show_prompt()" value="Show prompt box" />

</body>
</html>'

Two fields, post to php. No way other than an Ajax?
Yes, there's an other way. One the same page you add an HTML form, with method POST and action set to your PHP script. In the form, you add hidden fields. You fill out the form using Javascript and then call its submit() method.

Why would you want to do that though?

This is a technique used for CSRF, by the way.
(Aug 6, 2011 12:27 AM)G-Brain Wrote:  Yes, there's an other way. One the same page you add an HTML form, with method POST and action set to your PHP script. In the form, you add hidden fields. You fill out the form using Javascript and then call its submit() method.
Much thanks for pointing me in the right direction. 🤝

Quote:Why would you want to do that though?

unique login system

Quote:This is a technique used for CSRF, by the way.

Hmm.. interesting, perhaps I'll look into it. I've read up a bit on XSS, BeEF etc.

Would you be willing to write the script for it? I'll huck you a few LR in a couple days, and can show you a really cool community. :)

shoot me a PM
If it's on the same domain, why wouldn't you use ajax?
Here's my jsonp implementation: http://code.google.com/p/jsonp-post/
Basically it simulates cross-domain post requests.



Possibly Related Threads...
Thread / Author Replies Views Last Post
by apknanJan 30, 2024 05:58 PM 2 349 Jan 30, 2024 05:58 PM
Last Post: Klonopin
[Help] by MefisNov 16, 2014 12:59 PM 0 152 Nov 16, 2014 12:59 PM
Last Post: Mefis
[Lua] by JohnD03Aug 3, 2013 10:12 AM 2 147 Aug 3, 2013 10:12 AM
Last Post: JohnD03