0

我将创建一个静态 PHP 表单,您可以在其中允许用户填写他们的信息,包括图像和所有数据。问题是提交表单时,链接页面action="..."没有显示填写的信息或数据和图像。 HTML 代码如下所示:

<!DOCTYPE html>
      <head>
     <title></title>
   <script type="text/javascript" src="http:////ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
      <script type="text/javascript" src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
     <script type="text/javascript" src="jquery.js"></script>
         <script type="text/javascript">
       function readURL(input) {
             if (input.files && input.files[0]) {
            var reader = new FileReader();

            reader.onload = function (e) {
                $('#blah').attr('src', e.target.result);
            }

            reader.readAsDataURL(input.files[0]);
        }
    }
    </script>
     </head>


      <body>
         <form name="rform" method="get" action="researchers.php">  
      <h4>Researchers Profile</h4> 

         <fieldset>
    <legend>Perosnal Details</legend>
       <form id="form1" runat="server"  method="get" action="researchers.php" enctype="multipart/form-data" id="pro_image>
       <input type='file' onchange="readURL(this);" />
          <br><img id="blah" src="profile pic.jpg" alt="your image" width="160px" height="120px" name="image"/><br/>
</form>

    <table width="600px">
    <tr>    
        <td>Name</td>   
        <td>:</td>
        <td><input type="text" name="rname" maxlength="40" size="50" placeholder="Your Name"></td>
    </tr>
     <tr>
        <td>Education</td> 
        <td>:</td>
        <td><textarea name="edu" rows="3" cols="70" placeholder="Education"></textarea></td>
    <tr>
        <td>Address</td>
        <td>:</td>
        <td><textarea name="address" rows="3" cols="70" placeholder="Address"></textarea></td>
    </tr>
    <tr>
        <td>Office</td>
        <td>:</td>
        <td><input type="text" name="office" size="50" maxlength="50" placeholder="Office"><td>
    </tr>  
    <tr>
        <td>Fax</td>
        <td>:</td>
        <td><input type="text" name="fax" size="50" maxlength="50" placeholder="Fax"></td>
    </tr>
    <tr>
        <td>Email</td>
        <td>:</td>
        <td><input type="email" name="remail" maxlength="40" size="50" placeholder="Your Email"></td>
    </tr>
    <tr>
        <td>Research Overview</td>
        <td>:</td>
        <td><textarea name="overview" rows="10" cols="70" placeholder="Research Overview"></textarea></td>
    </tr>
     <tr>
        <td>Keywords</td>
        <td>:</td>
        <td><textarea name="keywords" rows="8" cols="70" placeholder="Keywords"></textarea></td>
     </tr>
    </table>
            <script type="text/javascript">
    function readURL2(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();

            reader.onload = function (e) {
                $('#blah2').attr('src', e.target.result);
            }

            reader.readAsDataURL(input.files[0]);
        }
    }
</script> 
    <fieldset>
    <legend>Projects</legend>

     <form id="form2" runat="server" method="get" action="researchers.php" enctype="multipart/form-data" id="pro_image>
    <input type='file' onchange="readURL2(this);" />
    <br><img id="blah2" src="information.jpg" alt="your image" width="600px" height="180px" name="image2"/><br/>
</form>
        <table width="600px" id="project">
            <tr>
                <td>1</td>
                <td><textarea name="pro_1" cols="100" rows="2"></textarea></td>
            </tr>
            <tr>
                <td>2</td>
                <td><textarea name="pro_2" cols="100" rows="2"></textarea></td>
            </tr>
            <tr>
                <td>3</td>
                <td><textarea name="pro_3" cols="100" rows="2"></textarea></td>
            </tr>


        </table>

     </fieldset>
        <script type="text/javascript">
 function readURL3(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();

            reader.onload = function (e) {
                $('#blah3').attr('src', e.target.result);
            }

            reader.readAsDataURL(input.files[0]);
        }
    }
</script> 

      <fieldset>
    <legend>Publications</legend>
     <form id="form2" runat="server" method="get" action="researchers.php" enctype="multipart/form-data" id="pro_image">
    <input type='file' onchange="readURL3(this);" />
    <br><img id="blah3" src="information.jpg" alt="your image" width="600px" height="180px" name="image3"/><br/>
