473,472 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Get File Contents/Source using POST first

5 New Member
I am trying to post a login first then get the source of another page on that same server I posted to in order to get a specific value by element. It is required that you login before you can get the value. Anyways, is it possible before I run file_get_contents on my PHP page to POST to a login script/web service so I can get a specific value instead of the login page itself? Some sample code would be much appreciated.
Feb 9 '08 #1
2 2068
adamalton
93 New Member
Can you clarify this a bit? You want someone to login and THEN let them have access to another page or a value within it, like from a database or something?

Can you not just create a login page and then redirect them to the page that contains the info?

Soemthing like:
login.html
[HTML]<html><body>
<form action="validate_login.php" method="post">
<input type="text" name="username">
<input type="password" name="password">
<input type="submit" value="Login">
</form>[/HTML]
validate_login.php
[PHP]<?php
if($_POST['username']=="valid username" && $_POST['password']=="secret word"){

session_start();
$_SESSION['logged_in']=true;
header("Location: page_with_stuff_on_it.php");
}
else{//if their username/password were not valid
header("Location: login.html");//send them back to the login page
}
?>[/PHP]
page_with_stuff_on_it.php
[PHP]<?php
session_start();
if($_SESSION['logged_in']){//if they ARE logged in
print "secret stuff goes here";
}
else{
print "You are not allowed to see the secret stuff";
}
?>[/PHP]
Feb 10 '08 #2
distraction
5 New Member
Yes, I will try to clarify. The action method to the form is not on my domain, it is on another domain. I would like to pass the login information via action method and once they are logged into that domain--I need to redirect to another page on their domain to get a different form element's value returned to me. The only way to get a cross-domain's element back to me is through a server side proxy which returns the element back to me nicely except I need it to login because if I do not, then the other page on that domain will not give the correct value since the user did not login on that through that same proxy.

I was thinking I could use file_get_contents($_POST['url']) to get the value I need via iframe except if I do a form to login to that domain before getting contents, it will not give me the correct value because the same method needs to login first before getting contents.

I have tried AJAX with some CGI/Perl and maybe that is the most reasonable approach, however, I was thinking there was some clever way to implement this in PHP. Someone once suggested cURL but I did a little research on this and wasn't really too sure how to get it done.
Feb 10 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
7
by: Joseph | last post by:
Hi, I'm having bit of questions on recursive pointer. I have following code that supports upto 8K files but when i do a file like 12K i get a segment fault. I Know it is in this line of code. ...
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box...
1
by: j7.henry | last post by:
I am trying to pull specific data that is in a comma delimited file into a web page. So if my comma delimited file looks like: Name,Address,Zip Fred,123 Elm,66666 Mike,23 Jump,11111 I would...
4
by: Jim Michaels | last post by:
after a file upload, $_FILES is not populated but $_POST is. what's going on here? $_POST=C $_POST=C $_POST=C $_POST=C:\\www\\jimm\\images\\bg1.jpg $_FILES= $_FILES= $_FILES=
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
2
by: hotflash | last post by:
Hi Master CroCrew, I found a good PURE ASP that will allow you to upload 10MB file to the server and the file contents such as Network, Author, Title, etc... will insert to MS Access at the same...
7
by: mohi | last post by:
hello everyone, i have a program where i write a structure of 1020B to a file a number of times and in the next run of the program i have to again write those structures but by taking some count...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.