【发布时间】:2011-09-10 03:18:31
【问题描述】:
我发布这个是为了寻求帮助,它可能对其他人有用。我不清楚如何做到这一点,或者是否有可能。帖子内容来自文本区域,我想将内容重新创建到隐藏字段中以发布到另一个页面。起初以为可以用 Ajax 完成,但不确定。
if(isset($_POST["submit"]))
{
$total = $_POST["textarea"];
if($total != "")
{
$pieces = explode("\n",$total);
$i=0;
foreach($pieces as $piece)
{
$pieces2 = $piece;
$piece3 = array_map('trim', explode(" ", $pieces2));
// gets the 1st offset in the array
if(strpos($piece3[0], 'http') !== FALSE)
{
$output .= '<input type="hidden" name="url['.$i.']" value="'.$piece3[0].'" />'."\r\n";
}
// no links in the textarea box then error message
}else{
$output .= "NO READABLE IMPORT<br>";
}
}
至于 html。此表单通过第 2 步发送到另一个页面。就像这样。
<form name="batch_import" action="addurls.php?step=2" method="post">
<textarea id="textarea" cols="100" rows="10"></textarea>
<?php echo $output; ?>
<input type="button" name="submit" value="Import" class="inputbutton" />
</form>
【问题讨论】:
标签: php javascript ajax curl