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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
soren
Forum Newbie
Posts: 14
Joined: Wed Oct 16, 2002 2:36 pm
Location: Denmark

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

Post 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]
User avatar
Heavy
Forum Contributor
Posts: 478
Joined: Sun Sep 22, 2002 7:36 am
Location: Viksjöfors, Hälsingland, Sweden
Contact:

Post 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.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

small error

Post 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
User avatar
soren
Forum Newbie
Posts: 14
Joined: Wed Oct 16, 2002 2:36 pm
Location: Denmark

Post 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 :(
Last edited by soren on Wed Oct 16, 2002 3:30 pm, edited 1 time in total.
User avatar
soren
Forum Newbie
Posts: 14
Joined: Wed Oct 16, 2002 2:36 pm
Location: Denmark

Re: small error

Post 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.
rev
Forum Commoner
Posts: 52
Joined: Wed Oct 02, 2002 3:58 pm
Location: Atlanta, GA

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

Post 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>
User avatar
soren
Forum Newbie
Posts: 14
Joined: Wed Oct 16, 2002 2:36 pm
Location: Denmark

PROBLEM SOLVED !

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Good plan to read this as well:
viewtopic.php?t=511

Mac
Post Reply