PHP从一种形式获取值到另一种形式

时间:2016-03-10 06:21:06

标签: javascript php html

loginform.php

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detaild_address);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    stub = (ViewStub) findViewById(R.id.layout_stub);
    stub.setLayoutResource(R.layout.content_detaild_address);
    View inflated = stub.inflate();

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    String check = "0";
    String chEck;
    DBHandler db = new DBHandler(DetaildAddress.this);
    List<DBconnector> Contacts = db.getAllContacts();
    for (DBconnector cn : Contacts) {
        chEck = cn.getActive();
        if(chEck != null){
            if (chEck.equals("1")){
                check = chEck;
            }
        }
    }
    if (check.equals("1")) {
        List<DBconnector> contacts = db.getActiveData();

        for (DBconnector c : contacts) {
            Customer_id = c.getCustomer_id();
            //new CheckAddress().execute();
            boolean connected = false;
            ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
            if(connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED ||
                    connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED) {
                //we are connected to a network
                new InfoAccountsascyn(DetaildAddress.this,url_address,Customer_id).execute();
            }
            else
            {
                Toast.makeText(DetaildAddress.this,"Internet Connection is not Available",Toast.LENGTH_LONG).show();
                Intent intent=new Intent(DetaildAddress.this,HomeActivity.class);
                startActivity(intent);
                connected = false;
            }

        }

    }
    else{
        Toast.makeText(DetaildAddress.this, "Please login First", Toast.LENGTH_LONG).show();
        Intent intent = new Intent(DetaildAddress.this, UserLogin.class);
        startActivity(intent);
    }
    gridView = (GridView) findViewById(R.id.gridView1);
    myLastVisiblePos = gridView.getFirstVisiblePosition();
    products = new ArrayList<DetailedAddressInfo>();
    //gridView.setAdapter(new DetailedAddressAdapter(DetaildAddress.this, R.layout.deshbord_address, products));

    TextView newaddress=(TextView)findViewById(R.id.newaddress);
    newaddress.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent=new Intent(DetaildAddress.this,NewAddress.class);
            String ok = "0";
            intent.putExtra("ok", ok);
            startActivity(intent);
        }
    });
}

newform.php

<form action="" method="post">
<font size="12px"><label><b>USER ID:</b></label><span id="tab6"></span>
<input type="text" name="t1"  title="Enter The Station Id" maxlength="5">

我希望在<input type="text" value="<?php $_POST["t1"]; ?>"> 中获取userid文本框的值,并在logingorm.php的文本框中显示内容 我添加了一些验证,所以我不想使用newform.php是否有任何其他方法可以将值从一种形式转换为另一种形式。

2 个答案:

答案 0 :(得分:0)

您必须提供表单操作: -

if ((contact.getShapeA()->getCategoryBitmask() & contact.getShapeB()->getCollisionBitmask()) == 0
    || (contact.getShapeB()->getCategoryBitmask() & contact.getShapeA()->getCollisionBitmask()) == 0)
{
    std::cout << "Overlap!" << std::endl;
}

在newform.php中你必须回显值

<form action="newform.php" method="post">
<font size="12px"><label><b>USER ID:</b></label><span id="tab6"></span>
<input type="text" name="t1"  title="Enter The Station Id" maxlength="5">
  

如果操作设置为“”,表单将提交给自己。也就是说,如果你的   script是index.php,你的表单提交到index.php。

相反,你可以使用jquery提交你的

<input type="text" value="<?php echo $_POST["t1"]; ?>">

再次使用javascript即可。

$("#form-id").submit()

答案 1 :(得分:0)

提交表单后,在loginform.php中编写以下代码..

session_start();
if (isset($_POST))
{
    $t1 = $_POST['t1'];
    $_SESSION['t1'] = $t1;
}

这里我设置了一个会话变量t1。然后我们可以在任何地方使用此会话变量我在newform.php中使用这个t1。

    session_start();
$t1 = '';
if (isset($_SESSION['t1']))
{
    $t1 = $_SESSION['t1'];
}
<input type="text" value="<?php echo $t1; ?>">
相关问题