PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > Open New URL window
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Open New URL window

Réponse
 
LinkBack Outils de la discussion
Vieux 19/09/2007, 23h50   #1
Andrew Prostko
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Open New URL window

I am new to PHP and to email lists so I apologize in advance.


What I am trying to do is to take a password from user input, check
it to make sure it is == to something, say “burgers”

My problem is, I do not know how to make the Else statement...
How do I get it to open a new url?
I want it IF yes open this page, else open this page
or
If it is not correct then Say the password is incorrect or
something…
Else
Open a different webpage

My last attempt:
---------------
<BODY onLoad="top.window.focus()">

<?php

// Define your password
$password = "burgers";

if ($_POST['pw'] != $password) {

?>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>

<TR>
<TD ROWSPAN=2 WIDTH=50%>

<img src="images/charlee.gif">
</TD>
<TD WIDTH=50% ALIGN=CENTER VALIGN=MIDDLE>
<FONT FACE="ARIAL" SIZE=2><B>You'll need a password to get in here. We're
tryin' to keep out the

riff-raff.</B></FONT><BR>
</TD>
</TR>
<TR>
<TD WIDTH=50% ALIGN=CENTER VALIGN=BOTTOM>
<CENTER>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<br />
Name: <input type="text" name="Name" />
<br />
Email: <input type="text name="email" />
<br />
What is the Current Coupon Password?: <input type="text" name="pw" />
<input type="submit" value="Get Coupon!"/>
</form>
<A HREF="index.html" TARGET="_blank"><B>Return to Char-lees</B></A></FONT>
</CENTER>
</TD>
</TR>
</TABLE>

<?php
}
else{

$file = fopen("http://www.google.com/","r";

?>

<?php
} ?>
---------------

This creates a nice small form with an image to the left.

My problem is, I do not know how to make the Else statement...
How do I get it to open a new url?
I want it IF yes open this page, else open this page

Andrew Prostko
AProstko @ verizon.net

  Réponse avec citation
Vieux 20/09/2007, 00h33   #2
Jim Lucas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Open New URL window

Andrew Prostko wrote:
> I am new to PHP and to email lists so I apologize in advance.
>
>
> What I am trying to do is to take a password from user input, check
> it to make sure it is == to something, say “burgers”
>
> My problem is, I do not know how to make the Else statement...
> How do I get it to open a new url?
> I want it IF yes open this page, else open this page
> or
> If it is not correct then Say the password is incorrect or
> something…
> Else
> Open a different webpage
>
> My last attempt:
> ---------------
> <BODY onLoad="top.window.focus()">
>
> <?php
>
> // Define your password
> $password = "burgers";
>
> if ($_POST['pw'] != $password) {
>
> ?>
> <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
>
> <TR>
> <TD ROWSPAN=2 WIDTH=50%>
>
> <img src="images/charlee.gif">
> </TD>
> <TD WIDTH=50% ALIGN=CENTER VALIGN=MIDDLE>
> <FONT FACE="ARIAL" SIZE=2><B>You'll need a password to get in here. We're
> tryin' to keep out the
>
> riff-raff.</B></FONT><BR>
> </TD>
> </TR>
> <TR>
> <TD WIDTH=50% ALIGN=CENTER VALIGN=BOTTOM>
> <CENTER>
> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
> <br />
> Name: <input type="text" name="Name" />
> <br />
> Email: <input type="text name="email" />
> <br />
> What is the Current Coupon Password?: <input type="text" name="pw" />
> <input type="submit" value="Get Coupon!"/>
> </form>
> <A HREF="index.html" TARGET="_blank"><B>Return to Char-lees</B></A></FONT>
> </CENTER>
> </TD>
> </TR>
> </TABLE>
>
> <?php
> }
> else{
>
> $file = fopen("http://www.google.com/","r";
>
> ?>
>
> <?php
> } ?>
> ---------------
>
> This creates a nice small form with an image to the left.
>
> My problem is, I do not know how to make the Else statement...
> How do I get it to open a new url?
> I want it IF yes open this page, else open this page
>
> Andrew Prostko
> AProstko @ verizon.net
>
>


You might be in need of the header() function in php



--
Jim Lucas

"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare
  Réponse avec citation
Vieux 20/09/2007, 01h17   #3
Richard S. Crawford
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Open New URL window

On Wednesday 19 September 2007 15:50:08 Andrew Prostko wrote:
> My problem is, I do not know how to make the Else statement...
> How do I get it to open a new url?
> I want it IF yes open this page, else open this page


Andrew,

try the header() function:

<?php

if ($_POST['pw'] != $password) {

?>

...show your form...

<?php

} else {

header ("otherpage.php");

}

One problem you might be having is that the < body > tag at the very top might
be sending headers to your browser before your else statement has a chance to
kick in, generating an error which reads something like, "Headers already
sent..." Try moving it to after the conditional, like this:

<?php

if ($_POST['pw'] != $password) {

?>

< BODY onLoad="top.window.focus()" >

...rest of your form...

<?php

} else {

...and so on.


--
Richard S. Crawford
Editor-in-chief, Daikaijuzine (http://www.daikaijuzine.com)
Personal website: http://www.mossroot.com
http://www.myspace.com/underpope / underpope.livejournal.com
"We are here to each other get through this thing, whatever it is."
(Kurt Vonnegut, 1922 - 2007)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQBG8bwj0Q4njIwYM+oRAnx7AJ9Mdo/5qjv+GfAhZQEaQAEmmw46ywCfQ/g+
DIMmu/4IGtcWWZEU97Y7o0E=
=RGOr
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 20/09/2007, 07h52   #4
Andrew Prostko
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [PHP] Open New URL window


Ok, so I started using the header code that was suggested:

And I get this error:

Parse error: parse error, unexpected '{' in
/home/char-lee/public_html/beta/1.php on line 3

This is the code:
-----------
<?php
if ($_POST['pw'] != burgers
{
header("Location: password.php");
}
else
{
header("Location: sept-coupon07.html");
}
?>
-----------
  Réponse avec citation
Vieux 20/09/2007, 08h18   #5
Don Read
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Open New URL window

On Thu, 20 Sep 2007 02:52:19 -0400 Andrew Prostko said:


Ok, so I started using the header code that was suggested:

And I get this error:

Parse error: parse error, unexpected '{' in
/home/char-lee/public_html/beta/1.php on line 3

This is the code:
-----------
<?php
if ($_POST['pw'] != burgers
{
header("Location: password.php");
}
else
{
header("Location: sept-coupon07.html");
}
?>
-----------

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Close your parenthesis, daggummit!

if ($_POST['pw'] != burgers )
^^^

--
Don Read dread@aceweb.com
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.
  Réponse avec citation
Vieux 20/09/2007, 08h19   #6
Stut
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Open New URL window

Andrew Prostko wrote:
> Ok, so I started using the header code that was suggested:
>
> And I get this error:
>
> Parse error: parse error, unexpected '{' in
> /home/char-lee/public_html/beta/1.php on line 3
>
> This is the code:
> -----------
> <?php
> if ($_POST['pw'] != burgers


You'll be wanting to put burgers in quotes and close the bracket on the
line above.

if ($_POST['pw'] != 'burgers')

> {
> header("Location: password.php");
> }
> else
> {
> header("Location: sept-coupon07.html");
> }
> ?>
> -----------


I suggest you find a beginners book or Google for a beginners tutorial
on PHP because it would appear you need to learn some fundamentals of
the language before continuing.

-Stut

--
http://stut.net/
  Réponse avec citation
Vieux 20/09/2007, 08h33   #7
Andrew Prostko
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [PHP] Open New URL window FINAL ANSWER


Wow, it really must be late, Thank you for pointing out that missing
parenthesis
.... 330am and now I can go to bed happy... TY VM

Ending Code for anyone listening:

Get PW from another .php page using:

<form action="passwordcheck.php" method="post">
<br />
What is the Password?: <input type="text" name="pw" />
<input type="submit" value="Submit!"/>
</form>

This is the passwordcheck.php code:
<?php
if ($_POST['pw'] != burgers)
{
header("Location: password.php");
}
else
{
header("Location: sept-coupon07.html");
}
?>
  Réponse avec citation
Vieux 20/09/2007, 08h46   #8
Chris
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Open New URL window FINAL ANSWER

Andrew Prostko wrote:
> Wow, it really must be late, Thank you for pointing out that missing
> parenthesis
> ... 330am and now I can go to bed happy... TY VM
>
> Ending Code for anyone listening:
>
> Get PW from another .php page using:
>
> <form action="passwordcheck.php" method="post">
> <br />
> What is the Password?: <input type="text" name="pw" />
> <input type="submit" value="Submit!"/>
> </form>
>
> This is the passwordcheck.php code:
> <?php
> if ($_POST['pw'] != burgers)


You might want to quote that as well:

'burgers'

otherwise php will look for a defined value called 'burgers', ie:

php will look for this:

define('burgers', 'xyz');

and try to compare against that (in this case the real password is 'xyz').

If you turn up error reporting:

error_reporting(E_ALL);

and display errors:

ini_set('display_errors', true);

you would see a message about this.

--
Postgresql & php tutorials
http://www.designmagick.com/
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h00.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14822 seconds with 16 queries