Page 1 of 1

(not) Passing data from HTML-form to PHP code

Posted: Wed Oct 16, 2002 2:36 pm
by soren
I want to pass username and password from an HTML-form to a .php page. However it isnt working.

I have a short HTML form:

<html>
<form action=checkpoint.php action=post>
Indtast dit brugernavn
<input type=text name=username>
<p>
Indtast kodeord
<input type=password name=password>
<p>
<input type=submit name=submit value=KLIK!>
</form>
</html>

and an even shorter PHP page:

<?php

echo ":".$username":";

exit;
?>

Not matter what I enter into the username filed of the form - it doesnt show up on the checkpoint.php page - however the two : (before and after username) does come out as expected.

I am running php 4.2.2-8.0.5 on Red Hat linux 8.0 with apache 2

Any ideas ???

:?: [/b]

Posted: Wed Oct 16, 2002 2:43 pm
by Heavy
Try substituting $username for $_POST['username']

I have at some time discovered that I had to name the form for correct function i.e.:

Code: Select all

<form name="Form1" action=checkpoint.php action=post>
But I do not remember if it was with ASP or PHP I had that problem.

small error

Posted: Wed Oct 16, 2002 2:47 pm
by phpScott
I'm not sure if this will fix the problem but where you have
echo ":".$username":";

you need to put a second . after $username
like so
echo ":".$username.":";

try that. It is probably what is causing it not to come through as expected

phpScott

Posted: Wed Oct 16, 2002 3:10 pm
by soren
Heavy wrote:Try substituting $username for $_POST['username']

I have at some time discovered that I had to name the form for correct function i.e.:

Code: Select all

<form name="Form1" action=checkpoint.php action=post>
But I do not remember if it was with ASP or PHP I had that problem.
I have already tried $HTTP_POST_VAR["username"] - no help !

I give the other suggestion a go ! - sorry didnt do the trick

Soren :(

Re: small error

Posted: Wed Oct 16, 2002 3:16 pm
by soren
phpScott wrote:I'm not sure if this will fix the problem but where you have
echo ":".$username":";

you need to put a second . after $username
like so
echo ":".$username.":";

try that. It is probably what is causing it not to come through as expected

phpScott
That was a typo - its okay in the actual script - so thats not the problem.

Re: (not) Passing data from HTML-form to PHP code

Posted: Wed Oct 16, 2002 3:34 pm
by rev
soren wrote: <form action=checkpoint.php action=post>
Wrong HTML syntax for a form submittal.

Valid form HTML below:

Code: Select all

<form name="formName" method="POST" action="submit.php">
</form>

PROBLEM SOLVED !

Posted: Wed Oct 16, 2002 3:39 pm
by soren
rev wrote:
soren wrote: <form action=checkpoint.php action=post>
Wrong HTML syntax for a form submittal.

Valid form HTML below:

Code: Select all

<form name="formName" method="POST" action="submit.php">
</form>
YES YES YES !!!

That did the trick .. :D

Posted: Thu Oct 17, 2002 2:33 am
by twigletmac
Good plan to read this as well:
viewtopic.php?t=511

Mac