HTML没有传递给PHP

时间:2014-09-09 07:21:10

标签: php html post

我不知道为什么表单没有将任何信息传递给PHP函数页面。

HTML:

<form action="function.php" method="post">
<input type="text" name="userid" class="textbox" data-placeholder="yes" value="Enter Your User ID Here" onfocus=" if (this.value == 'Enter Your User ID Here') { this.value = ''; }" onblur="if (this.value == '') { this.value='Enter Your User ID Here';} " /><br /><br />


<input type="text" name="webid" class="textbox" data-placeholder="yes" value="Enter Your Webform ID Here" onfocus=" if (this.value == 'Enter Your Webform ID Here') { this.value = ''; }" onblur="if (this.value == '') { this.value='Enter Your Webform ID Here';} " /><br /><br />

<input type="submit" name="submit" class="btn" value="Generate"  />

function.php:

<?php
$wid = $_POST['webid'];
$uid = $_POST['userid'];
if(isset($_POST['submit']))

if(isset($_POST['userid']) && isset($_POST['webid']))){

echo " You've done a successful job"
$link = "http://www.something.com".$uid."url&=".$wid;
echo $link;

}
?>

我一直在

http:www.something.comurl&=

2 个答案:

答案 0 :(得分:0)

你的表格:

<form action="function.php" method="post">

    <input type="text" name="userid" class="textbox" data-placeholder="yes" value="Enter Your User ID Here" onfocus=" if (this.value == 'Enter Your User ID Here') { this.value = ''; }" onblur="if (this.value == '') { this.value='Enter Your User ID Here';} " /><br /><br />


    <input type="text" name="webid" class="textbox" data-placeholder="yes" value="Enter Your Webform ID Here" onfocus=" if (this.value == 'Enter Your Webform ID Here') { this.value = ''; }" onblur="if (this.value == '') { this.value='Enter Your Webform ID Here';} " /><br /><br />

    <input type="submit" name="submit" class="btn" value="Generate"  />
    </form>

function.php:

<?php
$wid = $_POST['webid'];
$uid = $_POST['userid'];
if(isset($_POST['submit']))

if(isset($_POST['userid']) && isset($_POST['webid'])){

echo " You've done a successful job";
$link = "http://www.something.com".$uid."url&=".$wid;
echo $link;

}
?>

答案 1 :(得分:0)

您的代码存在一些问题。

中缺少分号
echo " You've done a successful job"
                                    ^ right there

然后一个括号太多了

if(isset($_POST['userid']) && isset($_POST['webid']))){
                                                     ^ right there

会产生解析错误。

然后这个:

$link = "http://www.something.com".$uid."url&=".$wid;

/

之后应该有.com
$link = "http://www.something.com/".$uid."url&=".$wid;

另外,适当的支撑技术将有助于分离条件语句:

$wid = $_POST['webid'];
$uid = $_POST['userid'];
if(isset($_POST['submit'])){

if(isset($_POST['userid']) && isset($_POST['webid'])){

echo " You've done a successful job";
echo " - ";
$link = "http://www.something.com/".$uid."url&=".$wid;
echo $link;

    }

} // closing brace for if(isset($_POST['submit']))

另外,从技术上讲,你错过了一个结束</form>标签。

此测试的最终结果是:

You've done a successful job - http://www.something.com/1url&=test

在表单元素输入中使用1test