Return to Home Page????

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SamCec
Forum Newbie
Posts: 17
Joined: Mon Aug 16, 2010 11:43 am

Return to Home Page????

Post by SamCec »

I am new to PHP and trying to learn enough to help me with my web site. I have several pages on my site defined as follows:
These were written using HTML:
Home page = WoodArt.shtml
OrderForm page = Form.html
PHP code page = Test.php

This is what's happening: On the ORDERFORM page when I click the SUBMIT button, the PHP code page is called and executed. When the execution is complete, I have a blank page on my screen. I would like to have it automatically return to the HOME page. Can someone explain to me and show me the code I need to do this?

Thank you,
Sam
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Return to Home Page????

Post by AbraCadaver »

Code: Select all

header('Location: example.com/WoodArt.shtml');
exit;
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
liamallan
Forum Newbie
Posts: 19
Joined: Sat Aug 14, 2010 6:25 pm

Re: Return to Home Page????

Post by liamallan »

put this in the end of ur code:

Code: Select all

header("Location: ../woodarts.html");
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Return to Home Page????

Post by AbraCadaver »

liamallan wrote:put this in the end of ur code:

Code: Select all

header("Location: ../woodarts.html");
No, don't do that. Location headers require a absolute URL (though they may work without one) and why the ../?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
SamCec
Forum Newbie
Posts: 17
Joined: Mon Aug 16, 2010 11:43 am

Re: Return to Home Page????

Post by SamCec »

Everyone: Thank you for your suggestions but using that code, I could not get it to work. I did add this code to the bottom of my PHP code and finally got it to work.

Code: Select all

<meta http-equiv="refresh" content="0;url=WoodArt.shtml" />
Thanks Again,
Sam
liamallan
Forum Newbie
Posts: 19
Joined: Sat Aug 14, 2010 6:25 pm

Re: Return to Home Page????

Post by liamallan »

i use the ../ to take me back to the root folder in case the processing file is in its own directory
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Return to Home Page????

Post by AbraCadaver »

liamallan wrote:i use the ../ to take me back to the root folder in case the processing file is in its own directory
Suppose it's 2 directories deep :)
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
liamallan
Forum Newbie
Posts: 19
Joined: Sat Aug 14, 2010 6:25 pm

Re: Return to Home Page????

Post by liamallan »

works if its 3,4,5,6 or 7 directories deep.

infact u can have as many directories as u want :crazy:
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Return to Home Page????

Post by AbraCadaver »

liamallan wrote:works if its 3,4,5,6 or 7 directories deep.

infact u can have as many directories as u want :crazy:
What?
http://www.example.com/index.php is the home page.

http://www.example.com/content/products/index.php contains this code:

Code: Select all

header('Location: ../index.php');
Will not take you to the first URL, you would need to use ../../ which is very confusing to use many different relative paths in many pages when simply using http://www.example.com/index.php in any page works as intended. :D
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply