Forum Moderators: coopster

Message Too Old, No Replies

how to open page

         

Sarah Atkinson

3:35 pm on Oct 27, 2005 (gmt 0)

10+ Year Member



I want to send the browser to a differnet page how do i do this with php? it's an if statment

if true send to example1.com else send to example2.com.

[edited by: jatar_k at 3:53 pm (utc) on Oct. 27, 2005]
[edit reason] examplified [/edit]

jatar_k

3:53 pm on Oct 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> send the browser to a differnet page

based on what criteria?

Sarah Atkinson

4:18 pm on Oct 27, 2005 (gmt 0)

10+ Year Member



i've got the criteria but I didn't think it was pertinent to the question.

it's weather or not my mail thing works or not.

if it works I want it to go back to the main page and if it doesn't work I want it to go to an error page. or something... actualy if it doesn't work I don't know where I want it to go to lol.

gsnider

4:20 pm on Oct 27, 2005 (gmt 0)

10+ Year Member



Make a page named www.yoursite.com/page.php with this code in it:
<?
if ($_REQUEST['id'] === true) {
header('Location: page1.php');
} else {
header('Location: page2.php');
}
?>

Type in www.yoursite.com/page.php?id=true
and you will go to page1.php otherwise, you'll go to page2.php

jatar_k

4:28 pm on Oct 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



another way is

if (some test) $nextpage = 'page1.php';
else $nextpage = 'page2.php';
header("Location: $nextpage");

Sarah Atkinson

4:54 pm on Oct 27, 2005 (gmt 0)

10+ Year Member



for some reason it's not working

Sarah Atkinson

4:57 pm on Oct 27, 2005 (gmt 0)

10+ Year Member



Got it to work thanks

gsnider

8:34 pm on Oct 31, 2005 (gmt 0)

10+ Year Member



post the solution so people with the same problem can see how to solve it.

thanks

ruffain

6:38 am on Nov 2, 2005 (gmt 0)

10+ Year Member



HI i'm about 3 weeks into PHP and sence Sarah didn't reply as to how she got this to work.I have 3 questions. My email form works but it throws up a plain white page with Thank You and i did add echo to display my email address aswell. I would like for it to go to my home page instead of this white page when the mail is sent. My email form is on my contact page.
Question 1. Can i add this scritp to the contact page and call page2.php /contact.html and page1.php /main.html?
Question 2. where do i type this www.mysite.com/page1?id=true
Question 3. Do i put this in my mail.php script aswell.

Thank you in advance for any help.

gsnider

7:52 pm on Nov 4, 2005 (gmt 0)

10+ Year Member



Add this to the page you send the e-mail message.

<body onLoad="location.href='home.php'">

NomikOS

6:33 am on Nov 5, 2005 (gmt 0)

10+ Year Member



I don't understand you very well ruffain. But another way to do what gsnider said is:


<?php
# at contact.php
# --------------
/*
send mail successful with your code
and inmediatly after:
*/
header ('location: [mysite.com...]
exit;
/*
without footer of any kind! see the exit instruction.
*/

# at beginning home.php
# ---------------------
if (mailSendingOk == 1)
{
say 'thank you dear user.';
}
/*
continue displaying home content as always.
*/
?>

I use it always in pages with POST request method to avoid resubmitting of forms and that so very ugly pages and so commons like:


[3]Warning: Page has Expired[/3] The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you.

To resubmit your information and view this Web page, click the Refresh button.

What do you think?

ruffain

8:30 am on Nov 5, 2005 (gmt 0)

10+ Year Member



Thank you for your time gsnider and NoMikOS,i tryed both scritps and i couldn't get them to work;When i click the send button i get a Thank u page that ends with mail.php what i would like is a page that ends with the home page that ends with main.html

I may have just not put the scritp in the right place on the emails page .I tryed a lot of deff. places with the same resuilts. Where you had the file highlighted in yellow i put in my page address mysite.com/main.html

NomikOS

6:18 pm on Nov 5, 2005 (gmt 0)

10+ Year Member



I think in that sor of problems you must:

1) separate html from code
2) to reconsider the flow of your code

that's take time but give you much more control over your design and much less headaches.
go ahead!

Sarah Atkinson

3:19 pm on Nov 10, 2005 (gmt 0)

10+ Year Member



I'm sorry for not replyinging as to how I got it to work. I realy need to keep a folder with all my solutions in them. truthfully this was so long ago I don't even rember the problem let alone the solution lol.

It's just been one of thos months

NomikOS

3:55 pm on Nov 10, 2005 (gmt 0)

10+ Year Member



Ok, now i'am at that moments i'm out of the world, but glad for your post.
later we continue with this issue...

---