/    Sign up×
Community /Pin to ProfileBookmark

problems processing my forms

please take a look a the script and the document to see what i’m doing wrong its not outputting the right information

[code]<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<title>gt</title>
</head>
<body>
<form method=”post” action=”display_input.php”>
<p><strong>text field:</strong><br>
<textarea name=”text1″ cols=45 rows=5 wrap=virtual></textarea></p>
<P><strong>string function :</strong><br>
<input type=”radio” name=”func” value=”md5″> get md5<br>
<input type=”radio” name=”func” value=”strlen”> get length of string<br>
<input type=”radio” name=”func” value=”strrev”> reverse the string<br>
<input type=”radio” name=”func” value=”strtoupper”> make string uppercase<br>
<input type=”radio” name=”func” value=”strtolower”> make string lowercase<br>
<p><input type=”submit” name=”submit” value=”do sumhing”></p>

</body>
</html>[/code]
[code]
<?php
if(($_post[text1]==””)||($_post[func]==””))
{
header(“location:generic_form.html”);
exit;
}
$result= $_post[func]($_post[text1]);
?>
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<title>generic input results</title>
</head>
<body>
<?echo “$result”;?>
<P><a href=”generic_form.html”>go again!</a></p>
</body>
</html>[/code]

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@ChipzzzOct 23.2010 — Off the top of my head, I'd suggest something like this:

[code=php]
<?php
if(($_post[text1]=="")||($_post[func]==""))
{
header("location:generic_form.html");
exit;
}
$result= eval("$_post['func']($_post['text1'])");
?>
[/code]

<i>
</i>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
&lt;head&gt;
&lt;title&gt;generic input results&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?echo "$result";?&gt;
&lt;P&gt;&lt;a href="generic_form.html"&gt;go again!&lt;/a&gt;&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;


I haven't tried it but it should work. Good luck ?
Copy linkTweet thisAlerts:
@BelrickOct 23.2010 — Wheres your appostraphes?

i.e: $_post['func']
Copy linkTweet thisAlerts:
@ChipzzzOct 23.2010 — Whoops, I forgot half of them.

[code=php]
if(($_post['text1']=="")||($_post['func']==""))
[/code]


Thanks, Belrick ?
Copy linkTweet thisAlerts:
@BelrickOct 24.2010 — Glad to have helped
Copy linkTweet thisAlerts:
@kwadjo_okaiauthorOct 25.2010 — this is the error im getting when i modified that line of code


Parse error: parse error, expecting T_STRING' or T_VARIABLE' or `T_NUM_STRING' in C:wampwwwdisplay_input.php on line 7
Copy linkTweet thisAlerts:
@ChipzzzOct 25.2010 — I tidied up another few odds and ends. Try this:

<i>
</i>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
&lt;head&gt;
&lt;title&gt;gt&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form method="post" action="display_input.php"/&gt;
&lt;p&gt;&lt;strong&gt;text field:&lt;/strong&gt;&lt;/p&gt;&lt;br&gt;
&lt;textarea name="text1" cols=45 rows=5 wrap=virtual&gt;&lt;/textarea&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;string function :&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;
&lt;input type="radio" name="func" value="md5"/&gt; get md5&lt;br /&gt;
&lt;input type="radio" name="func" value="strlen"/&gt; get length of string&lt;br /&gt;
&lt;input type="radio" name="func" value="strrev"/&gt; reverse the string&lt;br /&gt;
&lt;input type="radio" name="func" value="strtoupper"/&gt; make string uppercase&lt;br /&gt;
&lt;input type="radio" name="func" value="strtolower"/&gt; make string lowercase&lt;br /&gt;
&lt;p&gt;&lt;input type="submit" name="submit" value="do sumhing"/&gt;&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;


[code=php]
<?php
if(($_POST['text1']=="")||($_POST['func']==""))
{
header("location:generic_form.html");
exit;
}
$result= $_POST['func']($_POST['text1']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>generic input results</title>
</head>
<body>
<?echo "$result";?>
<p><a href="generic_form.html">go again!</a></p>
</body>
</html>
[/code]


Have fun ?
×

Success!

Help @kwadjo_okai spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...