</form>
        <table width="600px" id="pub">
            <tr>
                <td>1</td>
                <td><textarea name="pub_1" cols="100" rows="2"></textarea></td>
            </tr>
            <tr>
                <td>2</td>
                <td><textarea name="pub_2" cols="100" rows="2"></textarea></td>
            </tr>
            <tr>
                <td>3</td>
                <td><textarea name="pub_3" cols="100" rows="2"></textarea></td>
            </tr>

        </table>

</form>

<input type="submit" name="savebtn" value="Save"/>
<input type="reset" name="resetbtn" value="Reset"/>

下面作为研究人员.php 代码:

<!DOCTYPE html>
   <head>
   <title></title>
  </head>
  <body>
      <h4>Researchers Profile</h4> 

    <fieldset>
    <legend>Perosnal Details</legend>
        <?php echo $_GET["image"]; ?>

       </form>
        <table width="600px">
    <tr>    
        <td>Name</td>   
        <td>:</td>
        <td><?php echo $_GET["rname"]; ?></td>
    </tr>
     <tr>
        <td>Education</td> 
        <td>:</td>
        <td><?php echo $_GET["edu"]; ?></td>
    <tr>
        <td>Address</td>
        <td>:</td>
        <td><?php echo $_GET["address"];?></td>
    </tr>
    <tr>
        <td>Office</td>
        <td>:</td>
        <td><?php echo $_GET["office"];?><td>
    </tr>  
    <tr>
        <td>Fax</td>
        <td>:</td>
        <td><?php echo $_GET["fax"];?></td>
    </tr>
    <tr>
        <td>Email</td>
        <td>:</td>
        <td><?php echo $_GET["remail"];?></td>
      </tr>
      <tr>
        <td>Research Overview</td>
        <td>:</td>
        <td><?php echo $_GET["overview"];?></td>
    </tr>
     <tr>
        <td>Keywords</td>
        <td>:</td>
        <td><?php echo $_GET["keywords"];?></td>
     </tr>
    </table>

    <fieldset>
    <legend>Projects</legend>

        <?php echo $_GET["image2"]; ?>
        <table width="600px" id="project">
            <tr>
                <td>1</td>
                <td><?php echo $_GET["pro_1"]; ?></td>
            </tr>
            <tr>
                <td>2</td>
                <td><?php echo $_GET["pro_2"]; ?></td>
            </tr>
            <tr>
                <td>3</td>
                <td><?php echo $_GET["pro_3"];?></td>
            </tr>


        </table>

  </fieldset>
    <fieldset>
    <legend>Publications</legend>
        <?php echo $_GET["image3"]; ?>        
        <table width="600px" id="pub">
            <tr>
                <td>1</td>
                <td><?php echo $_GET["pub_1"]; ?></td>
            </tr>
            <tr>
                <td>2</td>
                <td><?php echo $_GET["pub_2"]; ?></td>
            </tr>
            <tr>
                <td>3</td>
                <td><?php echo $_GET["pub_3"]; ?></td>
            </tr>

        </table>

4

2 回答 2

0

这是第2页

<h4>Researchers Profile</h4> 

<fieldset>
<legend>Perosnal Details</legend>
<?php echo $_GET["image"]; ?>
<table width="600px">
    <tr><td>Name</td><td>:</td><td><?php echo $_GET["rname"]; ?></td></tr>
    <tr><td>Education</td><td>:</td><td><?php echo $_GET["edu"]; ?></td></tr>
    <tr><td>Address</td><td>:</td><td><?php echo $_GET["address"];?></td></tr>
    <tr><td>Office</td><td>:</td><td><?php echo $_GET["office"];?><td></tr>  
    <tr><td>Fax</td><td>:</td><td><?php echo $_GET["fax"];?></td></tr>
    <tr><td>Email</td><td>:</td><td><?php echo $_GET["remail"];?></td></tr>
    <tr><td>Research Overview</td><td>:</td><td><?php echo $_GET["overview"];?></td></tr>
    <tr><td>Keywords</td><td>:</td><td><?php echo $_GET["keywords"];?></td></tr>
</table>
</fieldset>

<fieldset>
<legend>Projects</legend>
<?php echo $_GET["image2"]; ?>
<table width="600px" id="project">
    <tr><td>1</td><td><?php echo $_GET["pro_1"]; ?></td></tr>
    <tr><td>2</td><td><?php echo $_GET["pro_2"]; ?></td></tr>
    <tr><td>3</td><td><?php echo $_GET["pro_3"];?></td></tr>
