Page 1 of 1
PHP Newbie Question
Posted: Mon Mar 21, 2005 8:19 pm
by ryan1111
I'm creating my first PHP webpage. It's a login page. If the user enters the wrong information, of course, I want to let them know. All of the examples I see use echo(). However, I don't want the error message to appear in the upper left corner of the window. I want it to appear at a specific place on the page. How on earth do I do this?
Thanks!
Posted: Mon Mar 21, 2005 8:28 pm
by feyd
echo out the html up to that specific point, or use a template-esque system of content display.
Code: Select all
<?php
$template =<<<STOP
<html>
<head>
<title>{TITLE}</title>
</head>
<body>
<div style="e;text-align:right; border: 2px red solid; background-color: yellow; color: blue; padding: 10px 10px 10px 10px; font-weight: bold;"e;>{ERROR_DATA}</div>
</body>
</html>
STOP;
$error = 'Hi. I\'m an error.';
$title = 'I\'m a title';
$find = array('{TITLE}', '{ERROR_DATA}');
$rep = array($title, $error);
$output = str_replace($find, $rep, $template);
echo $output;
?>
Code: Select all
<html>
<head>
<title>I'm a title</title>
</head>
<body>
<div style="e;text-align:right; border: 2px red solid; background-color: yellow; color: blue; padding: 10px 10px 10px 10px; font-weight: bold;"e;>Hi. I'm an error.</div>
</body>
</html>
Posted: Tue Mar 22, 2005 10:00 am
by ryan1111
Thanks! You pointed me in the right direction.
