php转jsp

ttuurr 2008-09-02 12:31:05
《Bulletproof Ajax中文版》第5章 有个formlogic.php,但是我没学过php,有谁能把它转成jsp文件吗?谢谢了!
...全文
147 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ttuurr 2008-09-03
  • 打赏
  • 举报
回复
formlogic.php如下:

<?

$output = '';

$required = array('email','name','message');

$errors = array();

if (isset($_REQUEST['submit'])) {

foreach ($required as $field) {

if (empty($_REQUEST[$field])) {

$errors[$field] = 'this is required';

}
}

if (count($errors)<1) {

// Send an email

$output.= '<p class="feedback">';
$output.= 'Thank you for getting in touch';
$output.= '</p>';

echo $output;
return;

}
}

$output.= '
<form method="post" id="contactform" action="'.$_SERVER['PHP_SELF'].'">';

$fields = array(
'name' => 'text',
'email' => 'text',
'message' => 'textarea'
);

foreach ($fields as $field => $type) {

$output.= '
<p>';
$output.= '
<label for="'.$field.'">';
$output.= ucwords($field);
if (isset($errors[$field])) {
$output.= ' <strong class="error">is required</strong>';
}
$output.= '</label>';

switch ($type) {

case 'textarea':
$output.= '
<textarea name="'.$field.'" id="'.$field.'" cols="30" rows="10">';
if (isset($_REQUEST[$field])) {
$output.= htmlspecialchars($_REQUEST[$field]);
}
$output.= '
</textarea>';
break;

default:
$output.= '
<input type="text" name="'.$field.'" id="'.$field.'"';
if (isset($_REQUEST[$field])) {
$output.= ' value="'.htmlspecialchars($_REQUEST[$field]).'"';
}
$output.= ' />';
break;

}

$output.= '
</p>';

}

$output.= '
<p>
<input type="submit" name="submit" value="Submit" />
</p>
</form>
';

echo $output;

?>
wangzi6hao 2008-09-03
  • 打赏
  • 举报
回复
不虽然勉强可以读下去,但是太不习惯了.
头大,你还是到php社区去,让那边的仁兄帮你注释一下吧.
iwlk 2008-09-03
  • 打赏
  • 举报
回复
php 的语法,太差劲了...

怎么看也不习惯.... 呵呵
gavin1234 2008-09-02
  • 打赏
  • 举报
回复
什么都没有,怎么帮你转
zhanggc1001 2008-09-02
  • 打赏
  • 举报
回复
贴代码
《Bulletproof Ajax中文版》没看过

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