/    Sign up×
Community /Pin to ProfileBookmark

easy form doesnt work

hi,

i have this simple html code with php, and i want to receive the information from the form and print on the screen in index.php, but this form doenst return anything

Does anyone knows what’s the problem

Thanks in advance

<html>
<head>
<title>test</title>
<meta http-equiv=’Content-Type’ content=’text/html; charset=iso-8859-1′>

</head><body>

<?
include ‘funcs.php’;
calfunc($fname,$lname);
print “<br>NAME 1″.$fname.”<br>”;
print “<br>NAME 2″.$lname.”<br>”;
?>

</body>
</html>

file funcs=

<?
function calfunc($fname,$lname)
{
?>
<form action=”index.php” method=”post”>

First name:
<input type=”text” name=”fname” value=”Mickey” />
<br />
Last name:
<input type=”text” name=”lname” value=”Mouse” />
<br />
<input type=”submit” value=”Submit” />
</form>
<?
}

to post a comment
HTML

6 Comments(s)

Copy linkTweet thisAlerts:
@NogDogOct 01.2005 — Try changing this...
[code=php]
calfunc($fname,$lname);
[/code]

...to this...
[code=php]
calfunc($_POST['fname'], $_POST['lname']);
[/code]
Copy linkTweet thisAlerts:
@rincewind456Oct 01.2005 — Your form page needs to look something like this:

<html>

<head>

<title>test</title>

<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>

</head><body>

<form action="index.php" method="post">

First name:

<input type="text" name="fname" value="Mickey" />

<br />

Last name:

<input type="text" name="lname" value="Mouse" />

<br />

<input type="submit" value="Submit" />

</form>

</body>

</html>

and your index.php page needs to include this:

<?

print "<br>NAME 1 ".$_POST['fname'];"<br>";

print "<br>NAME 2 ".$_
POST['lname'];

?>

I dont understand what the func stuff is for!
Copy linkTweet thisAlerts:
@a10392authorOct 01.2005 — that works thanks,

its because in my office i just use the variable name, and i get confused thinking it was a HTML problem

What change do i have to do in php.ini to use the variable names instead $_POST['variable']



thanks
Copy linkTweet thisAlerts:
@rincewind456Oct 01.2005 — register globals, which is usualy set to off, as a security measure.
Copy linkTweet thisAlerts:
@NogDogOct 01.2005 — A quick work-around for scripts written that assume register_globals to be on is to insert this at the beginning of the script:
[code=php]
if(!ini_get("register_globals"))
{
if(isset($_POST) and count($_POST) > 0)
{
extract($_POST);
}
}
[/code]

(You can do the same thing with $_GET if you're using any GET data.)
Copy linkTweet thisAlerts:
@a10392authorOct 01.2005 — Works ?

thanks for your help

Regards ?
×

Success!

Help @a10392 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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