Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

How to access data from server through client script ?

Links for php scripts

Moderators: macek, egami, gesf

How to access data from server through client script ?

Postby Antrikssh » Wed Aug 22, 2012 10:17 pm

Hello,

I have created 2 script one for client and another for server. In the server script I have defined some opertaion like (+, -, *, /) and run the server script on my machine. Now server script run on my machine as a service.

After that I have created client side page say client.php. In which I send request of 2 number addition by using form. But in the "action = server.php" its reloads the server script that I dont want to do. Beacuse server.php is already run on my machine.

If there is any technic in php by that I will perform operation without reload the server.php script through client.php then please tell me.

Thanks and Regards,
Antrikssh Mishra... :)
Antrikssh
New php-forum User
New php-forum User
 
Posts: 22
Joined: Wed May 02, 2012 5:27 am

Re: How to access data from server through client script ?

Postby Nullsig » Thu Aug 23, 2012 8:10 am

You cannot access server-side information using client side scripts. The closest you can get is using AJAX to issue invisible requests to the server and returning them to the currently loaded page.

You will need some way to save state, typically that will involve session variables.
User avatar
Nullsig
php-forum Fan User
php-forum Fan User
 
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: How to access data from server through client script ?

Postby Antrikssh » Thu Aug 23, 2012 10:54 pm

Hello,

I dont want to use AJAX, Is there is any solution in php for my work. I have worked with session variable. I got one issue can you please tell me the solution of that. I have created two script in which I have used session variable I will send my script to you.

/******** Input.php *********/
<?php
session_start();
var = 50;
$_SESSION['var'] = var;
?>

/********** Output.php **********/

<?php
session_start();
print $_SESSION['var'];
?>

when I execute both of the script by using browser ("http://localhost/Input.php" then "http://localhost/Output.php" ) its work according to the code. But when I execute it with command prompt ("php Input.php" then "php Output.php") then is gave output

Undefined index: var in /path to/the file/Output.php
I searched for this problem and found that session_start() is not work with command prompt. Can you please tell me the solution for that.

Thanks and Regard,
Antrikssh... :)
Antrikssh
New php-forum User
New php-forum User
 
Posts: 22
Joined: Wed May 02, 2012 5:27 am

Re: How to access data from server through client script ?

Postby Nullsig » Fri Aug 24, 2012 8:12 am

AJAX is really the only solution to access server side data on the client. You cannot touch the server data from the client without executing a new server-side script. That will either involve a full page refresh or an AJAX function.
User avatar
Nullsig
php-forum Fan User
php-forum Fan User
 
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: How to access data from server through client script ?

Postby Antrikssh » Fri Aug 24, 2012 8:28 pm

Hello Nullsig,

Thanks for giving me your precious time. Yesterday I was found the cause of problem that I sent you in my last post. I found that when I was run both of the script through browser then at that time web server is helping me to mentain my session variable but when I was run from the command prompt then nothing is there to mentain my session because of that I think session variable is not working on command prompt.

But Dear Nullsig I want to run my server script from command prompt which run as service and the updated value I will get from client side by using php only, not by AJAX.

Thanks and Regards,

Antrikssh... :)
Antrikssh
New php-forum User
New php-forum User
 
Posts: 22
Joined: Wed May 02, 2012 5:27 am

Re: How to access data from server through client script ?

Postby sufalamtech » Tue Aug 28, 2012 5:20 am

You can easily run ajax programming in client scripts then upload it via ftp server detail and you can easily access from there.
User avatar
sufalamtech
New php-forum User
New php-forum User
 
Posts: 1
Joined: Wed Jul 27, 2011 1:12 am
Location: india


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.