2016년 11월 20일 일요일

uploading Apache (Xampp) PHP file with app inventor



I have trying to upload a PHP code using WEB tag, Below is my PHP code.

<?php
$userName = $_GET['userName'];
$answer = "Hello from the web page sideee !!!!". $userName;

echo '$answer';
?>


I just want the username to be displayed in the label present in my app.
I have been getting this error which I attached. Also I have attached my blocks code. 

I'm using XAMPP control panel  v3.2.2. Is it the issue with my PHP code ? should I add permission request to the php code for XAMPP ??.

Please help!

web.PNG 표시 중
 error.png

--
I think its a problem with the url.
Upload the php file to a webserver and than write again the new url in the urltext.

--
So, in order for this to work, you must have your PHP code (hello.php) located at c:xampp/htdocs/tutorial/ or similar
If you have that, point your browser to http://localhost/tutorial/hello.php?userName=John
What do you see?

If this works as expected, try your app again. If your name could contain blanks or special characters, you have to encode the URL before you use it to send to the server.
Use the Web UriEncode block for this:


text UriEncode(text text)
Encodes the given text value so that it can be used in a URL.

Cheers, Ghica. 

-- 
as Mika said, it's a problem with the url
localhost in this case is your device itself, but not your computer, see also here  https://en.wikipedia.org/wiki/Localhost
use the ip address of your computer instead, this usually starts with 192.168.x.x

Taifun

-- 
Thank you so much guys, 

I made few changes and I achieved my desired output! 
Thank you Taifun I added my computer IP and it worked. 
Also I made mistake in my PHP code i.e when I echoed my $answer it was in underscore. 

It works!!!!

-- 

댓글 없음:

댓글 쓰기