LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 517|回复: 2

那位大侠帮俺会诊一下下面的代码,给点修改意见与思路,谢了。

[复制链接]
发表于 2005-5-11 09:58:40 | 显示全部楼层 |阅读模式
俺先说说的俺的意图与实现思路吧:页面上有四个radio按钮,每个按钮对应表格里各个GIF文件,这四个GIF文件相当于四样产品,俺想客户每选定一个 radio ,就激活一段PHP代码,这段PHP代码就实现连接MYSQL数据库,并取得对应某个产品的条形码与密码的值,然后通过一段 javascript代码作判断,跟着将条形码的值显示在条形码框里,跟着就在密码框里输入六位数字,然后按确定,作个判断,如果输入数字跟取得的产品密码值相同的,就弹出该产品的下载对话框,如果不一样就弹出密码不正确的警告框。代码如下:

downtest.html


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> 下载测试页 </TITLE>
<META NAME="Generator" CONTENT="editplus&vi&emacs&phped">
<META NAME="Author" CONTENT="evan">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<p align="center" > <b>
<font color="0000FF" face ="黑体“ size="18" >
下载测试页
</font>
</b>
</p>
<hr>
<br>
<br>
<script language="javascript">
<!--begin
var wares="";
//radio buttons are either/or elements
//MIE evaluates onClick of an elemet,NN does not
function getRadio(what) {
//get the wares
j=what.wares.length;//alert(j)
for (i=0;i<j;i++) {
if (what.wares.checked) var wares = what.wares.value
//show selections
what.barcode.value= (wares)

}
//end==>
}
</script>

<?php
// this php script be use to vote in
// barcode and passwd from epay_all
// datatable  of epay database .
$dbcnt= mysql_pconnect("localhost","root","")or die("Could not connect");
$reselt= mysql_select_db("epay") or die("Could not connect");
$sqla= "select barcode,passwd from epay_all where ware = '高山' limit 1" ;
$sqlb= "select barcode,passwd from epay_all where ware = '大海' limit 1" ;
$sqlc= "select barcode,passwd from epay_all where ware = '蓝天' limit 1" ;
$sqld= "select barcode,passwd from epay_all where ware = '白云' limit 1" ;
if radioa=cheched {
        $resulta=mysql_query($sqla)or die ("Could not connect");
        $row=mysql_fetch_array($resulta);
         $barcode=$row["barcode"];
         $passwd=$row["passwd"];
                                        }
        else if radiob=cheched{
                $resultb=mysql_query($sqlb) or die ("Could not connect");
                $row=mysql_fetch_array($resultb);
                $barcode=$row["barcode"];
                $passwd=$row["passwd"];
                                }
                        else if radioc=cheched {
                        $resultc=mysql_query($sqlc) or die("Could not connect");
                         $row=mysql_fetch_array($resultc);
                         $barcode=$row["barcode"];
                         $passwd=$row["passwd"];
                        }
                        else if radiod=cheched {
                                 $resultd=mysql_query($sqld) or die("Could not connect");
                                 $row=mysql_fectch_array($resultd);
                                 $barcode=$row["barcode"];
                                 $passwd=$row["passwd"];
                        }
# mysql_close($dbcnt);
?>

<script language="javascript">
<!--begin
//compare passwd and $passwd two variable,
//if passwd equal $passwd ,point to a href,
//else ponit to alert dialog box.

function compare(){
var $passwd;

if ("passwd" == $passwd){
        location.href="image/001.gif";
   }
   else {
           alert("密码不正确,请正确输入密码!");

        }
}
//end==>
</script>


<p align="center">
<table border="1" width="50%">
  <tr>
    <td  width="25%"> <img src="image/001.gif" width="30" height="30"></td>
        <td  width="25%"> <img src="image/002.gif" width="30" height="30"></td>
        <td  width="25%"> <img src="image/003.gif" width="30" height="30"></td>
        <td  width="25%"> <img src="image/004.gif" width="30" height="30"></td>
  </tr>
</table>
</p>
<p>
<form name="picform">
<div onClick='getRadio(document.picform)' />
<p align="center">
<input type="radio" name="wares" value="20181593578" id="radioa"  >高山&nbsp&nbsp&nbsp<input type="radio" name="wares" value="20181472589" id="radiob">大海&nbsp&nbsp&nbsp<input type="radio" name="wares" value="$barcode" id="radioc">蓝天&nbsp&nbsp&nbsp<input type="radio" name="wares" value="$barcode" id="radiod">白云&nbsp&nbsp&nbsp
</p>

<br><br>
</div>

<p align="center">
产生条形码:<input type="text" name="barcode" size="24" maxlength="24">
</p>
<p align="center">
输入&nbsp&nbsp密码: <input type="text" name="passwd" id="passwd" value="" size ="24" maxlength="24"></p>
<p align="center">
<input type="button" name="button" value="确认" size="8" onclick="compare()">&nbsp&nbsp&nbsp <input type="reset" name="reset" value="重置" size="8" >
</p>
</form>
</p>

<hr>
<marquee> 将相本无种,男儿当自强!</marquee>

</BODY>
</HTML>
 楼主| 发表于 2005-5-11 11:47:16 | 显示全部楼层
那downtest.html 就是俺实现那思路的初步代码
.现在问题就是在WINDOWS下面打开这个downtest.html 时,基本效果就出来了,也就是选一个raido值时,代码框有个预定值显示出来,这个值就是 <input type="radio" name="wares" value="20181593578" id="radioa"  >中的value值,这说明javasrcip代码中的"function getRadio(what) {"是产生作用的,而手工在密码框输入框输入六位数时,再按确定,也可以弹出密码不正确的警告框,这说明 javascrip代码中的"function compare(){"也产生作用。只是将这html放到linux的真实环境里,打开这个html网页,就一点反应就没有,只看到这个html页的界面。因而猜想问题可能是PHP连接MYSQL数据库取值这方面有问题。



ps: 俺的环境: 俺先在windows2000,用EDIDPLUS写好一些代码,然后放到vmware 下的linux环境(已装好linux+apache+php+mysql+phpmyadmin) ,而windows2000没装php,mysql,因而WINDOWS2000不支持PHP.
回复 支持 反对

使用道具 举报

发表于 2005-5-11 18:30:05 | 显示全部楼层
不知兄弟的 radioa\b\c\d是如何传递到服务器的?请将if radioa=cheched 改为
[php]if ($_POST["waves"]=="20181593578"){....}[/php]
以下BCD类同...试试!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表