PHP表单不会在IE中处理

时间:2013-08-30 15:22:49

标签: php html mysql internet-explorer

您键入“姓氏”或数字“xxxxx-xx-xxx”的表单适用于每个浏览器接受IE。 IE 9和10无论如何都是我可以访问的。

<form action="search_view.php" id="contactform" method="get" >

<h2>Search AES-MOM UHV Cleaning Database</h2>
<p>
<label>Search by Last name or Cost Code:</label>
<input type="text" name="query" value=""><input name="submit" type="submit" value="Submit">
</p></form>

PHP处理代码如下。 在IE中它返回“最小字符长度为2”,就像表格是空的

<?php
mysql_connect("", "", "") or die("Error connecting to database: ".mysql_error());
/*
    localhost - it's location of the mysql server, usually localhost
    root - your username
    third is your password

    if connection fails it will stop loading the page and display an error
*/

mysql_select_db("MOM_vac-cleaning") or die(mysql_error());
/* tutorial_search is the name of database we've created */
 ?>

<!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>Search results</title>   
</head>
<body>  
<table>
<tr>
    <td>
<?php
$query = $_GET['query'];
// gets value sent over search form

$min_length = 2;
// you can set minimum length of the query if you want

if(strlen($query) >= $min_length){ // if query length is more or equal minimum length then

    $query = htmlspecialchars($query);
    // changes characters used in html to their equivalents, for example: < to &gt;

    $query = mysql_real_escape_string($query);
    // makes sure nobody uses SQL injection

   $raw_results = mysql_query("SELECT * FROM cleaning WHERE lname LIKE '%".$query."%' OR cost_code LIKE '%".$query."%' ORDER BY id DESC") or die(mysql_error());

    // '%$query%' is what we're looking for, % means anything, for example if $query is Hello
    // it will match "hello", "Hello man", "gogohello", if you want exact match use `title`='$query'
    // or if you want to match just full word so "gogohello" is out use '% $query %' ...OR ... '$query %' ... OR ... '% $query'

    echo "<table class='table' border='1' cellpadding='3' align='center'>";
    echo "<th class='blackbg'>NAME</th><th class='blackbg'>GROUP</th><th class='blackbg'>COST CODE</th><th class='blackbg'>EMAIL</th><th class='blackbg'>PHONE</th><th class='blackbg'>DATE<br />REQUIRED</th><th class='blackbg'>DESCRIPTION</th><th class='blackbg'>INSTRUCTIONS</th><th class='blackbg'>ALCOHOL<br />ACETONE</th><th class='blackbg'>REG WASH<br />CU</th><th class='blackbg'>REG WASH<br />AL/SS</th><th class='blackbg'>DRYING<br />OVEN</th><th class='blackbg'>OVEN<br />TEMP</th><th class='blackbg'>UHV OVEN<br />BAKEOUT</th><th class='blackbg'>TEMP/TIME</th><th class='blackbg'>BAKEOUT<br />REQUESTS</th><th class='blackbg'>DATE OF<br />WORK</th><th class='blackbg'>TIME<br />SPENT</th><th class='blackbg'>TECHNICIAN</th><th class='blackbg'>UHV OVEN<br />PROGRAM</th><th class='blackbg'>COMMENTS</th><th class='blackbg'>TECHNICIAN</th></tr>";

    if(mysql_num_rows($raw_results) > 0){ // if one or more rows are returned do following

        while($results = mysql_fetch_array($raw_results)){
        // $results = mysql_fetch_array($raw_results) puts data from database into array, while it's valid it does the loop

            echo "<tr>";
            echo "<td>" . $results['fname'] . " " . $results['lname'] . "</td>";
            echo "<td>" . $results['group']."</td>";
            echo "<td>" . $results['cost_code']."</td>";
            echo "<td>" . $results['email']."</td>";
            echo "<td>" . $results['phone'] . "</td>";  
            echo "<td>" . $results['date_req'] . "</td>";   
            echo "<td>" . $results['description']."</td>";
            echo "<td>" . $results['instructions']."</td>";
            //echo "<td>" . $results['alc']."</td>";
            if($results['alc']  == "1"){
                echo "<td bgcolor='#C5EECD' align='center'>Yes</td>";
                }
            else if ($results['alc']  == "0"){
                echo "<td bgcolor='#F7C1C8' align='center'>No</td>";}

            //echo "<td>" . $results['reg_copper']."</td>";
            if($results['reg_copper']  == "1"){
                echo "<td bgcolor='#C5EECD' align='center'>Yes</td>";
                }
            else if ($results['reg_copper']  == "0"){
                echo "<td bgcolor='#F7C1C8' align='center'>No</td>";}

            //echo "<td>" . $results['reg_alum'] . "</td>";
            if($results['reg_alum']  == "1"){
                echo "<td bgcolor='#C5EECD' align='center'>Yes</td>";
                }
            else if ($results['reg_alum']  == "0"){
                echo "<td bgcolor='#F7C1C8' align='center'>No</td>";}

            //echo "<td>" . $results['drying'] . "</td>";
            if($results['drying']  == "1"){
                echo "<td bgcolor='#C5EECD' align='center'>Yes</td>";
                }
            else if ($results['drying']  == "0"){
                echo "<td bgcolor='#F7C1C8' align='center'>No</td>";}

            echo "<td>" . $results['temp'] . "</td>";               
            //echo "<td>" . $results['uhv'] . "</td>";
            if($results['uhv']  == "1"){
                echo "<td bgcolor='#C5EECD' align='center'>Yes</td>";
                }
            else if ($results['uhv']  == "0"){
                echo "<td bgcolor='#F7C1C8' align='center'>No</td>";}

            echo "<td>" . $results['temp_time'] . "</td>";
            echo "<td>" . $results['bake_req'] . "</td>";               
            echo "<td>" . $results['hours'] . "</td>"; 
            echo "<td>" . $results['time_spent'] . "</td>";
            echo "<td>" . $results['tech'] . "</td>";                
            echo "<td>" . $results['program'] . "</td>";
            echo "<td>" . $results['comments'] . "</td>";
            echo "<td>" . $results['techII'] . "</td>";
            echo "</tr>";
            // posts results gotten from database(title and text) you can also show id ($results['id'])
        }       

    // close table>
    echo "</table>";

    }
    else{ // if there is no matching rows do following
        echo "No results meeting your search criteria have been found";
    }

}
else{ // if query length is less than minimum
    echo "Minimum character length is ".$min_length;
}
 ?>

非常感谢任何帮助!

0 个答案:

没有答案