Jump to content

[SOLVED] Unstable includes menu ONLY on a php form page -- not the rest of the site


pjkinann

Recommended Posts

Hello,

My php form works great,  but I noticed that somehow it causes my top navigation (horizontal) menu to reposition itself continually on mouseover. It is an includes menu.  However, as a test, I replaced the includes menu with a standard UL menu, but it still changes positions.  It moves back and forth horizontally.

 

This only happens on my form pages, so I'm assuming it has something to do with the php form code rather than the includes menu.

 

I can't see anything obvious but a PHP guru probably could find this.

 

Hope someone can help.

 

Pages are:

http://www.pjkinann.com/AdvancedBusinessSales/pages/buyers_contact.php

 

http://www.pjkinann.com/AdvancedBusinessSales/pages/sellers_contact.php

 

http://www.pjkinann.com/AdvancedBusinessSales/pages/contact_general.php

 

Menu on all other pages of the site is stable:

http://www.pjkinann.com/AdvancedBusinessSales/index.php

 

This is the code above the doctype:

<?php
include('../captcha/captchac_lib.php');  
$admin_email = 'pjkinann@mac.com'; 
$contact_subject = 'Advanced Business Sales: Message'; 
$contact_sentpage = 'sent.php'; 
$contact_notification_subject = 'Thank you for contacting Advanced Business Sales.'; 
$contact_notification_message = 'This is an automated response to let you know that your message was received. We will contact you within 24 hours.'; 

if(isset($_POST['form_contact_submit']) && $_POST['form_contact_submit'] == 'Send Message') {
$error=array();
$contact_name = '';
$contact_email = '';
$contact_message = '';

// Grab name
if(isset($_POST['form_contact_name']) && !empty($_POST['form_contact_name'])) {
$contact_name = stripslashes($_POST['form_contact_name']);
} else {
$error['contact_name'] = 'You have not provided your name.';
}

// Grab Email
if(isset($_POST['form_contact_email']) && !empty($_POST['form_contact_email'])) {
$contact_email = trim($_POST['form_contact_email']);
} else {
$error['contact_email'] = 'You have not provided your email address.';
}
// Test validity
if($contact_email) {
$email_pattern = "/^[\.\-\w]+@[\.\-\w]+\.[^\.\W\d]{2,4}$/i";
if(!preg_match($email_pattern,$contact_email)) {
	$error['contact_email_invalid'] = 'Your email address appears to be invalid.';
}
}

// Grab the message
if(isset($_POST['form_contact_message']) && !empty($_POST['form_contact_message'])) {
$contact_message = stripslashes($_POST['form_contact_message']);
} else {
$error['contact_message'] = 'You have not added your message.';
}

$Turing_code = $_REQUEST["Turing"]; 
if ( CheckCaptcha($Turing_code) !=1 )
$error['contact_message'] = 'The captcha code is incorrect. Please try again!';

// Email variables
$compile_message = "Name: $contact_name\r\n";
$compile_message .= "Email: $contact_email\r\n";
$compile_message .= $contact_message;
$headers_contact = "From: $contact_name <$contact_email>\r \n";
$headers_notification = "From: $admin_email <$admin_email>\r \n";
if(!$error) {
mail($admin_email, $contact_subject, $compile_message, $headers_contact);
mail($contact_email, $contact_notification_subject, $contact_notification_message, 
$headers_notification);
header("location: $contact_sentpage");
}
}
?>

 

 

This is the html and php form within the document:

<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Advanced Business Sales</title>
<link href="../css/AdvBus.css" rel="stylesheet" type="text/css" />
<!--[if LTE IE 6]>
<link href="../css/ie.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<!--[if IE 7]>
<link href="../css/ie7.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<link href="../css/form.css" rel="stylesheet" type="text/css" />
</head>
<body id="buyerscontactpage" class="twocol">
<div id="wrapper">
  <div id="header"> <img src="../images/title1.gif" alt="Welcome to Stirling" name="title" width="255" height="29" id="title" />
    <?php include('../includes/topnav.php'); ?>
    <!-- The clear below keeps the navigation inside the header on resize -->
    <div class="clearit"></div>
    <!-- close header -->
  </div>
  <div id="strap">
    <!-- close strap -->
  </div>
  <div id="content">
    <h1>Buyer's Services </h1>
    <div id="innerwrapper">
      <div id="rightcol"><img src="images/steeple.jpg" alt="Stirling Steeple" width="161" height="121" /><img src="images/robert_the_bruce.jpg" alt="Robert the Bruce" width="161" height="121" /><img src="images/uni.jpg" alt="university" width="161" height="121" /></div>
      <div id="leftcol">
        <?php include('../includes/buyers.php'); ?>
        <!-- close leftcol -->
      </div>
      <div id="innercontent">
        <h2>Contact Us </h2>
        <h4>We will contact you within 24 hours.</h4>
        <?php
