Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

new user php problem

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

new user php problem

Postby li » Wed Oct 30, 2002 5:49 am

Hi,

I am new in PHP and I have a problem. if I use the following HTML form file:

<HTML>
<HEAD>
<TITLE>A simple form</TITLE>
</HEAD>
<BODY>
<FORM method="POST" action="1.php">
<INPUT type="submit" name="mybutton" value="Click me!">
</FORM>
</BODY>
</HTML>

Which create a button and then call the php file describe below:
<HTML>
<HEAD>
<TITLE>Doing something with the form</TITLE>
</HEAD>
<BODY>
<?
if(isset($_POST['mybutton'])) {
echo "Great! You clicked the button!\n";
} else {
echo "Hmm...you must have come to this script without clicking the button.\n";
}
?>
</BODY>
</HTML>

I get a button but when I click it I click the button I get the msg “Hmm...you must have come to this script without clicking the button.”

I do not know why is it like that can any one explan please why I can not get the proper output “Great! You clicked the button”

Thx.
li
New php-forum User
New php-forum User
 
Posts: 3
Joined: Wed Oct 30, 2002 5:28 am

Postby DoppyNL » Wed Oct 30, 2002 6:14 am

try doing this:
Code: Select all
printr($_POST);

and you will get all values that where posted.

If you got an older version of PHP you will need to use $HTTP_POST_VARS instead of $_POST.

Greetz Daan
DoppyNL
 

Postby Jay » Wed Oct 30, 2002 9:14 am

DoppyNL wrote:try doing this:
Code: Select all
printr($_POST);

and you will get all values that where posted.

If you got an older version of PHP you will need to use $HTTP_POST_VARS instead of $_POST.

Greetz Daan

The function is print_r($_POST) btw ;)
Jay
 

Postby DoppyNL » Wed Oct 30, 2002 10:00 am

Jay wrote:The function is print_r($_POST) btw ;)

ehh, sorry, my mistake.
probably because I don't use that one, I use a function of my own (with I different layout)

Greetz Daan
DoppyNL
 

Postby Jay » Wed Oct 30, 2002 12:35 pm

DoppyNL wrote:
Jay wrote:The function is print_r($_POST) btw ;)

ehh, sorry, my mistake.
probably because I don't use that one, I use a function of my own (with I different layout)

Greetz Daan

How different, I find print_r() to be quite useful when I'm stuck on a problem concerning arrays. Problem is you have to look at the source code, unless you use <pre> tags before and after.
Jay
 

Postby li » Wed Oct 30, 2002 11:21 pm

Still does not want to work.
li
New php-forum User
New php-forum User
 
Posts: 3
Joined: Wed Oct 30, 2002 5:28 am

Postby DoppyNL » Thu Oct 31, 2002 12:03 am

What version of PHP are you running?

Have you tried $HTTP_POST_VARS['mybutton'] ?
or simply $mybutton ?

Greetz Daan
DoppyNL
 

Postby li » Thu Oct 31, 2002 1:52 am

I am using the latest version (php4.2.3).
li
New php-forum User
New php-forum User
 
Posts: 3
Joined: Wed Oct 30, 2002 5:28 am

Postby Jay » Thu Oct 31, 2002 2:03 am

Try using GET variables and access the page directly by appending the variables on the end of your URL. Then you'll know if the server is passing the variables on.
Jay
 


Return to PHP coding => General

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron