Current location: Hot Scripts Forums » Programming Languages » PHP » how do i make php open another web page?


how do i make php open another web page?

Reply
  #1 (permalink)  
Old 10-30-03, 10:50 AM
wonderland wonderland is offline
New Member
 
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
how do i make php open another web page?

Hi

Totally basic question (total newbie to php and programming!)

what is the code to open other web pages in php?

after someone submits a form i want php to go to a page if
they leave a field blank for example, rather than just echo
out "you have not filled in your name"

as the visual style jumps from nice web page to crappy white
web page with unformatted text etc.

will be sooo grateful if someone could help!

Cheers.
Reply With Quote
  #2 (permalink)  
Old 10-30-03, 12:35 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
didn't get you idea quite well , but this is a looong story
you can use the form action in the page you want to submit your info to ..
like :
Code:
<form method="POST" action="page.php">
and in this page.php make an IF statment to see if the fields were fell down or show the error message ,, a basic example of what you need:
PHP Code:

<?php

$user
=trim($_POST['username']);
$pass=trim($_POST['password']);

if ( !
user OR !pass ) {
echo
'you didn\'t fell all fields required ..';
} else {
//PUT REST OF SCRIPT HERE ..
}
you can format the output using the simple HTML <b> , <u> , <i> and <font> to format your output ..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]

Last edited by NeverMind; 10-30-03 at 12:37 PM.
Reply With Quote
  #3 (permalink)  
Old 11-01-03, 08:11 PM
darton520 darton520 is offline
New Member
 
Join Date: Aug 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
At the top of your form page, you could put:
<?php echo "$result"; ?> <?php echo "$result2"; ?> etc. the rest of the first line

Make sure not to break after the php snippet or it will have a blank line or two at the top of your page. Use double quotes so if $result is blank, it will not do anything.

On the action page, you could use this:

if((empty(inputname1)) || (empty(inputname2)))
{
if(empty(inputname1))
{
$result= 'put what you want your mesage to be here';
}
if(empty(inputname2))
{
$result = 'put what you want your second mesage to be here';
}
include 'your form page';
exit() //exits the script so it don't let the user proceed, or add info to your db
}
else
{
the rest of your script goes here
}
Reply With Quote
  #4 (permalink)  
Old 11-03-03, 03:03 AM
wonderland wonderland is offline
New Member
 
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Ah.

I knew this would get confusing...

So far the page works fine and reads an error message when the
required fields aren't filled in. But i have a pretty little frameset
which suddely is replaced by a horrible white page with non
formatted text saying "error: you didn't fill in your name" and this
looks very unprofessional. I am ofcourse using the 'if name field
is equal to zero, then echo "bla bla" '

So i need some code which, instead of echoing some text, actually
opens a web page which i have designed to look consistent with the
rest of the site.

Surely there must be some code which says

open ("/my_web_page.htm");

thanks guys.
Reply With Quote
  #5 (permalink)  
Old 11-03-03, 03:20 AM
wonderland wonderland is offline
New Member
 
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Its ok, Its ok.

I saw a similar topic on the subject, what i'm looking for is:

header("Location: http://url.com");

Which i use for positive confirmation and didn't stop to think
I could use it for negative confirmation


thanks anywho!
Reply With Quote
  #6 (permalink)  
Old 09-23-08, 06:51 PM
artwyse11 artwyse11 is offline
New Member
 
Join Date: Sep 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb Redirect to another page from a PHP file

Hi
Just use an hybrid code HTML and PHP - in fact PHP support HTML - and use the redirection capability of HTML with the META tag or by adding some javascript. It will still stay an PHP file that will execute the PHP code and the additional HTML and even Javascript.
If that is not enough, ask, I will give you more detail.
Reply With Quote
  #7 (permalink)  
Old 09-23-08, 06:55 PM
artwyse11 artwyse11 is offline
New Member
 
Join Date: Sep 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
I am sorry I didn't read you last message. header work as well.
But the advantage of using the META tag is that you can display a message for few seconds - like a thank you message - using that same php page and then redirect to another page.

Last edited by artwyse11; 09-23-08 at 07:22 PM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 3 (0 members and 3 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to make money w PHP? jv2222 The Lounge 73 07-06-09 11:06 PM
Input button to open new page modgen JavaScript 1 08-11-04 10:05 AM
need to make a confirmation page codeguru21 PHP 1 10-02-03 04:18 PM
Open source PHP Mail Script jewellgr Website Reviews 1 08-18-03 03:30 PM
How to make the index.html page for each categories ? vuzzan PHP 2 07-01-03 05:35 AM


All times are GMT -5. The time now is 07:21 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.