联系表格不工作jQuery Php

时间:2013-10-11 13:47:29

标签: php jquery forms

我的网站正在使用ben alman的bbq插件,内容是动态生成的 当我点击提交按钮时,我的联系页面将是http://example.com/#contact.php,它只是将我重定向到主页(index.php)。 我已经尝试将contact.php放在form action=""中,但它只是跳转到该页面,但网站的所有元素都是丢失的。

我也尝试在contact.php的前面在form action =“”中添加#它只是同一页面,表单不发送。

这是我在联系页面上的代码

    <?php include ('admin/inc/fnc.php'); ?>
<!--<?php require_once('Connections/connectdb.php'); ?>-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> 
<script src="js/jquery.ba-bbq.min.js"></script>
<link href="style/style.css" rel="stylesheet" type="text/css" />
<div id="content-wrap">
<h1 class="headingtext2">Contact</h1>
         <p class="">Have enquiries?<br /> Want me to create something that will make you or your company stand out from the crowd?<br /><br /> Pop me a email, we can discuss greater into detail<br />
           Please Allow up to at least 24 hours for your questions to be responded
         </p>
      <div id="contactform">
        <?php
mysql_select_db($database_connectdb, $connectdb);
$query_rsEmailAddress = "SELECT adm_email FROM tbl_admins WHERE adm_id=1";
$rsEmailAddress = mysql_query($query_rsEmailAddress, $connectdb) or die(mysql_error());
$row_rsEmailAddress = mysql_fetch_assoc($rsEmailAddress);
$totalRows_rsEmailAddress = mysql_num_rows($rsEmailAddress); 
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
      $self = $_SERVER['PHP_SELF'];
}
//$to = $row_rsEmailAddress['adm_email']; 
// process the email
if (array_key_exists('btn', $_POST)) { 
// process the email
$to = 'contact@hybridizedesigns.com'; // own email address
$subject = 'Message from Hybridize Designs website'; 
// list expected fields
$expected = array('frmname','frmemail','frmtel','frmmessage'); 
// set required fields
$required = array('frmname','frmemail','frmmessage'); 
// create empty array for any missing fields
$missing = array(); 

 // process the $_POST variables
 foreach ($_POST as $key => $value) {  
  // assign to temporary variable and strip whitespace if not an array
  $temp = is_array($value) ? $value : trim($value); 
  // if empty and required, add to $missing array
  if (empty($temp) && in_array($key, $required)) { 
   array_push($missing, $key); 
  } // otherwise, assign to a variable of the same name as $key 
  elseif (in_array($key, $expected)) { 
   ${$key} = $temp; 
  }  
 }

// validate the email address
if (!empty($frmemail)) { 
 // regex to ensure there are no illegal characters in email address
 $checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';  
 // reject the email address if it doesn't match
 if (!preg_match($checkEmail, $frmemail)) { 
  array_push($missing, 'frmemail'); 
 } 
} 
//get IP address
$ip = $_SERVER['REMOTE_ADDR']; 
//make time
$time = time();
$date = date("r", $time); 
// go ahead only if all required fields are ok
if (empty($missing)) { 
$frmmessage = nl2br($frmmessage); 
// build the message
$message = "<div style=\"font-size:12px;font-family:arial,verdana,sans-serif;color:#666;line-height:26px;padding:10px;\">";
$message .= "<div style=\"width:100%;\"><strong style=\"width: 180px;height:auto;\">Name:</strong> $frmname</div>";
$message .= "<div style=\"width:100%;\"><strong style=\"width: 180px;height:auto;\">Email:</strong> $frmemail</div>";
$message .= "<div style=\"width:100%;\"><strong style=\"width: 180px;height:auto;\">Telephone:</strong> $frmtel</div>";
$message .= "<div style=\"width:100%;\"><strong style=\"width: 180px;height:auto;\">Message:</strong><br />$frmmessage</div>";
$message .= "<div style=\"width:100%;\"><strong style=\"width: 180px;height:auto;\">IP:</strong> <span style=\"color:#990000;\">$ip</span></div>";
$message .= "<div style=\"width:100%;\"><strong style=\"width: 180px;height:auto;\">Date:</strong> $date</div></div>"; 
// create additional headers 
$additionalHeaders = "From: $frmemail<$frmemail>"; 
if (!empty($frmemail)) { 
 $additionalHeaders .= "\r\nReply-To: $frmemail"; 
} 
$additionalHeaders .= "\r\nContent-type: text/html; charset=us-ascii"; 
// send email
$mailSent = mail($to, $subject, $message, $additionalHeaders); 
if ($mailSent) { 
 // $missing is no longer needed if the email is sent, so unset it
 unset($missing); 
} 
} 
} 
?> 
<link href="../style/style.css" rel="stylesheet" type="text/css" /> 
<form id="frmcontact" name="frmcontact" method="post" action="">
  <table border="0" cellspacing="0" cellpadding="0" id="tbl_contact">
    <?php 
 global $mailSent;
    global $missing; 
 if ($_POST && $mailSent) { ?>
    <tr>
      <td colspan="2" style="padding:0px 0px 315px 0px;"><p class="warning_sent">Your message has been sent successfuly.<br />
          I will get back to you shortly.</p></td>
    </tr>
    <?php } else {
      if ($_POST && isset($missing)) { ?>
    <tr>
      <td colspan="2" style="padding:0px 0px 10px 0px;"><p class="warning">Please complete the missing item(s) indicated.</p></td>
    </tr>
    <?php } elseif ($_POST && !isset($missing) && !$mailSent) { ?>
    <tr>
      <td colspan="2" style="padding:0px 0px 10px 0px;"><p class="warning">Sorry there was a problem sending your message.<br />
          Please try again later.</p></td>
    </tr>
    <?php } ?>
    <?php if (isset($missing) && in_array('frmname', $missing)) { ?>
      <tr>
        <th scope="row">&#160;</th>
        <td><span class="missing">Please provide your name</span></td>
      </tr>
      <?php } ?>
    <tr>
      <th scope="row"><label for="frmname" class="req">Name:</label></th>
      <td><input type="text" name="frmname" id="frmname" class="frmfld" <?php if (isset($missing)) { echo 'value="'.htmlentities($_POST['frmname']).'"'; } ?> /></td>
    </tr>
    <?php if (isset($missing) && in_array('frmemail', $missing)) { ?>
      <tr>
        <th scope="row">&#160;</th>
        <td><span class="missing">Please provide your valid email address</span></td>
      </tr>
      <?php } ?>
    <tr>
      <th scope="row"><label for="frmemail" class="req">Email:</label></th>
      <td><input type="text" name="frmemail" id="frmemail" class="frmfld" <?php if (isset($missing)) { echo 'value="'.htmlentities($_POST['frmemail']).'"'; } ?> /></td>
    </tr>
    <?php if (isset($missing) && in_array('frmtel', $missing)) { ?>
      <tr>
        <th scope="row">&#160;</th>
        <td><span class="missing">Please provide your telephone number</span></td>
      </tr>
      <?php } ?>
    <tr>
      <th scope="row"><label for="frmtel">Telephone:</label></th>
      <td><input type="text" name="frmtel" id="frmtel" class="frmfld" <?php if (isset($missing)) { echo 'value="'.htmlentities($_POST['frmtel']).'"'; } ?> /></td>
    </tr>
    <?php if (isset($missing) && in_array('frmmessage', $missing)) { ?>
      <tr>
        <th scope="row">&#160;</th>
        <td><span class="missing">Please provide your message</span></td>
      </tr>
      <?php } ?>
    <tr>
      <th scope="row"><label for="frmmessage" class="req">Message:</label></th>
      <td><textarea name="frmmessage" id="frmmessage" cols="" rows="" class="frmarea"><?php if (isset($missing)) { echo htmlentities($_POST['frmmessage']); } ?>
</textarea></td>
    </tr>
    <tr>
      <th scope="row">&nbsp;</th>
      <td><label for="btn" id="sbm">
          <input type="submit" name="btn" id="btn" value="" />
        </label></td>
    </tr>
    <?php } ?>
  </table>
</form> 

      </div>
</div>

如何在提交按钮中获取正确的链接?

0 个答案:

没有答案