Jump to content

Pass parameter from HTML form to PHP


lucerias

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>


Link to comment
https://forums.phpfreaks.com/topic/21133-pass-parameter-from-html-form-to-php/
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"];
[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]
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

Archived

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

×
×
  • Create New...

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.