penguin0 Posted June 8, 2007 Share Posted June 8, 2007 What I need to do is take "site info" from a form, save it to a database table called siteinfo, and then write style information based on the variables. Site Form: <? include("header2.php"); $result = mysql_query( "SELECT content FROM pages WHERE number = 4" ); $num_rows = mysql_num_rows( $result ); while ( $a_row = mysql_fetch_row( $result ) ) { foreach ( $a_row as $field ) print "$field"; } if ($admin == "1") { $sql = "SELECT name, url, adminname, adminemail, fontcolor, table_bg, menu_text FROM siteinfo WHERE id = $siteid"; $result = mysql_query($sql, $link) or die(mysql_error()); while ( $a_row = mysql_fetch_array( $result ) ) { $name = $row['name']; $url = $row['url']; $adminname = $row['adminname']; $adminemail = $row['adminemail']; $fontcolor = $row['fontcolor']; $table_bg = $row['table_bg']; $menu_text = $row['menu_text']; } echo "<form action=\"do_editsite.php\" method=\"POST\"> <table cellpadding=6 cellspacing=1 class=ptable><tr><th colspan=2>Edit: $name</th></tr> <tr><td>SiteName:</td><td><input type=\"text\" name=\"name\" size=\"25\" maxlength=\"25\" value=\"$name\"></td></tr> <tr><td>Site Url:</td><td><input type=\"text\" name=\"url\" size=\"25\" maxlength=\"35\" value=\"$url\"></td></tr> <tr><td>Admin Name:</td><td><input type=\"text\" name=\"adminname\" size=\"25\" maxlength=\"25\" value=\"$adminname\"></td></tr> <tr><td>Admin Email:</td><td><input type=\"text\" name=\"adminemail\" size=\"35\" maxlength=\"50\" value=\"$adminemail\"></td></tr> <tr><td>Font Color:</td><td><input type=\"text\" name=\"fontcolor\" size=\"7\" maxlength=\"7\" value=\"$fontcolor\"></td></tr> <tr><td>Table Background:</td><td><input type=\"text\" name=\"table_bg\" size=\"7\" maxlength=\"7\" value=\"$table_bg\"></td></tr> <tr><td>Menu Font:</td><td><input type=\"text\" name=\"menu_text\" size=\"7\" maxlength=\"7\" value=\"$menu_text\"></td></tr> <input type=\"hidden\" name=\"id\" value=\"$siteid\">"; } else { echo "<h3>Access Denied</h3> You do not have the necessary permissions to view this page. If you think<br /> this is an error, please contact the site administrator to gain access."; } if ($admin == "1") { echo "<tr><td align=center colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"Update $name\"></td></tr></table> </form>"; } include("footer.php"); ?> Posts to: <? include("header2.php"); $result = mysql_query( "SELECT content FROM pages WHERE number = 4" ); $num_rows = mysql_num_rows( $result ); while ( $a_row = mysql_fetch_row( $result ) ) { foreach ( $a_row as $field ) print "$field"; } if ((!$_POST[name]) || (!$_POST[adminname]) || (!$_POST[adminemail])) { header( "Location: editsite.php"); exit; } if ($admin == "1") { $sql = "UPDATE siteinfo SET name = '$_POST[name]', url = '$_POST[url]', adminname = '$_POST[adminname]', adminemail = '$_POST[adminemail]', fontcolor = '$_POST[fontcolor]', table_bg = '$_POST[table_bg]', menu_text = '$_POST[menu_text]' WHERE id = '$_POST[id]'"; $result = @mysql_query($sql, $link) or die(mysql_error()); echo "$_POST[name] updated!"; } else { echo "<h3>Access Denied</h3> You do not have the necessary permissions to view this page. If you think<br /> this is an error, please contact the site administrator to gain access."; } include("footer.php"); ?> CSS I want it to post to: body { margin:0px auto; padding:0px; background-color:FFFFFF; } .menu_text { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; line-height: 30px; font-weight: normal; font-variant: normal; text-transform: none; text-decoration: none; color: #FEDA25; background-color:inherit; } .menu_text:hover { color: #FFFFFF; text-decoration:none; background-color:inherit; } Quote Link to comment Share on other sites More sharing options...
penguin0 Posted June 8, 2007 Author Share Posted June 8, 2007 Anyone? Quote Link to comment Share on other sites More sharing options...
penguin0 Posted June 9, 2007 Author Share Posted June 9, 2007 ? Quote Link to comment Share on other sites More sharing options...
Accurax Posted June 9, 2007 Share Posted June 9, 2007 i may be wrong.... but i didnt think you could insert php into a css file ....... if there is a way, i definatly want to know about it though. Quote Link to comment Share on other sites More sharing options...
soycharliente Posted June 9, 2007 Share Posted June 9, 2007 You are correct. Quote Link to comment Share on other sites More sharing options...
penguin0 Posted June 9, 2007 Author Share Posted June 9, 2007 I didn't mean put php in a css form, but can't you use fopen to change a .css around? Quote Link to comment Share on other sites More sharing options...
penguin0 Posted August 27, 2007 Author Share Posted August 27, 2007 Is there a way to do what I said last? Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 27, 2007 Share Posted August 27, 2007 Yes, PHP can generate a CSS file using header(), or can just write to the file. Quote Link to comment Share on other sites More sharing options...
tibberous Posted August 27, 2007 Share Posted August 27, 2007 Not sure, but I think browsers like to cache css files -- if your trying to make it super-dynamic you *might* have trouble. Quote Link to comment Share on other sites More sharing options...
keeB Posted August 27, 2007 Share Posted August 27, 2007 Unless you send a Content-Refresh header. Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 27, 2007 Share Posted August 27, 2007 I've only really had trouble with browsers caching image files which are dynamically created, especially Firefox. I have my css generated using a .php file and I never see it cache. Could be just me. Quote Link to comment Share on other sites More sharing options...
soycharliente Posted August 27, 2007 Share Posted August 27, 2007 If I'm not mistaken, isn't the entire point of a CSS file so that your browser CAN cache it? Why would you write a separate file just for it to be sent every time? I'd would just leave it in the style section if that were the case so I didn't have to keep switching back and forth between files. It's to eliminate all of the, outdated now, < font > tags and reduce the amount of data being sent so that the server has less stress and the page can load faster. I read that ESPN went to a completely CSS driven site and saved $1 million a month on bandwidth costs. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.