0

我有一个不能正常工作的代码我想什么时候user's select country from drop down select list?表单提交后,值应该存储到courier array?

例如

如果用户选择了美国,那么美国应该与abc courier array values如果值相互匹配,那么$_SESSION['country1']=$abc;将被创建?

塞诺里奥

我有两家不同的快递公司,我想根据快递公司将国家列表传递到另一个页面?

索引页

<?php
session_start();
if(isset($_REQUEST['test']))
{
$newcountry=$_POST['country'];  

//Let's Assume Courier Companies Is Abc
$abc=array($newcountry=>'Usa',$newcountry=>'Uk');

//Let's Assume Another Courier Companies Is Xyz
$xyz=array($newcountry=>'Singapore',$newcountry=>'Germany');

$_SESSION['country1']=$abc;
$_SESSION['country2']=$xyz;

if(isset($_SESSION['country1']) && isset($_SESSION['country2'])){
header('Location:test.php'); 
}}
?>

<form method="post">
<select name="country" id="country">
<option value="Usa">Usa</option>
<option value="Uk">Uk</option>
<option value="Germany">Germany</option>
<option value="Singapore">Singapore</option>
<input type="submit" name="test" value="Submit" />

</select>
</form>

测试.php

session_start();
echo $country2=implode($_SESSION['country1']);
4

1 回答 1

0
$newcountry=$_POST['country'];  

//Let's Assume Courier Companies Is Abc
$abc=array($newcountry=>'Usa',$newcountry=>'Uk');

//Let's Assume Another Courier Companies Is Xyz
$xyz=array($newcountry=>'Singapore',$newcountry=>'Germany');

您对 $abc 和 $xyz 的数组分配会产生一个元素。如果选择“Usa”,则 $abc = array("Usa" => "Uk") 和 $xyz = array("Usa" => "Germany") 因为 $newcountry 的值是相同的,并且后一个值重置正式的价值。

于 2013-05-20T20:27:01.067 回答