By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,022 Members | 856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,022 IT Pros & Developers. It's quick & easy.

simple formm & $_POST

P: n/a
I have this form:

<form action="http://www.XXXXXXX.com/form.php" method="post"
name="form1" target="_blank" id="form1">
<label>Nome &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="<b>name</b>" type="text" maxlength="45" />
</label>
<p>
<label>Last
<input name="last name" type="text" dir="ltr" maxlength="45" />
</label>
</p>

now, i have made this php script just to echo the value in "name" and
"last" but it doesn't work:

<?php
print("$_POST['name']");
print("thanks, see you soon");
?>

what's the error?

May 29 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
vinnie kirjoitti:
I have this form:

<form action="http://www.XXXXXXX.com/form.php" method="post"
name="form1" target="_blank" id="form1">
<label>Nome &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="<b>name</b>" type="text" maxlength="45" />
Remove the <b></bfrom input name.
</label>
<p>
<label>Last
<input name="last name" type="text" dir="ltr" maxlength="45" />
</label>
</p>

now, i have made this php script just to echo the value in "name" and
"last" but it doesn't work:

<?php
print("$_POST['name']");
print("thanks, see you soon");
?>

what's the error?
You can test what was posted with
print_r($_POST);

It's often very helpful in debugging the input data.

--
Ra*********@gmail.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
May 29 '07 #2

P: n/a
En las nuevas, el vinnie escribió:
I have this form:

<form action="http://www.XXXXXXX.com/form.php" method="post"
name="form1" target="_blank" id="form1">
<label>Nome &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="<b>name</b>" type="text" maxlength="45" />
</label>
<p>
<label>Last
<input name="last name" type="text" dir="ltr" maxlength="45" />
</label>
</p>

now, i have made this php script just to echo the value in "name" and
"last" but it doesn't work:

<?php
print("$_POST['name']");
print("thanks, see you soon");
>>

what's the error?

<input name="<b>name</b>"

should be

<input name="name"
May 29 '07 #3

P: n/a
>
You can test what was posted with
print_r($_POST);

It's often very helpful in debugging the input data.

--
Rami.Elo...@gmail.com
i did, but this is what i get:
<<
Array(form1(name))
thanks, see you soon
>>
While i was expecting the name that the user has typed in. Is there
anything missing?

May 29 '07 #4

P: n/a
vinnie wrote:
>>
You can test what was posted with
print_r($_POST);

It's often very helpful in debugging the input data.

--
Rami.Elo...@gmail.com

i did, but this is what i get:
<<
Array(form1(name))
thanks, see you soon
>>>

While i was expecting the name that the user has typed in. Is there
anything missing?
Hi Vinnie

print_r need <pretags, like this:

echo "<pre>";
print_r($_POST);
echo "</pre>";

for output that you can actually read being human. :)

Regards,
Erwin Moller
May 29 '07 #5

P: n/a
vinnie wrote:
I have this form:

<form action="http://www.XXXXXXX.com/form.php" method="post"
name="form1" target="_blank" id="form1">
<label>Nome &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="<b>name</b>" type="text" maxlength="45" />
</label>
<p>
<label>Last
<input name="last name" type="text" dir="ltr" maxlength="45" />
</label>
</p>

now, i have made this php script just to echo the value in "name" and
"last" but it doesn't work:

<?php
print("$_POST['name']");
Besides the namingproblem (boldtags), another thing:
You use:
print("$_POST['name']");

Why do you use the "" around the $_POST["name"] ?
simply do:
echo $_POST['name'];

You said you are a novice. My advise would be NOT to use
variablesubstitution in strings untill you understand what is happening.

eg:
$name="vinnie";
echo "Your name is $name";

Works just fine, but it is excactly the same as:
echo "Your name is".$name;

The above example wasn't very tricky, but this one is worse:
$name[0]["firstname"] = "vinnie";
echo "Your name is $name[0]["firstname"]";

which will result in an error (because of the "" used as stringdelimmiter
and in the name-array.).

Easier is just to assemble your string using . as glue:
echo "Your name is ".$name[0]["firstname"];
Regards,
Erwin Moller
print("thanks, see you soon");
?>

what's the error?
May 29 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.