Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Directing Server Php Return Page


How do I have the server-side php script open up a new client window, rather than having it return to the client page that invoked the php script in the first place? I want to preserve the original client page. Or if I could do it, better yet, is there a way to have the php script return to the
same window, but a new page, thereby preserving the original client page?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Re-Directing Back To "Sort After" Page&
I am using sessions and a MySQL user database to restrict users to certain pages on a website. If the user has not logged in and tries to access a protected page they will get the login page.

Now if they are trying to acess a page like specials.php and they have to logon to access that page, then they get the login page and they then enter login details to access it. If their login is correct, I send a header Location to the Index of the site. How do I direct the user to the page they were looking to access(specials.php) without getting directed to the index.php page. I want to implement this function to all the restricted pages. I know its something pretty simple... maybe keep the url of the "sort after" page in a variable and then re-direct to that page after login ? Can someone give me a hint

Thanks

Directing Web Forms
i want to make a web form but i want 4 pages to this form

1. password login page
2. enter your membership number
3. if membership # is from 1-10 then go to www.form1.com
4. if membership # is from 11-20 then go to www.form2.com

how would i do the if statements?? to get the code to recognize the range??

How To Return A Cookie To Server?
I am trying to retrieve a page from a server which sets a cookie on login, then only allows pages to be served when the cookie is returned. I have had a look at the cookie, it is in the form 'username=zzz&password=xxxx'.

fsockopen is used to connect to the server and then fputs is used to send header info. I'm just guessing on how to construct the header. I have tried to send the cookie header in this form:

'Cookie: username=xxx&password=xxxxx',
also like this:
'Cookie: username=xxx; password=xxx'.

I get bad request errors each time. Can anyone give me an example of sending headers that includes returning a cookie?

Return Results On One Page
i have a search field on a .php page. i want to return the results on the same page i.e i dont want the action to point to test2.php but test.php which is were my search filed is sitting at the moment. how do i do this? 

i got this on my first page:

<form method="post" action="test2.php">
Name: <input type="text" size="10" maxlength="40" name="name">

<input type="submit" value="Send">
</form>

and this on the second:

<?php
$name = $_POST['name'];
if ($name=="Friday")
  echo "Have a nice weekend!";
elseif ($name=="Saturday")
  echo "Tomorrow is Sunday!";
else
  echo "Please enter Friday or Saturday";
?>

Return To The Previous Page In Php?
How to return to the previous page in php?

Paypal Page Return.
so, on my site, users are allowed to donate. When they donate (via paypal) they are directed back to the processing page. I use this:

