duanfen2349 2014-11-22 21:09
浏览 38
已采纳

在php中获取输入类型按钮的值

I wrote this code but the problem is that when I press the "Change background" button, nothing changes but I should be able to see some part of contents after I pressed it.

<form name="change "action="index.php" method="get">
        <center><a href="index.php"><button type="button">REFRESH THE PAGE!!</button></a></center><br/>
        <center><b>WELCOME NOTE!!</b></center><br/>
        <center><textarea readonly="readonly" name="textarea" rows="6" cols="50" style="color:blue; font-size:15pt">Each day holds a surprise. But only if we expect it can we see, hear, or feel it when it comes to us. Let's not be afraid to receive each day's surprise, whether it comes to us as sorrow or as joy It will open a new place in our hearts, a place where we can welcome new friends and celebrate more fully our shared humanity.</textarea></center>
<br/>

<?php

        mysql_connect("localhost","DB","password") or die("ERROR!!");
        mysql_select_db("DB") or die("COULDN'T FIND IT!!") or die("COULDN'T FIND DB"); 


        $sql = mysql_query("SELECT * FROM background");

        $id = 'ID';
        $Blue = 'blue';
        $White = 'white';
        $Silver = 'silver';
        $Red = 'red';
        $text=$_GET['textarea'];

        while($rows = mysql_fetch_assoc($sql)){


            if (isset( $_SESSION['CurrentUser'])){

            echo '<center><button type="button" name="background">Change background</button>';
            echo '<button type="button" name="color">Change font color</button>';
            echo '<button type="button" name="size">Change font size</button></center><br/>'; 

                if (isset( $_GET['background'])){ 
                echo '<span>Choose background color</span><br/>';
                echo '<a href="?colour='.$Blue.'"><img src="red.png"></a>'; 
                echo '<a href="?colour='.$White.'"><img src="white.jpg"></a>'; 
                echo '<a href="?colour='.$Silver.'"><img src="silver.jpg"></a>';
                echo '<a href="?colour='.$Red.'"><img src="red.png"></a>'; }

            }               

    }
    ?>

    </form>


    </td></tr></table>

Program doesn't see this part;

if (isset( $_GET['background'])){ 
                    echo '<span>Choose background color</span><br/>';
                    echo '<a href="?colour='.$Blue.'"><img src="red.png"></a>'; 
                    echo '<a href="?colour='.$White.'"><img src="white.jpg"></a>'; 
                    echo '<a href="?colour='.$Silver.'"><img src="silver.jpg"></a>';
                    echo '<a href="?colour='.$Red.'"><img src="red.png"></a>'; }
  • 写回答

3条回答 默认 最新

  • dtng25909 2014-11-22 21:31
    关注

    It doesn't work because form cannot be submited without submit button: Replace <button type="button" with <button type="submit"

    BTW use mysqli_ instead of mysql_ because it is deprecated

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题