使用<input /> PHP / HTML中的post方法获取价值

时间:2015-10-08 22:52:13

标签: php html input

我有以下代码,我正在尝试发送&#34;用户名&#34;当我点击按钮时,文本字段的值到下一页,不幸的是,正在发送的值总是&#34; &#34;,我在这里做错了什么?

 <!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
<head>
    <?php 
     include "../pfe/files/connect.php";
     $page = isset($_POST['page']) ? $_POST['page'] : '';

     if(!$page) {
     $id = $_GET["id"];

    session_start();
                }


    ?>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <?php
     echo'<title>User Page</title>';
    ?>
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/new.css">
    <!--[if lt IE 9]><script    src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->

    </head>
    <body>
    <div align="center">

    <?php
    $query1 = "select * from USER where ID=$id";

    $exec1 = $mysql->query($query1) or die("Erreur ...");
    $row1 = $exec1->fetch_array();

     ?>
                <form name="form" method="post">
                <table align=\"center\" border=\"1\ " >
                <thead>
                    <tr>
                    <td><input type="text" name="username" id="username"  placeholder="Username" required value=<?php echo htmlentities($row1["USERNAME"]); ?>></td>
                    <td></tr>

                </thead>
                </table>
                </form>

                <?php

                $username = isset($_POST['username']) ?      $_POST['username'] : '';
                echo' hone \'{$username}\'';

                if(isset($_GET["update"]))
                    {
                    $username2= $_GET["username2"];
    $query1 = "UPDATE USER set USERNAME='$username2' where USER.ID=$id";

    $exec1 = $mysql->query($query1) or die("Error");}
                ?>
                <table>
                <tread>

                    <tr>
                    <td>
                    <?php  $username = isset($_POST['username']) ?   $_POST['username'] : '';
                    echo" <a href=\"../pfe/user.php?  update&id=$id&username2=$username\" class=\"button yellow\">Update</a>  <br>"; ?></td> </tr>


    <?php    



    include "../pfe/files/disconnect.php";
    ?>


                </thead>
                </table>


</div>
</body>
</html>

0 个答案:

没有答案