Page 1 of 1
Simple Question
Posted: Sat Feb 07, 2004 7:25 pm
by ut1205
I'm good at HTML but I'm having a problem with it when it is within PHP tags. In the statement below I want to insert "Align=Center". What't the right format?
Code: Select all
<?php
print_error("<b>Your E-Mail Address is Invalid</b>");
?>
Posted: Sat Feb 07, 2004 7:33 pm
by DuFF
We'd have to see the print_error function. It should be at the top of the file or in an included file starting with the code:
Code: Select all
function print_error($something) {
If you post that, we'll be able to help you.
See if this is what you need!
Posted: Sat Feb 07, 2004 7:39 pm
by ut1205
Code: Select all
<?php
function print_error($reason,$type = 0) {
build_body($title, $bgcolor, $text_color, $link_color, $vlink_color, $alink_color, $style_sheet);
// for missing required data
if ($type == "missing") {
if ($missing_field_redirect) {
header("Location: $missing_field_redirect?error=$reason");
exit;
} else {
?>
<p align="center"><b>The Form Was Not Submitted For the Following Reasons:</b></p>
<ul><?
echo $reason."\n";
?></ul>
<p align="center"><b>Please use your browser's back button to return to the form and try again.</b><?
}
} else { // every other error
?>
The form was not submitted because of the following reasons:<p>
<?
}
?>
Posted: Sat Feb 07, 2004 7:41 pm
by DuFF
OK, now you just have to change the function's HTML output. Maybe something like this?
Code: Select all
<?php
function print_error($reason,$type = 0) {
build_body($title, $bgcolor, $text_color, $link_color, $vlink_color, $alink_color, $style_sheet);
// for missing required data
if ($type == "missing") {
if ($missing_field_redirect) {
header("Location: $missing_field_redirect?error=$reason");
exit;
} else {
?>
<p align="center"><b>The Form Was Not Submitted For the Following Reasons:</b></p>
<div align="center"><?
echo $reason."\n";
?></div>
<p align="center"><b>Please use your browser's back button to return to the form and try again.</b><?
}
} else { // every other error
?>
The form was not submitted because of the following reasons:<p>
<?
}
?>
Thanks
Posted: Sat Feb 07, 2004 8:59 pm
by ut1205

Thanks!!! Worked great. I'm sure there will be more questions to come.
Jim
Still Confused
Posted: Sun Feb 08, 2004 7:14 pm
by ut1205

Within the PHP open and close tags I've figured out the "Bold", "Underline", "Links",ect but I still can't figure out how to code "align=center". Shown below are plain "echo" statements that are aligned to the "left". Is there any code I can put in the statements themself to get them to align in the center of the page?
Code: Select all
<?php
echo "<b><h3>Thank you for your message.</h3></b>\n";
echo "<b><h3>If requested a reply will be sent within 24 hours.</h3></b>\n";
echo "<b><h3>Click <a href="../index.php">Here</a> To Return.</h3></b>\n";
echo "<br><br>\n";
?>
Posted: Sun Feb 08, 2004 8:44 pm
by DuFF
Simplified it a little:
Code: Select all
<?php
echo "<div align="center"><b><h3>Thank you for your message.\n";
echo "If requested a reply will be sent within 24 hours.\n";
echo "Click <a href="../index.php">Here</a> To Return.</h3></b></div>\n";
echo "<br><br>\n";
?>
To center something, just use <div align="center"> or use CSS to position it.
Posted: Sun Feb 08, 2004 8:47 pm
by Illusionist
or, even easier, use <center> and </center>
Posted: Sun Feb 08, 2004 8:49 pm
by DuFF
True, but <center> is deprecated. It still works on all main browsers right now though.
Edit:
Hmm, seems that div align is also deprecated. You should be using CSS instead by now.
Posted: Mon Feb 09, 2004 3:15 am
by malcolmboston
i know its not the "correct" way of doing it but i usually just do things like:
if i need to align something inside PHP use:
<align=center>
it works exactly the same without the quotations, and works properly on the browsers ive tested such as:
Internet Explorer 6
Mozilla (latest version)
Mozilla Firebird (latest linux version)
Opera 7.0
dunno about netscape coz its a horrible browser so i wont use it, however you should use the escaped character method or heredoc
my $0.02
Posted: Mon Feb 09, 2004 5:58 am
by Straterra
Doesn't Mozilla and Netscape both use the Gecko engine?
Posted: Mon Feb 09, 2004 6:07 am
by malcolmboston
yep, but then again i dont like mozilla either and opera behavaes differently to every other browser
inactuality the only browsers i like are IE6 and Firebird