如何更改表单中提交的字符串行与另一个表单输入 [英] How do I change a string line submitted in the form with another form input

查看:263
本文介绍了如何更改表单中提交的字符串行与另一个表单输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的第一页中,我有这样的代码:

In my first page I have this code:

$number="1234567891";
$str="456";

echo "<form action='edit.php' method='POST'><input type='hidden' name='msg' value='$message' />
        <input type='hidden' name='text' value='$number' />
        <input type='hidden' name='edit' value='$str' />
        <input type='submit' name='chedit' value='Go' style='position:relative; top:25px; left: 50%;'>
      </form>";

在我的edit.php中,我有这样的代码:

In my edit.php I have this code:

<form action="#" method="POST">
   Edit Number
   <input type="text" name="change" value="$mumu"/>
   <input type="submit" name="pch" value="Change"/>
</form>

<?php
       if (isset($_POST["chedit"]))
       {
           $suj = $_POST["msg"];
           $text = $_POST["text"];
           $mumu =$_POST["edit"];
           if(isset($_POST["pch"]))
           {
               $change = $_POST["change"];       
               $obinna = str_replace("$change","$mumu","$text"); 
               echo $obinna;
           }
       }

     ?> 

我的问题是,每当我将新文本放入新窗体并单击提交以编辑一个字符旧的字符串提交行刷新页面,没有结果输出。请解释一下吗?

My problem is that whenever I put a new text in new form and click submit to edit a character in the old string submitted line the page refreshes and no result is output. Please can anybody sort this out?

推荐答案

//试试这个..

    if (isset($_POST["chedit"]))
       {
           $suj = $_POST["msg"];
           $text = $_POST["text"];
           $mumu =$_POST["edit"];
           if(isset($_POST["pch"]))
           {
               $change = $_POST["change"];   
                          //456 ,   //555(post value) , //(your text)12345678910
// $obinna = str_replace("Set old value you change in text","set new value you want to set in text ","your orignal text "); 
               $obinna = str_replace("$mumu","$change","$text"); 
               echo $obinna;
           }
       }
       echo '<form action="#" method="POST">
          Edit Number
          <input type="text" name="change" value="" placeholder="Change"/>
          <input type="text" name="edit" value="" placeholder="Edit"/>  
          <input type="submit" name="pch" value="Submit"/>
       </form>'

检查演示网址: - https://eval.in/931366

Check Demo Url :- https://eval.in/931366

这篇关于如何更改表单中提交的字符串行与另一个表单输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