|
查看: 970|回复: 12
|
[已解决] php POST东西去第二面的问题
[复制链接]
|
|
|
<?php
echo"<input type='text' name='T2' size='11'> ";
echo"<input type='text' name='T1' size='77'></p>";
echo"<p> <input type='submit' value=' Add ' name='submit' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'> ";
echo"<input type='reset' value=' Reset ' name='B2' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'> ";
echo"<input type='submit' value=' Back ' name='submit' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'></p>";
if(isset($_POST["submit"]))
{
$submit = $_POST["submit"];
if($submit==" Add ")
{
print "<script language ='javascript'>window.location.href='AssociationAddProcess.php'</script>";
}
else if($submit==" Back ")
{
print "<script language ='javascript'>window.location.href='Association.php'</script>";
}
}
?>
我想问一下各位大大,如果我的add是想把那两个submit button ('T2'和'T1')post去第二面,该怎么打呢?
[ 本帖最后由 KIRA4 于 7-10-2009 11:45 PM 编辑 ] |
|
|
|
|
|
|
|
|
|
|
发表于 5-10-2009 07:43 AM
|
显示全部楼层
<?php
echo"<input type='text' name='T2' size='11'> ";
echo"<input type='text' name='T1' size='77'></p>";
echo"<p> <input type='submit' value=' Add ' name='submit' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'> ";
echo"<input type='reset' value=' Reset ' name='B2' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'> ";
echo"<input type='submit' value=' Back ' name='submit' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'></p>";
if(isset($_POST["submit"]))
{
$submit = $_POST["submit"];
$T1 = $_POST["T1"];
$T2= $_POST["T2"];
if($submit==" Add ")
{
print "<script language ='javascript'>window.location.href='AssociationAddProcess.php?T1=$T1&T2=$T2'</script>";
}
else if($submit==" Back ")
{
print "<script language ='javascript'>window.location.href='Association.php'</script>";
}
}
?> |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 5-10-2009 07:58 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 5-10-2009 10:33 PM
|
显示全部楼层
很乱。。。
懒惰看。。。
用form post过去不就好咯。。。。
back的那个可以用其他的方法来做 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 5-10-2009 10:37 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 6-10-2009 07:36 AM
|
显示全部楼层
associationaddprocess.php
---------------------------------------------------------------------------------------------------
$id = $_GET["T2"];
$an = $_GET["T1"];
echo $id;
echo $an;
----------------------------------------------------------------------------
看看有没有问题 |
|
|
|
|
|
|
|
|
|
|
发表于 6-10-2009 08:28 AM
|
显示全部楼层
如果一定要用POST
<?php
echo "<FORM METHOD=POST ACTION='AssociationAddProcess.php'>";
echo"<input type='text' name='T2' size='11'>";
echo"<input type='text' name='T1' size='77'></p>";
echo"<p> <input type='submit' value=' Add ' name='submit' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'>";
echo"<input type='reset' value=' Reset ' name='B2' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'>";
echo"<input type='submit' value=' Back ' name='submit' style='font-family: Times New Roman; color: #000000; font-weight: bold; font-size: 12pt'></p>";
echo "</FORM>";
?>
associationaddprocess.php
--------------------------------------------------------------------------------------
<?php
if(isset($_POST["submit"]))
{
$submit = $_POST["submit"];
$id = $_POST["T2"];
$an = $_POST["T1"];
if($submit==" Back ")
{
print "<script language ='javascript'>window.location.href='Association.php'</script>";
}
else if($submit==" Add ")
{
echo $id;
echo $an;
//continue your coding
}
}
?> |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 6-10-2009 11:26 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 6-10-2009 11:28 PM
|
显示全部楼层
另外我想问一下header("Location: http://www.php.net");是不是和print "<script language ='javascript'>window.location.href='Association.php'</script>";同一种功能?
如果我想连接到Association.php是不是只是打header("Location: Association.php");
可是我还是link不过去哦。。。这个function可以post去第二面的吗? |
|
|
|
|
|
|
|
|
|
|
发表于 7-10-2009 07:41 AM
|
显示全部楼层
原帖由 KIRA4 于 6-10-2009 11:28 PM 发表 
另外我想问一下header("Location: http://www.php.net");是不是和print "window.location.href='Association.php'";同一种功能?
如果我想连接到Association.php是不是只是打header("Location: Association.php");
...
header("Location: http://www.php.net"); 是PHP的funtion
print "window.location.href='Association.php'";是javascript的function
基本上都是link去下一页 |
|
|
|
|
|
|
|
|
|
|
发表于 7-10-2009 01:50 PM
|
显示全部楼层
把
$sql = "INSERT INTO association(Index, AssociationName) VALUES ('$id', '$an')";
换去
$sql = "INSERT INTO `association`(`Index`, `AssociationName`) VALUES ('$id', '$an')"; |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 7-10-2009 09:05 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 7-10-2009 11:44 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|