Jump to content

Archived

This topic is now archived and is closed to further replies.

lucerias

Pass parameter from HTML form to PHP

Recommended Posts

I have created one parameter.html and parameter.php as the following, but i can't pass the parameter from html to php. I have gone through the code for many times and there is no spelling error.

parameter.html
<HTML>
<HEAD></HEAD>
<BODY>
<FORM METHOD=GET ACTION="parameter.php">
Who is your favourite author?
<INPUT NAME="Author" TYPE="TEXT">
<BR>
<BR>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>

parameter.php
<HTML>
<HEAD></HEAD>
<BODY>
Your favourite author is:
<?php
echo $Author;
?>
</BODY>
</HTML>


Share this post


Link to post
Share on other sites
First
You have method=get
You need some quotes round the get
method="get"

Second
You are using the GET method, therefor you need to call the var with that
<?php
echo $_GET["Author"];
?>

If you were using method='post'
then you show the function using
$_POST["Author"];

Share this post


Link to post
Share on other sites
Is there any way apart from this $_GET["Parameter"]? It is because i read a book and the example in book is done in this way: echo $Author. Thank you.

Share this post


Link to post
Share on other sites
[code]parameter.html
<HTML>
<HEAD></HEAD>
<BODY>
<FORM METHOD="post" ACTION="parameter.php">
Who is your favourite author?
<INPUT NAME="Author" TYPE="TEXT">
<BR>
<BR>
<INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>

parameter.php
<HTML>
<HEAD></HEAD>
<BODY>
Your favourite author is:
<?php
echo $Author;
?>
</BODY>
</HTML>
[/code]

Share this post


Link to post
Share on other sites
Sorry, is there any difference between the coding i provided and you posted later. I have already tried but it can't work. Thank you.

Share this post


Link to post
Share on other sites
Its to do with global register settings
In older versions of php, global_register used to be turned on, there for, you can call $_POST, $GET, $_SESSIONS by using the name
but this is now turned off, and I believe in V5 (maybe V6) You dont even have an option to turn it on

The reason being, is it opens you up to hack attempts
So the book your reading was probs created when using the older versions of PHP

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.