wml / xhtml form function

Started on the old forum in September 2010 · view the original in the archive · old links redirect here

1 reply · 1,868 views · started 16 years ago · 1 min read

2 participants
something else Fellow · 2,296 posts #1

Anyone got a better way to code a wml / xhtml form function to enable both wml and xhtml in 1 page dynamically? Heres my attempt:

function buildform($wml,$action,$method,$fields,$submit,$postfields){
if($wml){
$fields = preg_replace("/>(.*?)\</textarea>/is"," value=\"$1\"/>",$fields);
$fields = str_replace("textarea","input",$fields);
$fields = str_replace("selected=\"selected\"","",$fields);
$form = $fields;
$form .= "<anchor>$submit<go href=\"$action\" method=\"$method\">";
$form .= $postfields;
$form .= "</go></anchor>";
}else{
$form = "<form action=\"$action\" method=\"$method\">";
$form .= $fields;
$form .= "<input type=\"submit\" value=\"$submit\"/>";
$form .= "</form>";
}
}

usage:

echo buildform(TRUE,"something.php?else=yes","POST","<input name=\"test\" value=\"yes\"/>","Go","<postfield name=\"test\" value=\"$(test)\"/>");

or can anyone improve my code?

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close