PDA

View Full Version : Access external CSS file from PHP file?



web88js
08 Dec 2007, 03:28 AM
Hello everyone:

I am working a project that display a form between header and footer section. I want to center the error message just above the form.

I have three files header.php, footer.php and password.php. I use php include to include header and footer section.

Within the header.php file, I accessed an external style sheet - global.css which have all the styles.

I don't know what approach should I use to crate a style in global.css file so I can make the error message display right above the form after user click update password button.
a) Should I add div elements in header.php file ?

Code Segment in password.php file


if($num == 1)
{
$row = mysql_fetch_array($result, MYSQL_NUM);

$query = "update friend set password=SHA('$newpd')
where user_id=$row[0]";

$result = mysql_query($query);

//user password being successfully updated
if(mysql_affected_rows() == 1)
{
echo '<h1 id="mainhead">Thank You!</h1>
<p>Your password has been updated.</p>';

}
else
{
echo '<h1 id="mainhead">System Error!</h1>
<p class="error">Your password could not be changed due to a system error.</p>';
}

}

//display error message if there were no matching records found in db
else
{
echo '<h1 id="mainhead">Error!</h1>
<p class="error">Your email address and password do not match those on file. Please
try again.</p>';
}



Please give me some advises. Thanks!

Link to the php file (http://www.cuj06.com/home_page/password.php)

file structure image (http://www.cuj06.com/home_page/homepage_filestructure.jpg)

Wickham
08 Dec 2007, 08:52 AM
I think it sometimes depends on the order of the php and form in your page code.

Can you set up the page code to show the form code after the php codes with the error and Thank You messages?

In one of my forms the php code is coded first and the last item is "else" followed by the form, so the browser processes all the previous instructions first, which are invalid when the page is first loaded and so the "else" becomes valid and the form shows.

After the form is filled in and the submit button pressed, the page is processed again and one of the previous instructions to post the data and show the error message or Thank You message becomes valid and the message is displayed where the form was and the form is not shown because the last "else" is not reached because a previous instruction was valid. In the case of an error warning the back button must be used to see the form again.

There is a separate board for PHP queries. I'm not an expert in PHP.