holy85 Posted January 9, 2011 Share Posted January 9, 2011 Hi all, In my HTML webpage the CSS backgound works perfectly. CSS body{ background-image:url(../images/bg.png); background-repeat:repeat-x; } As I'm adding a contact form, I've changed my webpage to .PHP . I've tested it and all the other css coding works perfect in the php file. Except for the main page background. Nothing comes up Confused . I've got a feeling something from my php coding is overriding my css background. But I can't seem to find it. Sad . Can anyone help? PHP <?php session_start(); $to = 'email@hotmail.com'; $from = 'email@hotmail.com'; $subject_prefix = 'My Website Contact'; $header_file = 'form-header.php'; $footer_file = 'form-footer.php'; $form_width = '70%'; $form_background = '#ffffff'; $form_border_color = '#ffffff' $form_border_width = '1px'; $form_border_style = 'solid'; $cell_padding = '5px'; $left_col_width = '25%'; $font_size = '12px'; $field_error_color = '#FF0000'; $thank_you_message = <<<EOD <!-- Start message --> <p>Thank you for the email, we will be intouch shortly.</p><br /><br /><br /><br /><br /><br /><br /><br /> <!-- End message --> EOD; $thank_you_url = 'mwww.mywebsite.com'; $name = array('Name','name',NULL,NULL); $email = array('Email','email',NULL,NULL,NULL); $subject = array('Subject','subject',NULL,NULL); $message = array('Message','message',NULL,NULL); $code = array('Code','captcha_code',NULL,NULL,NULL); $error_message = ''; if (!isset($_POST['submit'])) { showForm(); } else { //form submitted $error = 0; if(!empty($_POST['name'])) { $name[2] = clean_var($_POST['name']); if (function_exists('htmlspecialchars')) $name[2] = htmlspecialchars($name[2], ENT_QUOTES); } else { $error = 1; $name[3] = 'color:#FF0000;'; } if(!empty($_POST['email'])) { $email[2] = clean_var($_POST['email']); if (!validEmail($email[2])) { $error = 1; $email[3] = 'color:#FF0000;'; $email[4] = '<strong><span style="color:#FF0000;">Invalid email</span></strong>'; } } else { $error = 1; $email[3] = 'color:#FF0000;'; } if(!empty($_POST['subject'])) { $subject[2] = clean_var($_POST['subject']); if (function_exists('htmlspecialchars')) $subject[2] = htmlspecialchars($subject[2], ENT_QUOTES); } else { $error = 1; $subject[3] = 'color:#FF0000;'; } if(!empty($_POST['message'])) { $message[2] = clean_var($_POST['message']); if (function_exists('htmlspecialchars')) $message[2] = htmlspecialchars($message[2], ENT_QUOTES); } else { $error = 1; $message[3] = 'color:#FF0000;'; } if(empty($_POST['captcha_code'])) { $error = 1; $code[3] = 'color:#FF0000;'; } else { include_once "securimage.php"; $securimage = new Securimage(); $valid = $securimage->check($_POST['captcha_code']); if(!$valid) { $error = 1; $code[3] = 'color:#FF0000;'; $code[4] = '<strong><span style="color:#FF0000;">Incorrect code</span></strong>'; } } if ($error == 1) { $error_message = '<span style="font-weight:bold;font-size:90%;">Please correct/enter field(s) in red.</span>'; showForm(); } else { if (function_exists('htmlspecialchars_decode')) $name[2] = htmlspecialchars_decode($name[2], ENT_QUOTES); if (function_exists('htmlspecialchars_decode')) $subject[2] = htmlspecialchars_decode($subject[2], ENT_QUOTES); if (function_exists('htmlspecialchars_decode')) $message[2] = htmlspecialchars_decode($message[2], ENT_QUOTES); $message = "$name[0]: $name[2]\r\n$email[0]: $email[2]\r\n\r\n$message[0]:\r\n$message[2]\r\n"; if (!$from) $from_value = $email[2]; else $from_value = $from; $headers = "From: $from_value" . "\r\n"; $headers .= "Reply-To: $email[2]" . "\r\n"; mail($to,"$subject_prefix - $subject[2]", $message, $headers); if (!$thank_you_url) { include $header_file; echo $GLOBALS['thank_you_message']; echo "\n"; include $footer_file; } else { header("Location: $thank_you_url"); } } } //else submitted function showForm() { global $name, $email, $subject, $message, $code, $header_file, $footer_file, $form_width, $form_background, $form_border_color, $form_border_width, $form_border_style, $cell_padding, $left_col_width, $font_size; include $header_file; echo $GLOBALS['error_message']; echo <<<EOD <form method="post" class="cForm"> <table style="width:{$form_width}; background-color:{$form_background}; border:{$form_border_width} {$form_border_style} {$form_border_color}; padding:10px; font-size:{$font_size};" class="contactForm"> <tr> <td style="width:{$left_col_width}; text-align:left; vertical-align:top; padding:{$cell_padding}; font-weight:bold; {$name[3]}">{$name[0]}</td> <td style="text-align:left; vertical-align:top; padding:{$cell_padding};"><input type="text" name="{$name[1]}" value="{$name[2]}" /></td> </tr> <tr> <td style="width:{$left_col_width}; text-align:left; vertical-align:top; padding:{$cell_padding}; font-weight:bold; {$email[3]}">{$email[0]}</td> <td style="text-align:left; vertical-align:top; padding:{$cell_padding};"><input type="text" name="{$email[1]}" value="{$email[2]}" /> {$email[4]}</td> </tr> <tr> <td style="width:{$left_col_width}; text-align:left; vertical-align:top; padding:{$cell_padding}; font-weight:bold; {$subject[3]}">{$subject[0]}</td> <td style="text-align:left; vertical-align:top; padding:{$cell_padding};"><input type="text" name="{$subject[1]}" value="{$subject[2]}" size="40" /></td> </tr> <tr> <td style="width:{$left_col_width}; text-align:left; vertical-align:top; padding:{$cell_padding}; font-weight:bold; {$message[3]}">{$message[0]}</td> <td style="text-align:left; vertical-align:top; padding:{$cell_padding};"><textarea name="{$message[1]}" cols="40" rows="6">{$message[2]}</textarea></td> </tr> <tr> <td style="width:{$left_col_width}; text-align:left; vertical-align:top; padding:{$cell_padding};"> </td> <td style="text-align:left; vertical-align:top; padding:{$cell_padding};"><img id="captcha" src="securimage_show.php" alt="CAPTCHA Image" /></td> </tr> <tr> <td style="width:{$left_col_width}; text-align:left; vertical-align:top; padding:{$cell_padding}; font-weight:bold; {$code[3]}">{$code[0]}</td> <td style="text-align:left; vertical-align:top; padding:{$cell_padding};"><input type="text" name="{$code[1]}" size="10" maxlength="5" /> {$code[4]} <br /><br />(Please enter the text in the image above. Text is not case sensitive.)<br /> <a href="#" onclick="document.getElementById('captcha').src = 'securimage_show.php?' + Math.random(); return false">Click here if you cannot recognize the code.</a> </td> </tr> <tr> <td colspan="2" style="text-align:left; vertical-align:middle; padding:{$cell_padding}; font-size:90%; font-weight:bold;">All fields are required.</td> </tr> <tr> <td colspan="2" style="text-align:left; vertical-align:middle; padding:{$cell_padding};"><input type="submit" name="submit" value="Submit" style="border:1px solid #999;background:#E4E4E4;margin-top:5px;" /></td> </tr> </table> </form> <div style="width:{$form_width};text-align:right;font-size:80%;"> </div> EOD; include $footer_file; } function clean_var($variable) { $variable = strip_tags(stripslashes(trim(rtrim($variable)))); return $variable; } /** Email validation function. Thanks to http://www.linuxjournal.com/article/9585 */ function validEmail($email) { $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = substr($email, $atIndex+1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { // local part length exceeded $isValid = false; } else if ($domainLen < 1 || $domainLen > 255) { // domain part length exceeded $isValid = false; } else if ($local[0] == '.' || $local[$localLen-1] == '.') { // local part starts or ends with '.' $isValid = false; } else if (preg_match('/\\.\\./', $local)) { // local part has two consecutive dots $isValid = false; } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { // character not valid in domain part $isValid = false; } else if (preg_match('/\\.\\./', $domain)) { // domain part has two consecutive dots $isValid = false; } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { // character not valid in local part unless // local part is quoted if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) { $isValid = false; } } if ($isValid && function_exists('checkdnsrr')) { if (!(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A"))) { // domain not found in DNS $isValid = false; } } } return $isValid; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/223825-background-disappears/ Share on other sites More sharing options...
haku Posted January 9, 2011 Share Posted January 9, 2011 Please don't post PHP in the CSS section. Post the HTML output of your script. PHP is irrelevant to CSS. Quote Link to comment https://forums.phpfreaks.com/topic/223825-background-disappears/#findComment-1156925 Share on other sites More sharing options...
holy85 Posted January 10, 2011 Author Share Posted January 10, 2011 Hi, Sorry Haku, I've posted it the proper way now with the tags and put it into the php section. I hope thats ok? Quote Link to comment https://forums.phpfreaks.com/topic/223825-background-disappears/#findComment-1157231 Share on other sites More sharing options...
Pikachu2000 Posted January 10, 2011 Share Posted January 10, 2011 No, it isn't. I've deleted the other post from the wrong category, and you can continue in this thread. Please don't post PHP in the CSS section. Post the HTML output of your script. PHP is irrelevant to CSS. If you have external stylesheets, you'll also want to post those. Please post each part within its own set of . . . tags. Quote Link to comment https://forums.phpfreaks.com/topic/223825-background-disappears/#findComment-1157242 Share on other sites More sharing options...
holy85 Posted January 10, 2011 Author Share Posted January 10, 2011 Hopefully I get it right this time. css1.css background code. body{ background-image:url(../images/bg.png); background-repeat:repeat-x; } My file contains html and php coding. The file is called index.php index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>mywebsite</title> <link href="scripts/css1.css" rel="stylesheet" type="text/css" /> <script src="../../Scripts/AC_RunActiveContent.js" type="text/javascript"></script> </head> <body> <div id="wrapper"> <div id="headcontent"> <div class="logo"> </div> <div class="quote"></div> <div class="menu"> <ul id="menulist"> <li><div class="current">Home</div></li> <li><a href="">Contact Us</a></li> <li><a href="">Services</a></li> <li><a href="">Prices</a></li> <li><a href="">other</a></li> <li><a href="">other</a></li> </ul> <p class="clear"/> </div> </div> <p></p> <div align="center"> <p class="heading">About Us</p> <p class="heading_nr">00000000</p> <p class="heading_r">Tel: </p> </div> <div id="main_heading"> </div> <div class="Main_text"> <p></p> <p>text</p> <h4>We Provide..</h4> <p>text</p> <div class="services_web"> </div> <p>more text</p> <div class="services_graphic"> <img src="images/graphic_services.gif" /> </div> <div id="footer"> <div class="footer_rt">Terms & Conditions | Sitemap</div> <div class="footer_lt">text <span class="style3">text</span> text <span class="style3">0000000</span></div> </div> </div> </div> <a class="floating_link" href="contact_us.htm">Go Somewhere</a> <?php session_start(); $to = 'email@hotmail.com'; $from = 'email@hotmail.com'; $subject_prefix = 'My Website Contact'; $header_file = 'form-header.php'; $footer_file = 'form-footer.php'; $form_width = '70%'; $form_background = '#ffffff'; $form_border_color = '#ffffff' $form_border_width = '1px'; $form_border_style = 'solid'; $cell_padding = '5px'; $left_col_width = '25%'; $font_size = '12px'; $field_error_color = '#FF0000'; $thank_you_message = <<<EOD <!-- Start message --> <p>Thank you for the email, we will be intouch shortly.</p><br /><br /><br /><br /><br /><br /><br /><br /> <!-- End message --> EOD; $thank_you_url = 'mwww.mywebsite.com'; $name = array('Name','name',NULL,NULL); $email = array('Email','email',NULL,NULL,NULL); $subject = array('Subject','subject',NULL,NULL); $message = array('Message','message',NULL,NULL); $code = array('Code','captcha_code',NULL,NULL,NULL); $error_message = ''; if (!isset($_POST['submit'])) { showForm(); } else { //form submitted $error = 0; if(!empty($_POST['name'])) { $name[2] = clean_var($_POST['name']); if (function_exists('htmlspecialchars')) $name[2] = htmlspecialchars($name[2], ENT_QUOTES); } else { $error = 1; $name[3] = 'color:#FF0000;'; } if(!empty($_POST['email'])) { $email[2] = clean_var($_POST['email']); if (!validEmail($email[2])) { $error = 1; $email[3] = 'color:#FF0000;'; $email[4] = '<strong><span style="color:#FF0000;">Invalid email</span></strong>'; } } else { $error = 1; $email[3] = 'color:#FF0000;'; } if(!empty($_POST['subject'])) { $subject[2] = clean_var($_POST['subject']); if (function_exists('htmlspecialchars')) $subject[2] = htmlspecialchars($subject[2], ENT_QUOTES); } else { $error = 1; $subject[3] = 'color:#FF0000;'; } if(!empty($_POST['message'])) { $message[2] = clean_var($_POST['message']); if (function_exists('htmlspecialchars')) $message[2] = htmlspecialchars($message[2], ENT_QUOTES); } else { $error = 1; $message[3] = 'color:#FF0000;'; } if(empty($_POST['captcha_code'])) { $error = 1; $code[3] = 'color:#FF0000;'; } else { include_once "securimage.php"; $securimage = new Securimage(); $valid = $securimage->check($_POST['captcha_code']); if(!$valid) { $error = 1; $code[3] = 'color:#FF0000;'; $code[4] = '<strong><span style="color:#FF0000;">Incorrect code</span></strong>'; } } if ($error == 1) { $error_message = '<span style="font-weight:bold;font-size:90%;">Please correct/enter field(s) in red.</span>'; showForm(); } else { if (function_exists('htmlspecialchars_decode')) $name[2] = htmlspecialchars_decode($name[2], ENT_QUOTES); if (function_exists('htmlspecialchars_decode')) $subject[2] = htmlspecialchars_decode($subject[2], ENT_QUOTES); if (function_exists('htmlspecialchars_decode')) $message[2] = htmlspecialchars_decode($message[2], ENT_QUOTES); $message = "$name[0]: $name[2]\r\n$email[0]: $email[2]\r\n\r\n$message[0]:\r\n$message[2]\r\n"; if (!$from) $from_value = $email[2]; else $from_value = $from; $headers = "From: $from_value" . "\r\n"; $headers .= "Reply-To: $email[2]" . "\r\n"; mail($to,"$subject_prefix - $subject[2]", $message, $headers); if (!$thank_you_url) { include $header_file; echo $GLOBALS['thank_you_message']; echo "\n"; include $footer_file; } else { header("Location: $thank_you_url"); } } } //else submitted function showForm() { global $name, $email, $subject, $message, $code, $header_file, $footer_file, $form_width, $form_background, $form_border_color, $form_border_width, $form_border_style, $cell_padding, $left_col_width, $font_size; include $header_file; echo $GLOBALS['error_message']; echo <<<EOD <form method="post" class="cForm"> <table style="width:{$form_width}; background-color:{$form_background}; border:{$form_border_width} {$form_border_style} {$form_border_color}; padding:10px; font-size:{$font_size};" class="contactForm"> <tr> <td style="width:{$left_col_width}; text-align:left; vertical-align:top; padding:{$cell_padding}; font-weight:bold; {$name[3]}">{$name[0]}</td> <td style="text-align:left; vertical-align:top; padding:{$cell_padding};"><input type="text" name="{$name[1]}" value="{$name[2]}" /></td> </tr> <tr> <td style="width:{$left_col_width}; text-align:left; vertical-align:top; padding:{$cell_padding}; font-weight:bold; {$email[3]}">{$email[0]}</td> <td style="text-align:left; vertical-align:top; padding:{$cell_padding};"><input type="text" name="{$email[1]}" value="{$email[2]}" /> {$email[4]}</td> </tr> <tr> <td style="width:{$left_col_width}; text-align:left; vertical-align:top; padding:{$cell_padding}; font-weight:bold; {$subject[3]}">{$subject[0]}</td> <td style="text-align:left; vertical-align:top; padding:{$cell_padding};"><input type="text" name="{$subject[1]}" value="{$subject[2]}" size="40" /></td> </tr> <tr> <td style="width:{$left_col_width}; text-align:left; vertical-align:top; padding:{$cell_padding}; font-weight:bold; {$message[3]}">{$message[0]}</td> <td style="text-align:left; vertical-align:top; padding:{$cell_padding};"><textarea name="{$message[1]}" cols="40" rows="6">{$message[2]}</textarea></td> </tr> <tr> <td style="width:{$left_col_width}; text-align:left; vertical-align:top; padding:{$cell_padding};"> </td> <td style="text-align:left; vertical-align:top; padding:{$cell_padding};"><img id="captcha" src="securimage_show.php" alt="CAPTCHA Image" /></td> </tr> <tr> <td style="width:{$left_col_width}; text-align:left; vertical-align:top; padding:{$cell_padding}; font-weight:bold; {$code[3]}">{$code[0]}</td> <td style="text-align:left; vertical-align:top; padding:{$cell_padding};"><input type="text" name="{$code[1]}" size="10" maxlength="5" /> {$code[4]} <br /><br />(Please enter the text in the image above. Text is not case sensitive.)<br /> <a href="#" onclick="document.getElementById('captcha').src = 'securimage_show.php?' + Math.random(); return false">Click here if you cannot recognize the code.</a> </td> </tr> <tr> <td colspan="2" style="text-align:left; vertical-align:middle; padding:{$cell_padding}; font-size:90%; font-weight:bold;">All fields are required.</td> </tr> <tr> <td colspan="2" style="text-align:left; vertical-align:middle; padding:{$cell_padding};"><input type="submit" name="submit" value="Submit" style="border:1px solid #999;background:#E4E4E4;margin-top:5px;" /></td> </tr> </table> </form> <div style="width:{$form_width};text-align:right;font-size:80%;"> </div> EOD; include $footer_file; } function clean_var($variable) { $variable = strip_tags(stripslashes(trim(rtrim($variable)))); return $variable; } /** Email validation function. Thanks to http://www.linuxjournal.com/article/9585 */ function validEmail($email) { $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = substr($email, $atIndex+1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { // local part length exceeded $isValid = false; } else if ($domainLen < 1 || $domainLen > 255) { // domain part length exceeded $isValid = false; } else if ($local[0] == '.' || $local[$localLen-1] == '.') { // local part starts or ends with '.' $isValid = false; } else if (preg_match('/\\.\\./', $local)) { // local part has two consecutive dots $isValid = false; } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { // character not valid in domain part $isValid = false; } else if (preg_match('/\\.\\./', $domain)) { // domain part has two consecutive dots $isValid = false; } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { // character not valid in local part unless // local part is quoted if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) { $isValid = false; } } if ($isValid && function_exists('checkdnsrr')) { if (!(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A"))) { // domain not found in DNS $isValid = false; } } } return $isValid; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/223825-background-disappears/#findComment-1157262 Share on other sites More sharing options...
Pikachu2000 Posted January 10, 2011 Share Posted January 10, 2011 That isn't the HTML output from the script. What you need to paste in here is the result of [View] --> [source] of the problem page from your web browser. Quote Link to comment https://forums.phpfreaks.com/topic/223825-background-disappears/#findComment-1157364 Share on other sites More sharing options...
holy85 Posted January 10, 2011 Author Share Posted January 10, 2011 "Pikachu" All fixed now. The error was in another .php file which my form was calling. Thank you for your help anyway. I'll try and post more simple stuff next time, and I look forward to helping others as well. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/223825-background-disappears/#findComment-1157408 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.