Any Site That Displays The Received Text? [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
So pretty much what I am looking for is a site that simply accepts POST requests, and the site then just displays the text received from the POST request.
For example, lets say that I POSTed "Hello, world!" to the site, if I looked at the contents of the page, it just said "Hello, world!". I need this for testing/developing purposes.
If not, could somebody possibly create a PHP script for this? I don't know PHP, otherwise I would do it myself :)
Thanks
EDIT: Sorry for the extremely easy question, I didn't realise it was this easy. Thanks for the answers :)

<?php
header("Content-Type: text/plain");
print_r($_POST);
This uses print_r to dump the content of the $_POST array. The page content type of text/plain is needed to prevent creating an XSS vulnerability.

Try this
First create a file names mypage.php then save this code.
<?php
if(isset($_POST['myText']))
{
echo $_POST['myText']
}
<form action='mypage.php'>
<input type='text' name='myText'>
<input type='submit'>
</form>
?>

Assume your form looks like this
<form method="POST">
<input type='text' name='field'>
<input type='submit' value='Submit'>
</form>
The simplest way is write this code below it
<?php var_export($_POST); ?>

Write your own! Do this on any website you have
Simply print_r($_POST); should suffice on a blank page

Related

Make your own code sample box [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
Is there a simple way to make your own, or is there a plugin to have your own PHP code sample box for presenting your code of an open-source project? I would like to have something like here on Stackoverflow, with colors, to present your code, like:
<?php echo 'test'; ?>
If there is no simple way to do is, i'll just make it a download, but It would be handy to have something like this :)
Thanks
highlight_string("<?php echo 'test'; ?>");
Or there are some libaries that do a better job and other languages. I've also used GeSHi in the past.
Also, highlight_file().
Using HTML:
echo "<pre>" . highlight_string("<?php echo 'test'; ?>", true) . "</pre>";
Most of these are actually javascript based. SO and many other sites use the js library called Pettify to make code blocks look nice. You can find the project at https://code.google.com/p/google-code-prettify/

Calling a method form a mobile application [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm new with PHP.
In my mobile application I have to query some data form server.
I have to call login before i can access the data.
I have to use the following type of Post request
http://SERVER_IP/wapdb/smartphone_login/
How it can be done in my PHP file?
Thanks,
Eyal.
I think you should detect the mobile device after the login so the webpage/mobile application uses styling that would work for maybe the desktop and mobile but when you login, it logs in the same way you would on a desktop using PHP, after you login, you could then change the page contents by the resolution of the phone. Otherwise you end up having two potentially dangerous logins that are basically the same but different folders.
In the form you will have used the method post, so the PHP script will use an array called $_POST and can use it by the name of the input elements for example (example in HTML):
<form method='POST' action='test.php'>
<input name='first_name'/>
<input type='submit' value='Send'/>
</form>
In PHP you can then do whatever you want by reading the contents of the post array
<?php
echo "Your name is " . $_POST['first_name'];
?>
You can use a php file to add the server IP in a tag.
<?php echo "<form method='POST' action='http://" . $_SERVER['SERVER_ADDR'] . "/wapdb/login/'><input name='first_name'/><input type='submit' value='Send'/></form>"; ?>
I would recommend you to have a play with $_SERVER["SERVER_NAME"] and other variables from http://php.net/manual/en/reserved.variables.server.php since it might use the internal IP address and you'd want the public IP. You can also look at some information available at W3Schools. http://www.w3schools.com/php/php_forms.asp
Hope this helps.

Advanced Session Script [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Improve this question
I was wondering if anybody knows how to make a script that would essentially save a percentage of how much you completed of say a test or something and when you go back to continue it will bring you to the page you're at. For example theres 5 pages, and you're on page 3 so it'll save as 60% and whenever you click continue it brings you to that page.
When I say advanced I mean like secure so you can't go skip to page 5 just by putting the url. For example at the head of each test page I would put this
if (session > 60%) {
header(Location: page3);
}
Do you guys know what I mean?
I was hoping somebody could just help me do this somehow and make it so it saves under the users profile and you can call the percentage whenever using a variable. Any ideas?
You're pretty close. First, check out any PHP Session Tutrorial to learn about them a bit.
You can access session variables with $_SESSION['keyname'] (after you've called session_start() on your page.
Simply save your progress as one of these, e.g. $_SESSION['progress'] = 60;
and evaluate by testing if the session is set (so you don't get an error), and then evaluate it as follows:
if ( isset($_SESSION['progress']) )
{
//write your if (or switch) statement here
}
Let me know if that makes sense or if you have any questions :)

PHP code to find an IP location from the IP entered through a input box [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to make a custom code which will help me to find location of a particular IP entered through a text box.
When I searched the internet what I found is only providing automatic detection of IP and it's location. Please help me.
I am using this code in my website
Please try it yourself -
<?php
function countryCityFromIP($ipAddr)
{
$url = "http://api.ipinfodb.com/v3/ip-city/?key=5cfaab6c5af420b7b0f88d289571b990763e37b66761b2f053246f9db07ca913&ip=$ipAddr&format=json";
$d = file_get_contents($url);
return json_decode($d , true);
}
if(isset($_REQUEST['submit'])){
$ip=countryCityFromIP($_REQUEST['ip']);
//print_r($ip);
echo $ip['cityName'];
}
?>
<form method="post">
<input type="text" name="ip" />
<input type="submit" name="submit" value="Find" />
</form>
please use print_r($ip); to get the details which parameter will get from the url.
Take a look at the MaxMind GeoIP database. A tutorial for that one can be found at http://www.phpandstuff.com/articles/geoip-country-lookup-with-php. There are various other databases available as well. For that take a look at https://stackoverflow.com/search?q=geolocation+%5Bphp%5D

Facebook textarea functions [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I would like to know how you add a function that clears the contents in the textarea if something is typed. For example, the standard message in the textarea would say: "Type something...", but if something is typed, the textarea would be cleared. Basically, the same function that Facebook uses in their wallpost-textarea.
And how do I make the height of the textarea automatically follow the amount of text, so no scrollbar is needed. Again, the same function that Facebook uses in their wallpost-textarea.
Actually, I've noticed that the function that clears the contents in the textarea/input field is used on this site's signup page, when you entering your e-mail, password etc.
I hope that some of you can help me. I've tried to find a script about it but without any luck!
The first thing is a (HTML5) placeholder attribute. It is a message that is there by default and when you start typing it goes away.
http://www.w3.org/html/wg/drafts/html/master/forms.html#the-placeholder-attribute
For the second one you need some JavaScript.
$('textarea').on('keyup',function(e){
$(this).css('height',$(this).get(0).scrollHeight);
});
Probably not the best solution but you could try something like the following.
<script>
function textAreaAdjust(o) {
o.style.height = "1px";
o.style.height = (25+o.scrollHeight)+"px";
}
</script>
<textarea cols="50" id="textAreaAdjust" style="overflow:hidden" placeholder="Type something..." onkeydown="textAreaAdjust(this)"></textarea>
jsfiddle example

Categories