</table>
</fieldset>

<fieldset>
<legend>Publications</legend>
<?php echo $_GET["image3"]; ?>        
<table width="600px" id="pub">
    <tr><td>1</td><td><?php echo $_GET["pub_1"]; ?></td></tr>
    <tr><td>2</td><td><?php echo $_GET["pub_2"]; ?></td></tr>
    <tr><td>3</td><td><?php echo $_GET["pub_3"]; ?></td></tr>
</table>
</fieldset>
于 2013-04-26T04:07:46.903 回答
0

输入类型提交需要在你的标签内

<form action="" method="">
<input type="submit"/>
</form>

///////////////////////////////////////// ///////////

<script type="text/javascript" src="http:////ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
function readURL(input) {
    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {
        $('#blah').attr('src', e.target.result);
        }

        reader.readAsDataURL(input.files[0]);
    }
}
</script>

<form name="rform" method="get" action="researchers.php"> 
    <h4>Researchers Profile</h4> 
    <fieldset>
        <legend>Perosnal Details</legend>
        <input type='file' name="image" onchange="readURL(this);" />
        <br><img id="blah" src="profile pic.jpg" alt="your image" width="160px" height="120px" name="image"/><br/>

        <table width="600px">
        <tr><td>Name</td><td>:</td><td><input type="text" name="rname" maxlength="40" size="50" placeholder="Your Name"></td></tr>
        <tr><td>Education</td><td>:</td><td><textarea name="edu" rows="3" cols="70" placeholder="Education"></textarea></td>
        <tr><td>Address</td><td>:</td><td><textarea name="address" rows="3" cols="70" placeholder="Address"></textarea></td></tr>
        <tr><td>Office</td><td>:</td><td><input type="text" name="office" size="50" maxlength="50" placeholder="Office"><td></tr>  
        <tr><td>Fax</td><td>:</td><td><input type="text" name="fax" size="50" maxlength="50" placeholder="Fax"></td></tr>
        <tr><td>Email</td><td>:</td><td><input type="email" name="remail" maxlength="40" size="50" placeholder="Your Email"></td></tr>
        <tr><td>Research Overview</td><td>:</td><td><textarea name="overview" rows="10" cols="70" placeholder="Research Overview"></textarea></td></tr>
        <tr><td>Keywords</td><td>:</td><td><textarea name="keywords" rows="8" cols="70" placeholder="Keywords"></textarea></td></tr>
        </table>
    </fieldset>
<script type="text/javascript">
function readURL2(input) {
    if (input.files && input.files[0]) {
    var reader = new FileReader();

    reader.onload = function (e) {
        $('#blah2').attr('src', e.target.result);
    }

    reader.readAsDataURL(input.files[0]);
    }
}
</script> 
    <fieldset>
        <legend>Projects</legend> 
        <input type='file' name="image2" onchange="readURL2(this);" />
        <br><img id="blah2" src="information.jpg" alt="your image" width="600px" height="180px" name="image2"/><br/>

        <table width="600px" id="project"><tr>
        <td>1</td><td><textarea name="pro_1" cols="100" rows="2"></textarea></td></tr>
        <tr><td>2</td><td><textarea name="pro_2" cols="100" rows="2"></textarea></td></tr>
        <tr><td>3</td><td><textarea name="pro_3" cols="100" rows="2"></textarea></td></tr> 
        </table>
    </fieldset>
<script type="text/javascript">
function readURL3(input) {
    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {
            $('#blah3').attr('src', e.target.result);
        }

        reader.readAsDataURL(input.files[0]);
    }
}
</script> 
    <fieldset>
        <legend>Publications</legend>
        <input type='file' name="image3" onchange="readURL3(this);" />
        <br><img id="blah3" src="information.jpg" alt="your image" width="600px" height="180px" name="image3"/><br/>

        <table width="600px" id="pub"><tr><td>1</td>
        <td><textarea name="pub_1" cols="100" rows="2"></textarea></td></tr>
        <tr><td>2</td><td><textarea name="pub_2" cols="100" rows="2"></textarea></td></tr>
        <tr><td>3</td><td><textarea name="pub_3" cols="100" rows="2"></textarea></td></tr>
        </table>
    </fieldset>

<input type="submit" name="savebtn" value="Save"/>
<input type="reset" name="resetbtn" value="Reset"/>       
</form>
于 2013-04-25T17:54:17.517 回答