LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-14-2010, 09:49 AM   #1
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Rep: Reputation: 62
How to intersperse PHP with HTML


Hi,
I have a site which will have, for example, a login system where people have to enter their usernames and passwords, depending on which they'll be let in to the site. So, in code, I've got a line like:

if ($_POST['password'] == $password) {
then do whatever
}
else { print "Wrong password" ; )

My problem is, this "Wrong password" printing is just a solitary line, not keeping with the colours and style of the site, and it looks very bad. I want to ideally, output some HTML, which will have a picture, and print the "Wrong password" in the font and colours I desire. How do I do this? Do I have to put all the HTML in a print statement, and then deal with the nightmare of escaping all the quote marks in it with a "\"? Or is there a cleaner method to the whole thing? Maybe something like this -

if ($_POST['password'] == $password) {
then do whatever
}
else
?>

<FONT SIZE=2> Wrong password </FONT>


Thanks for your help.
 
Old 09-14-2010, 09:54 AM   #2
14moose
Member
 
Registered: May 2010
Posts: 83

Rep: Reputation: Disabled
Hi -

One possibility:
Code:
<?php
if ($_POST['password'] == $password) {
  ... then do whatever ...
}
else {
  echo "Wrong password"; 
}
 ?>
Another possibility:
Code:
<?php
if ($_POST['password'] == $password) {
  ... then do whatever ...
}
else ?>
<em>Wrong password</em>
<?php
  ... more PHP ...
PS:
Don't use "<FONT>" tags, if you can avoid it. IMHO, CSS is much better...

Last edited by 14moose; 09-14-2010 at 09:58 AM.
 
Old 09-14-2010, 10:03 AM   #3
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Original Poster
Rep: Reputation: 62
Aah so I was right then, in my 2nd snip of code....? Thanks a lot, 14moose. Anybody else got any comments?
 
Old 09-14-2010, 06:51 PM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
You can include (or require) a file which holds the html formatting that you desire.
 
Old 09-15-2010, 10:29 AM   #5
rsciw
Member
 
Registered: Jan 2009
Location: Essex (UK)
Distribution: Home: Debian/Ubuntu, Work: Ubuntu
Posts: 206

Rep: Reputation: 44
Quote:
Originally Posted by 14moose View Post
Hi -

One possibility:
Code:
<?php
if ($_POST['password'] == $password) {
  ... then do whatever ...
}
else {
  echo "Wrong password"; 
}
 ?>
Another possibility:
Code:
<?php
if ($_POST['password'] == $password) {
  ... then do whatever ...
}
else ?>
<em>Wrong password</em>
<?php
  ... more PHP ...
PS:
Don't use "<FONT>" tags, if you can avoid it. IMHO, CSS is much better...
Personally I never liked interrupting the
<?php ?> code for HTML code, hence I usually write this way, which is a 3rd option to do

Code:
<?php
if ($_POST['password'] == $password) {
  ... then do whatever ...
}
else
print "<em>Wrong password</em>";
//  ... more PHP ...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
php in html johnh10000 Programming 2 01-25-2010 05:53 AM
html vs. php kotty Programming 13 11-28-2007 04:20 AM
Apache rending php when filename is x.php.html mastahnke Linux - Server 6 01-22-2007 08:39 AM
Html/php karan101 Programming 10 08-03-2006 02:42 AM
html to php? help me please!!!!! trscookie Programming 4 01-24-2005 06:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration