Click to See Complete Forum and Search --> : question on php & css & links


jogol
06-30-2005, 03:32 AM
hi experts, i need some help with a line of php:

if(empty($name) || empty($email) || empty($msg)) {
echo "All fields are required. Go back.";
}
i have a style sheet attached and want to apply the class "txt" to 'All fields are required. Go back.' further i want to add a link to "Go back"

the following doesnt work:

if(empty($name) || empty($email) || empty($msg)) {
echo "<span class="txt">All fields are required. <a href="kontakt.html">Go back</a>.</span>";
}

i also tried:

if(empty($name) || empty($email) || empty($msg)) {
echo <span class="txt">"All fields are required. <a href="kontakt.html">Go back</a>."</span>;
}

as you can see iīm a total noob and canīt figure out the right syntax.
please help.

regards,
jogol

NogDog
06-30-2005, 04:59 AM
echo "<span class=\"txt\">All fields are required. <a href=\"kontakt.html\">Go back</a>.</span>";
# ... or ...
echo "<span class='txt'>All fields are required. <a href='kontakt.html'>Go back</a>.</span>';


Note, if this text is not already being placed inside a paragraph (or other block element), you could just make it a paragraph:

echo "<p class='txt'>All fields are required. <a href='kontakt.html'>Go back</a>.</p>';

jogol
06-30-2005, 06:21 AM
thx for the quick help Nog Dog. it is much appreciated.

regards,
jogol

the tree
06-30-2005, 06:37 AM
Also, if you like, you don't need any quotes around your echoed text at allecho <<< ERROR
<p class="txt">All fields are required. <a href="kontakt.html">Go back</a>.</p>
ERROR;Just make sure that ERROR or whatever word you use is on a line of it's own.