/    Sign up×
Community /Pin to ProfileBookmark

$_Get Function Error

<form name=”getfunction” action=”testget.php”>
<input type=”text” name=q value=”<?php echo $_GET[‘q’]?>”/>
<input type=”submit” value=”submit”/>
</form>

I can’t type [B][/B]test page[B][/B] . It will only show [B][/B] . How to make to show [B]“test page”[/B]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@so_is_thisNov 14.2006 — Specify [B]method="get"[/B] or [B]method="post"[/B] in your FORM tag. Then, depending on what you specify, use one of these:

value="<?php echo $_GET['q']; ?>"

value="<?php echo $_POST['q']; ?>"
Copy linkTweet thisAlerts:
@iotaNov 14.2006 — Do you want test.php to show your get-submitted data?

If so, in your test.php, write :

[code=php]

<?=isset($_GET['q'])?$_GET['q']:'';?>
<form name="get" action="test.php">
<input type="text" name=q value=""/>
<input type="submit" value="submit"/>
</form>

[/code]
Copy linkTweet thisAlerts:
@saturngodauthorNov 14.2006 — Not work. I change a code for test
[code=php]<?php
if (isset($_GET['q']))
{ $g=$_GET['q'];
$g= stripslashes($g);
echo $g;
}
else
$g="";

?>
<form method="get" name="getfunction" action="testget.php">
<input type="text" name=q value="<?php echo $g; ?>"/>
<input type="submit" value="submit"/>
</form>[/code]


It show in web page (eg:[B]"test page"[/B]) but not show in input box.How to show in input box to display with [B]" "[/B]. It need for me because I use search box for my website.
Copy linkTweet thisAlerts:
@jignesh1Nov 14.2006 — [code=php]<?php
if(isset($_GET['q'])){
$g = $_GET['q'];
$g = stripslashes($g);
$g = "&quot;$g&quot;";
}else{
$g = "";
}
?>
<form method="get" name="getfunction" action="testget.php">
<input type="text" name="q" value="<?php echo $g; ?>" />
<input type="submit" value="submit" />
</form>[/code]

this script will show the text inputed in the text box with the quotation around the search word
Copy linkTweet thisAlerts:
@saturngodauthorNov 15.2006 — Thank all

I have it.
[code=php]<?php
if (isset($_GET['q']))
{ $g=stripslashes(str_replace('"','&quot;',$_GET['q']));
echo $g;
}
else
$g="";

?>
<form method="get" name="getfunction" action="testget.php">
<input type="text" name=q value="<?php echo $g ?>"/>
<input type="submit" value="submit"/>
</form>[/code]
×

Success!

Help @saturngod 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.3,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...