Jump to content


Photo

Pass parameter from HTML form to PHP


  • Please log in to reply
6 replies to this topic

#1 lucerias

lucerias
  • Members
  • PipPipPip
  • Advanced Member
  • 101 posts

Posted 18 September 2006 - 08:06 AM

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>




#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 18 September 2006 - 08:14 AM

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"];
Tell me the problem, I will try tell you the solution

#3 lucerias

lucerias
  • Members
  • PipPipPip
  • Advanced Member
  • 101 posts

Posted 19 September 2006 - 01:00 AM

Thanks, it works. What if i want to display the parameter together with a string?

#4 lucerias

lucerias
  • Members
  • PipPipPip
  • Advanced Member
  • 101 posts

Posted 19 September 2006 - 01:33 AM

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.


#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 19 September 2006 - 04:39 AM

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>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 lucerias

lucerias
  • Members
  • PipPipPip
  • Advanced Member
  • 101 posts

Posted 19 September 2006 - 08:27 AM

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.

#7 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 19 September 2006 - 10:25 AM

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
Tell me the problem, I will try tell you the solution




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users