为什么PHP会话变量不起作用?

时间:2016-06-07 16:50:24

标签: php session-variables

我正在尝试使用会话变量将变量的值从php文件传递到另一个变量,但它不起作用。第二个文件中的变量$ id_incidencia永远不会获得会话变量的值。谢谢!

file1.php

[HttpPost]
    public void SaveAccount(string accountId, string AccountName, string Address, string City, string State, string ZipCode, string PhoneNumber, string IsActive) 
    public PartialViewResult SaveAccount(FormCollection form)
    {
        string accountid = form["SaveAccount"].ToString();

        using (OdbcConnection _conn = new OdbcConnection("FILEDSN=c:\\datasources\\RxCard.dsn"))
        using (OdbcCommand cmd1 = new OdbcCommand())
        {
            cmd1.Connection = _conn;
            cmd1.CommandText = "{call web.SaveAccount(?,?,?,?,?,?,?,?)}";
            cmd1.Parameters.AddWithValue("@AccountID", accountId);
            cmd1.Parameters.AddWithValue("@AccountName", AccountName);
            cmd1.Parameters.AddWithValue("@Address", Address);
            cmd1.Parameters.AddWithValue("@City", City);
            cmd1.Parameters.AddWithValue("@State", State);
            cmd1.Parameters.AddWithValue("@ZipCode", ZipCode);
            cmd1.Parameters.AddWithValue("@PhoneNumber", PhoneNumber);
            cmd1.Parameters.AddWithValue("@IsActive", IsActive);  // need to handle conversion from string to boolean on stored proc

            cmd1.Parameters.AddWithValue("@AccountName", form["AccountName"].ToString());
            cmd1.Parameters.AddWithValue("@Address", form["Address"].ToString());
            cmd1.Parameters.AddWithValue("@City", form["City"].ToString());
            cmd1.Parameters.AddWithValue("@State", form["State"].ToString());
            cmd1.Parameters.AddWithValue("@ZipCode", form["ZipCode"].ToString());
            cmd1.Parameters.AddWithValue("@PhoneNumber", form["PhoneNumber"].ToString());
            cmd1.Parameters.AddWithValue("@IsActive", form["IsActive"].ToString());  // need to handle conversion from string to boolean on stored proc
            cmd1.CommandType = CommandType.StoredProcedure;
            _conn.Open();
            cmd1.ExecuteNonQuery();
            _conn.Close();
        }

file2.php

 @using (Html.BeginForm("SaveAccount", "RxCard", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
                <div id="Edit">
                    <label id="lblAccountName">Account Name</label>
                    <input style="margin: 5px; " type=text name="txtAccountName" id="txtAccountName" value="@Model.Pharmacy.AccountName" />
                    <label id="lblAddress">Address</label>
                    <input style="margin: 5px; " type=text name="txtAddress" id="txtAddress" value="@Model.Pharmacy.Address" />
                    <label id="lblCity">City</label>
                    <input style="margin: 5px; " type=text name="txtCity" id="txtCity" value="@Model.Pharmacy.City" />
                    <label id="lblState">State</label>
                    <input style="margin: 5px; " type=text name="txtState" id="txtState" value="@Model.Pharmacy.State" />
                    <label id="lblZip">Zip</label>
                    <input style="margin: 5px; " type=text name="txtZip" id="txtZip" value="@Model.Pharmacy.ZipCode" />
                    <label id="lblPhoneNumber">Phone Number</label>
                    <input style="margin: 5px; " type=text name="txtPhoneNumber" id="txtPhoneNumber" value="@Model.Pharmacy.PhoneNumber" />
                </div>

                <div id="Add">

                </div>

                <div id="ChkBox">
                    <input id="chkIsActive" style="margin: 5px; " type="checkbox" name="chkIsActive" onchange='Areyousure(this)' value="@Model.Pharmacy.IsActive" @(Model.Pharmacy.IsActive =="True" ? "checked=\"checked\"" : "") /> Is Active
                </div>

                <br/>
                <button type="submit" name="EditAccount" id="EditAccount" value="Edit">Edit</button>
                <button type="submit" name="SaveAccount" id="SaveAccount" value="@Model.Pharmacy.AccountID">Save</button>
               // <button type="submit" name="AddAccount" id="AddAccount" value="Add">Add</button>

                 }  

0 个答案:

没有答案
相关问题