if(!$error) {
print '<p><strong>Note</strong>: 
   All fields of the form are required.</p>'."\n";
} else {
print '<p>Could not process form because you have left something out. 
Please correct the errors listed below:</p>'."\n";
print '<ul id="list-error">'."\n";
foreach($error as $key => $value) {
	print '<li>'.$value.'</li>'."\n";
}
print '</ul>'."\n";
}
?>
        <form id="form-contact" action="<?php print $_SERVER['PHP_SELF']; ?>" method="post">
          <div>
            <label for="form-contact-name">Your Name:</label>
            <input type="text" id="form-contact-name" name="form_contact_name" <?php if(isset($_POST[
'form_contact_name'])) { print 'value="'.$_POST['form_contact_name'].'"'; } ?> />
            <label for="form-contact-email">Your email:</label>
            <input type="text" id="form-contact-email" name="form_contact_email" <?php if(isset($_POST['form_contact_email'])) { print 'value="'.$_POST['form_contact_email'].'"'; } ?> />
            <label for="form-contact-message">Your Message:</label>
            <textarea cols="40" rows="14" id="form-contact-message" name="form_contact_message"> <?php if(isset($_POST['form_contact_message'])) { 
   print stripslashes($_POST['form_contact_message']); } ?>
</textarea>
            <table cellpadding=5 cellspacing=0 bgcolor="#E4F8E4">
              <tr bgcolor="#AAD6AA">
                <td colspan="2"><font color="#FFFFFF" face="Verdana" size="2"><b>Image Verification</b></font></td>
              </tr>
              <tr>
                <td style="padding: 2px;" width="10"><img src="/captcha/captchac_code.php" id="captcha"></td>
                <td valign="top"><font color="#000000">Please enter the text from the image</font>   <br>
                  <input type="text" name="Turing" value="" maxlength="100" size="10">
                  [ <a href="#" onclick=" document.getElementById('captcha').src = document.getElementById('captcha').src + '?' + (new Date()).getMilliseconds()">Refresh Image</a> ] [ <a href="/captcha/whatisturing.html" onClick="window.open('/captcha/whatisturing.html','_blank','width=400, height=300, left=' + (screen.width-450) + ', top=100');return false;">What's This?</a> ] </td>
              </tr>
            </table>
            <input type="submit" id="form-contact-submit" name="form_contact_submit" value="Send Message" />
          </div>
        </form>
        <p>Information needed on this form:</p>
        <ul>
          <li>First Name:</li>
          <li>Last Name: </li>
          <li>Phone: </li>
          <li>Cell Phone:</li>
          <li> Fax:</li>
          <li> Email Address: </li>
          <li>Description of a business you are interested in:</li>
          <li> Geographic Location of the Business you are interested in: </li>
          <li>Available Capital:</li>
          <li> Other comments: </li>
        </ul>
        <!-- close innercontent -->
      </div>
      <div id="footer2col">
        <?php include('../includes/footer.php'); ?>
      </div>
      <!-- The clear below keeps the content longer than the left nav -->
      <div class="clearit"></div>
      <!-- close innerwrapper -->
    </div>
    <!-- close content -->
  </div>
  <!-- close wrapper -->
</div>
</body>
</html>

 

Link to comment
Share on other sites

I'm not going through all of that code but I can tell you from experience that it's probably going to be one of two things.

 

1. Unclosed HTML tag

2. Misaligned css (borders, floats, etc).

 

The best way I find my errors are to run it through an XHTML validator to see if  have any unclosed tags. If I'm still getting an issue I start ripping out styles until I find the cause (that's if I don't already know where it's coming from).

Link to comment
Share on other sites

Sorry, I clicked on a link to see what it was doing and I can tell you that I see the font-family changing when I mouse over. The best thing to do here is make sure your css classes are closed because if you leave something open it can "bleed" into the next one or maybe just assign a static font-family to the menu. Play around to see what you get.

Link to comment
Share on other sites

Hmmm.........that is odd, because that is an "includes" file.  That includes file is based on a stylesheet, so that stylesheet affects all pages on the site, and all pages work fine EXCEPT the 3 pages with the php form on it.

 

That is why it is mind-boggling -- all the pages are based on the same includes, same stylesheet, but the only pages affected are the form pages.

Link to comment
Share on other sites

YOU ARE A GENIUS! ;D:D;):):-[ :-[

 

That's EXACTLY what it was!  I had forgotten that there is also a stylesheet for the form!  :-[

 

When I checked the font in that it was different than the font for the entire site, so it was affecting the font for ONLY the form pages.

 

THANK YOU THANK YOU THANK YOU!!!!

Link to comment
Share on other sites

Yeah, sorry about all the posts.  But THANK YOU SO MUCH for the great clue! font! font! font!

I have two stylesheets and had forgotten I used one specifically for the form page.

 

Thank you again!  I was blessed to have found PHP freaks!  You responded so quickly I almost fell off my chair.  I thought I'd have to wait at LEAST 3-4 days!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.