if($_SERVER[HTTP_REFERER] != 'https://www.paypal.com/cgi-bin/webscr') {
echo "<center><b>Error.</b> ";

to check to see if they came from paypal, which prevents false donations / receiving the donation item multiple times with one payment.

BUT, It does not work . Is there any other way to secure that only one donation item is given?

Return All Instances Of A String Within A Page...
I'm looking to do this, but is it possible?:

A page to be downloaded via file_get_contents which has stuff similar to
the following in :

<a href="file.php?name=Widget1">Widget1</a><br>
<a href="file.php?name=Widget2">Widget2</a><br>
<a href="file.php?name=Widget3">Widget3</a><br>
etc.

I would like to be able to create an array which contains all the strings
between <a href="file.php?name=Widget1"> and </a><br> (The link text)

so
<a href="file.php?name=Widget1">Widget1</a><br> => Widget1

So that $linktext[0] = Widget1, [1] = Widget2 etc.

Is this possible, if so, how?
I've looked at preg_match_all, but can't see how to output multiple matches
of text *between* two strings to an array.....

Return Search Results On Same Page
I'm struggling with this much longer than I think I need to,

How do I make the results of a search display on the same page as the
search, sort of beneath the 'submit' button? Thanks for helping out.


Function That Will Return The Url Of Every Page I Have In My Domain?
Is there a php function that will return the url of every page I have in my domain? I am creating a sitemap to send to google and I really don't want to have to copy and paste 500+ urls.

How Do I Return 10 Results Per Page Using SELECT Statement?
I'm wasn't sure whether to post this under the PHP or under the MySQL section of the forums. Since most people (I'm assuming) who write PHP script, also use MySQL, I thought I'd stick with PHP. I'm rather new to both PHP and MySQL and I'd be very grateful to anyone who can help me solve a problem I'm having at the moment. First, I'll give you an introduction to my little project...

I'm developing a database in MySQL that is used to store the song titles of all the MP3s I have on my PC. I've written a basic search feature that works well. The user has 2 options: Either he can type a special "!ALL" "parameter", that I made up, to return all the songs in the database or the user may enter a few characters in the textbox and select "song title" or "artist" etc. from a dropdown to search for a specific song title or artist etc.. Hope you are following so far? Say for example the user presses submit after typing "!ALL" to return all the song titles - there could be hundreds of results. What I want to do now is display 10 results on a page, then on the next page another 10, etc. (like a real search engine!). I've tried doing it with the LIMIT statement, but like I said I'm new to this and discovered that that is not the right way of going about it. My question is this: how would I go about returning 10 matches per page? Do I use hidden form fields? What would the SELECT statement look like? What would the PHP scripting look like to setup the "back" and "forward" navigation between the result for the search?

How Do I Setup Php Script To Return A Browser Page?
I want the server-side php script to return a browser page that is essentially a copy of the
original client page that contained the <form> which referenced the php script in the first place.
However, the php script will need to change a couple html lines in that returned page.

Can A Field Communicate To A Server And Return Information To Another Field Without Retrieving The Whole Html Code Again?
I´ve got a sql table which has 3 fields.
Their relation to each other is like this example.

| CARS | YEAR | PRICE |
ford 2000
ford 2001
ford 2003
volkswagen 1999
volkswagen 2000

I am developing an ASP web page that modifies a specific registry.
So, it loads the information to some fields, but the user will be able
to change only the "PRICE" field.
I have to create two selects, one for "CARS" and other for "YEAR".
But the "YEAR" field will only contain the correspondent years for each
car the user selects. Example: selecting "ford" in the "CARS" <select>
box, only the years "2000", "2001", "2003" would be automatically
loaded in the "YEAR" <selec> box.
How could i implement it?

Random Products On A Page - Like Ads In An Ad Server
We have a table of products that we'd like to show on our content pages. Like ads in an ad server, we want the products to show randomly throughout specific pages. The logic might be something like:

For each page select all the products that match that topic
from this list of products, randomly choose 4 products for each content page

My product table has the following columns:

- productSKU (primary key - unique value - text)
- mytopic (the topic where the product should appear)
- probability_to_appear ( a product with a probability of 2 should show 2x as much as a product with a probability of 1)

My question is - how can I randomly choose 4 products to appear on each individual page?
I know that an ad server can serve weighted random ads. Does anyone know how I could use PHP code to serve weighted random products?

Pb Refreshing A PHP Page On An Apache Server
My problem is that I want to test with a PHP script on a Web server (
Apache ) whether the current displayed page inside the browser should be
redisplayed or not !

To do so, I take the signature of a given image on the server and store
it inside a cookie at the first visit.

When another GET for the same PHP file arrives, I read the cookie and if
the two sigantures are the same, what I want to do is :

- nothing that is the browser should not redisplay the same page

To do this, I put inside the PHP file

- a header call : header("Refresh: 5 ; $SELF");
- then an HTTP header 204 to tell the bowser to do nothing :
header("Status: 204 No content");

Everything works fine at the beginning ! I see with Live HTTP headers
that I receive the two headers and I wait for the refresh after 5
seconds but it never happens!

Page Not Found On Secure Server
I have several php pages on a secure server with hyperlinks or form buttons connecting the pages. All of the links are absolute (https://full.url...). The pages work well as long as I don't leave a page on the screen for more than ~ a minute. If the page is on the screen for any length of time, when I click the hard coded link, I see the following error:

The page cannot be displayed The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings. If I refresh, everything works ok again. It only occurs with secure pages.

The timeouts on the server are set the same as all of our other servers, so it doesn't seem to be a page timeout problem. The hyperlinks are absolute and are correct because they work when I refresh any page. I checked the logs and there are no 404 errors (or other errors)showing in the server error log. Code:

Check If The Page Exists On A Server
i have a set of links and that will be scrolled monthly, and i want to check if any of the links are broken and want to mail the broken links to the admin. now how do i check if the links are broken ?

Loading Page Makes My Server Reboot
I have a simple page with a bit of php code on it. The code is below: PHP Code:

Display Message Page During Server Side Processing
what is the standard way to "push" an intermediary message HTML page to the user while a server side process executes?

for example, in many forums such as this one, you get an HTML page containing a message, like below, that displays while the application completes its process.

"processing your post please wait and you will be returned to the forum".

Then after the server side process is complete, it sends up the final result of the process, in the case of a forum, returning you to the thread you started or responded to.

I plan to use something similar for file upload scripts so the user will have some sense of the status of the upload continuing, then finally receiving a message that upload was successful or failed due to some error.

Can this be done through one script printing out two different HTML pages each with their own HTTP header?

Redirect Page On Remote Web Host When Local Server Is Offline
Hope some one can help . I have my web site hosted on powweb (my remote web host)and I want a user to be redirected when they access my local server through a link on my remote web site to another page on my remote web site when my local server is offline.

Test Server To Live Server - Best Way Of Handling Different File Paths In Scripts?
I have taken over someone else's PHP code and am quite new to PHP. I made
some changes and have implemented them to a live environment fine so far.

However, I now want to setup a test environment. All the PHP scripts start
with a few lines of:

require_once "library file at specific location on server"

and when I move them from the test location to live location I have to
manually apply the changes to each script to reflect the different paths for
each server.

I was thinking of writing a small script that is contained within the same
folder as any folder that contains scripts that actually calls another
require for that server .

E.g.
Have script do_something.php which I am developing regularly.
On live server it starts with
require_once "/home/live/phplib/library.php";
On test server
require_once "/home/test/phplib/library.php";

Currently I apply a manual change this (via global change or whatever) when
moving from Test to Live
However, I might just change all requires to:
require_once "./require.php";

And then have a server specific version of require.php that contains the
necessary requires for the particular server on which it resides.

This way I can just change all the scripts to just require the require.php
file in the same folder as itself. The actual PHP scripts where I do most of
my updates need no changes whether on live or test servers.

I just wanted to know if there was a better way of doing it then this. I
know nothing about directives in PHP or if there was a way of determining
the current server name and then calling different require commands
appropriately.

SMTP Server - Sending Post From Php Script On Linux Server
Does any body know why send() is returning false..
where are the additional settings of SMTP server?

Code Output On Home Server Differs To Hosted Server
I just installed Apache, PHP and MySQL (all apears to work ok) on my WinXP machine at home. Apart from a few notice messages, the script mostly ran fine, except one of the forms. I simplifed it to a minimum, but it still doesn't work on my home server (tho it does on my hosted space). PHP Code:

Php MySQL Works On Remote Server, Only Partially On Local Server
code to populate form select fields with data from a MySQL database, so a user
can use those to sort/filter and view the 3,000 records. No inserts --
just selects; very simple.

I originally set this up using URL-based query strings at
http://stjuliana.org/school/ar/BUindex.php but since that only allowed
sorting and not filtering, hence all 3k records load, I made a form
verson at http://stjuliana.org/school/ar/index.php . Everything works
just fine, however, there's still a lot of tweaking I want to do, such
as splitting the form input and output into two pages (_blank), having
a printable version, etc. To that end I just set up the latest builds
of Apache, php and MySQL on my local Windows XP box, lest I blow my
beer budget for the month on bandwidth overage. <g>

I have a very simple page I used to test my localhost setup and
everything's fine. I can connect to MySQL, create, insert and select
from DBs, so I know my config is fine. All my other .php pages on this
site work fine locally as well.

The two abovementioned pages, however, are giving me fits when run
locally...

For the URL-query-string version, it loads up with the default view
(=name_ns), which grabs all records and sorts by name and point asc.
No matter which of the other sort 'views' I might choose, it still
loads up all the records in that default sort. The server's holding on
to something and I don't know how to clear it. The remote version
correctly sorts based on the query string chosen.

The form version is worse. It connects to the DB and populates the
select boxes with the field data -- that part's fine. But no matter
which submit button is selected, no data is retrieved. I get no error,
but no data either. The form's action is set to $_SERVER['PHP_SELF']
and I've tried both GET and POST -- no change.

Since the exact same pages work on the remote server I know it has to
be something on the local setup. But where do I look if there's no
obvious error?

This is probably something incredibly basic but I'm bleary-eyed from
reading tutorials and forums all over the Internet and can't come up
with anything.

Server Status Script That Works Behind Proxy Server?
My company uses a proxy server so my server status script only works internally. I can't check the status of a server on the Internet because of this. Is there a script (paid even) that allows me to go through the proxy server to see an external server?

Pages Loading From Test Server Then Online Server?
The one problem I am getting is that when I load up the website on my home server it loads in fine and then when I try to load another page it gets the page from the online website. It carries on with this alternating routine and I cannot find out why.

Setup files appear unchanged and the only thing I have changed are some of the PHP files and after it started doing this strange thing, I copied the original files back to see if that changed anything but no difference was seen. I am not even sure where to look for this problem let alone put it right.

Return A Value
i got a functions and it echos out a result, the problme is if i make the functions into a string it still echos out the result at the spot where the string is at. Code:

Return 0
I have a little function that gets a result from a query when supplied arguments, it works great except when the result is 0. Here's the func : Code:

Passing A Value (eg Id) From A Apache Server To A Windows Server
I am trying to pass an Id from one server to another. The case is like this I have two scripts one in php and the other in asp. I am trying to combine the both together by passing an Id from php script to an asp script. The problems come on the client side because the information is on two different servers. Is there a way around this? Can this be accomplished?

Website/PHP App On One Server; MySQL DB On A Different Server - Feasible?
I just inherited an ASP site project currently running off of a
Microsoft Access DB which I'd really like to convert to MySQL/PHP.
The only problem is that the site's host only supports Microsoft
Access and SQL DBs. MS SQL is simply not an option for us at this
time and the site is getting enough traffic that Access's 10
concurrent connection limitation is going to start to become an issue
in a hurry. This client recently renewed their annual subscription
for hosting services from the aforementioned provider so switching
hosts is not an option at this time.

I'd like to convert the Access DB to MySQL and host the DB on my
host's server while maintaining the asp/php site on the current host's
box but am worried that it will dramatically increase the time it
takes to process the asp/php scripts. It this sort of setup generally
frowned upon? Is there any way of estimating script processing time
without implementing the setup I've described and testing it
thoroughly? I should mention that the script is a very basic "SELECT"
query that simply pulls info from a database; it is nothing complex or
extremely taxing resource, server or bandwidth wise. Am I completely
off my rocker?

E-mail From Linux Server But Not Windows Server
The following one-liner sends mail from a Linux server but not from their Windows server.

mail ("admin@mydomain.com", "Subject", "body");

What do I need to check / change, please?

Return MAX Value From Array
I need to return the county with the greatest score with the following long query:

Class Does Not Return A Value
My first time working with a PHP class, and after 6 hours of working out the
kinks I am unable to return a value from the class, so now I appeal to the
general audience what on earth did I do wrong this time?

This is the code the retrieves the values:

What Can Return The ENTIRE Url?
I'm looking for PHP equivalent to Javascript's location.href property. This returns the ENTIRE url (including any variables that might be submitted to a script). I've looked at phpinfo(), but I didn't see exactly what I am after. If the answer is the HTTP_POST_VARS variable, could someone please give me a simple example of how exactly this variable is to be used in code?

Return Statement
What happens when you take the value returned by a function that
doesn't return a value? For example,

function myfunc($myvar) {
if ($myvar == "xyzzy")
return(1);

return;
}

$abc = myfunc("def");

I know from my days of c programming that this would be very bad to
do. But php gives you so rope I'm wondering if you could just do an
isset($abc) to see if myfunc returned a value.

If so then we could write (scary) code where on an error condition
instead of returning something like -1 you just don't return a value.

Return $$ From Function
How can I use the variables generated by the following function in my code? They're just not being passed to the main script. I've tried global $$k; bu that did nothing PHP Code:

Return Mail
I have Apache and PHP in a Linux server. I am using the mail() function from PHP to send mail in a webpage. How do I deal with returned mail? (eg. wrong address) How can I specify what address returned mail is sent to?

Return Row # With Each Array Value?
Does anyone know how to output an array from a MySQL query, but tack on an incremental value to the end of each variable that represents the row number? I'm looking for something like this:

// query stuff here
// Now I output the query result:
while ($fetch = mysql_fetch_array($result)) {
echo "&quoteBody(CURRENT ROW NUMBER)=".$fetch["quoteBody"]."&quoteDate(CURRENT ROW NUMBER)=".$fetch["quoteDate"]."&quoteWriter(CURRENT ROW NUMBER)=".$fetch["quoteWriter"]."";}

Of course the (CURRENT ROW NUMBER) references are what I'm looking for. The way I have it now, PHP outputs an ampersand-delimited string representing all fields in the database. Output looks like this now:

&quoteBody=This is the body of the quote&quoteDate=08/11/01&quoteWriter=Mike&

I'd like to find out how to make it look like this:

&quoteBody1=This is the body of the quote&quoteDate1=08/11/01&quoteWriter1=Mike&

You get the idea. Anyone know how to do this?

Return Variables
I have "index.php" that includes "func.php" (global functions) as well as "p_rand.php" (random product generator). I execute a function (of "func.php") from "p_rand.php" and assign the value to a variable I'll use to do statistics, but the value does not return to "p_rand.php".

I can print the value from "func.php", but when I try to return the value the script appears to stall and the page times-out. I need to get the value from a function in "func.php" back to "p_rand.php". Anyone have any ideas why this might happen, and how do I fix it?

About Return A Array
When I write this codes:

<?
function r_array(&$array){
for($i=1;$i<5;$i++) {
for($j=1;$j<5;$j++) {
$array[i][j] = "d";
}

}
}

r_array($array2);
print_r($array2);
echo $array[1][1];
?>

it display in the brower like this:

Array ( [i] =Array ( [j] =d ) )

And this means $array[1][1] can't be used. And what's the problem?

I want return a 2D array and use it like $array[1][1],what should I
do?

To Return A Function?
If you guys have a function that doesnt return anything, do you still include a 'return;' statement at the end? Is it good practice todo so or pointless?

Return Values
I have an idea about returning variables.

in 1st page, there's variable "x1". it's action page is B.
So, I can use "x1" in B.

$x11 = (int)$_POST['x1'];

B's action page is C

In that case, I want to use "x1" in C.
So, can I save "x1" in B and use it in C?

for exmaple, can I use following commend in C?

$x22 = (int)$_POST['x11'];

Mysql_query Return Value
I know the following $sql will fail since there is no Customer='Smith'. I
want to determine how to test a failure of mysql_query.

I thought mysql_query returned false if a query failed. The test fail path
is never taken in the following code is never taken.

Also, I get an invalid argument on mysql_num_rows($Result) error message.

$sql = "Update Table Set Password='password' where Customer='Smith'

$Connection = mysql_connect("localhost", "User", "PW") Or
die(mysql_error());

$DB = mysql_select_db("Database", $Connection);

$Result = mysql_query($sql, $Connection) or die(mysql_error());

if(!$Result) {

echo "Fail<br>";

}

$Rows = mysql_num_rows($Result) or die(mysql_error());

if($Rows > 0) {

echo "Success Rows: $Rows<br>";

} else {

echo "Failure<br>";

}

What do I need to do to test for a mysql_query failure?

Return Value Pg_exec
What is the value returned by pg_exec when running an update or insert SQL?

Return Value From Function
I wanted to centralize connection to a MySQL database, so I created a
function that reads (eliminating extraneous)

function connectDB() {
$db = mysql_connect(-------);
mysql_select_db("dbname");
return $db;
}

In my main routine I have

$db = connectDB();
----Database activity------
mysql_close($db);

Return To Html
Trying to write html form program that calls php prog. If php prog has
problem with what was entered would like to return from php to html program.

How To Return A File
In some html code I have the following:

<script type='text/javascript' src='foo.js'></script>

However, I'd like to replace 'foo.js' with something like
"bar.php?file=foo" and have bar.php echo foo.js back to the script
element. Is this possible?

Return Field Name
let's say you have a table that has some dates in it. The field is called DDATE

select DDATE from table blah blah

would return the data in the field. How can you write a query that would return the name of a field and not the data in the field?  I hope that makes sense. Code:

Shell_exec() Return Nothing
I ran into a problem with shell_exec() PHP and all files hosting on Redhat I have a html page that allow me to enter a linux command, then submit, then I get the output print out between $output.

when enter command: ls -l /etc, it a list of file and directory on /etc as expected
however, when I tried to execute my program at /etc/earch/esearch (esearch is executable), I received nothing back.

however when I telnet to server, command /etc/earch/esearch does return some text.
i'm sure php was running as same user as telnet.

Function Return
I have created an image resize code into a function which saves me outputing the code four times as my form has four image inputs.

Anyway at then end of this function I have an echo section that displays the image resized ( 4 in all images as function is called 4 times).

Anyway I would like to return the image name after the function is run, but not sure how to get this info. Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved