admash
asked on
Sending a response header to php script
Hi, 'sperts!
I have inherited a subscription based site that uses both php and perl/cgi for user management. I have a php script that will post to a cgi/perl script that searches for a specific username. The current perl script simply prints out the results. What do I add to the perl script so that it sends the result variable back to my php script?
The perl script is:
$name = `cat /path/to/my/list|grep -i "(results from form)"`;
$name =~ s/\n/<br>/ig;
print $name;
What do I need to change the "print $name" so that the result is sent (GET is fine) to a php script? Something like in php:
header("Location: http://www.mysite.com?name=results/");
I have inherited a subscription based site that uses both php and perl/cgi for user management. I have a php script that will post to a cgi/perl script that searches for a specific username. The current perl script simply prints out the results. What do I add to the perl script so that it sends the result variable back to my php script?
The perl script is:
$name = `cat /path/to/my/list|grep -i "(results from form)"`;
$name =~ s/\n/<br>/ig;
print $name;
What do I need to change the "print $name" so that the result is sent (GET is fine) to a php script? Something like in php:
header("Location: http://www.mysite.com?name=results/");
ASKER
No, there is no html present in $name, obviously there is a lot of cleaning up I need to do to the code. I am inexperienced with perl, however. I have been using php for a while now.
What I am getting is:
Location: http://www.mysite.com?name=all of the results
in my browser now. what do I need to do to actually send the url?
What I am getting is:
Location: http://www.mysite.com?name=all of the results
in my browser now. what do I need to do to actually send the url?
ASKER
Let me be a little more specific:
This is what needs to happen:
checkuser.php
This script checks current sales and finds expired accounts
When it finds expired account, I need to see if the username is still active.
This php script sends form info via post to findthisuser.cgi written in perl for a search
findthisuser.cgi
Takes the POST info and searches (the script is above).
I need this script to either return the search results to checkuser.php, OR
send a yes or no variable to checkuser.php to let me know that the username is there or not.
Maybe that will help make some sense. This is a convoluted way to handle this, but I am working with some tight requirements as to what I am allowed to change.
All of this works great so far, but I need to change the last part of the perl script so that it sends the appropriate response back to my php script.
This is what needs to happen:
checkuser.php
This script checks current sales and finds expired accounts
When it finds expired account, I need to see if the username is still active.
This php script sends form info via post to findthisuser.cgi written in perl for a search
findthisuser.cgi
Takes the POST info and searches (the script is above).
I need this script to either return the search results to checkuser.php, OR
send a yes or no variable to checkuser.php to let me know that the username is there or not.
Maybe that will help make some sense. This is a convoluted way to handle this, but I am working with some tight requirements as to what I am allowed to change.
All of this works great so far, but I need to change the last part of the perl script so that it sends the appropriate response back to my php script.
if you are seeing the literal words:
Location: http://www.mysite.com?name=all of the results
in the browser this means you have already printed an http header before executing the print "Location:....\n\n" command.
You may also need to uri encode $name before sending it out in the URI string.
print "Location:....\n\n";
is the same as the php function:
header("Location: http://www.mysite.com?name=results/");
Location: http://www.mysite.com?name=all of the results
in the browser this means you have already printed an http header before executing the print "Location:....\n\n" command.
You may also need to uri encode $name before sending it out in the URI string.
print "Location:....\n\n";
is the same as the php function:
header("Location: http://www.mysite.com?name=results/");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
(slaps self on forehead)
$name = shell_exec('cat /path/to/my/list|grep -i "(name I am looking for)"');
It works like a charm.
That's why I like EE. You guys always take seemingly complicated things and make them so simple. I hope some of this rubs off on me!
Thanks Perl Diver for your patience, knowledge and willingness to share!
Aaron
$name = shell_exec('cat /path/to/my/list|grep -i "(name I am looking for)"');
It works like a charm.
That's why I like EE. You guys always take seemingly complicated things and make them so simple. I hope some of this rubs off on me!
Thanks Perl Diver for your patience, knowledge and willingness to share!
Aaron
You're welcome.
$name =~ s/\n/<br>/ig;
print "Location: http://www.mysite.com?name=$name\n\n";
does $name really contain html code in it?