Page 1 of 1
My super newb question
Posted: Wed Oct 29, 2003 4:02 pm
by renaxgade
This is going to seem really stupid, but im stumped.
I have a form name form.html that looks like this:
<html>
<head>
<title>Form</title>
</head>
<body>
<form action="profile.php" method=post>
E-mail:
<br><input type="text" name="email">
<br>
Screen Name:
<br>
<input type="text" name="sm">
<br>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
and a php file called profile.php that looks like this:
<?php
echo "$email";
echo "$sm";
?>
But nothing happens when I enter stuff in the form, it gives me a blank page. Try it at
http://68.80.101.77/form.html
Thanks
Posted: Wed Oct 29, 2003 4:11 pm
by liljester
try this:
Code: Select all
<?php
echo "$_POST[email]<br>\n";
echo "$_POST[sm]<br>\n";
?>
Posted: Wed Oct 29, 2003 4:12 pm
by vigge89
test this then:
on profile.php:
Code: Select all
<?php
echo $_GET['email'];
echo $_GET['sm'];
?>
when u use GET, PHP save the form varibales and stuff in an array called $_GET[]
Posted: Wed Oct 29, 2003 4:14 pm
by liljester
his form is using the POST method (<form action="profile.php" method="post">)... $_GET will prolly be empty
Posted: Wed Oct 29, 2003 4:16 pm
by vigge89
liljester wrote:his form is using the POST method (<form action="profile.php" method="post">)... $_GET will prolly be empty
oops, forgot to mention that
ok, ill continue here:
form.html:
Code: Select all
<html>
<head>
<title>Form</title>
</head>
<body>
<form action="profile.php" method="get">
E-mail:
<br><input type="text" name="email">
<br>
Screen Name:
<br>
<input type="text" name="sm">
<br>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
And then on profile.php:
Code: Select all
<?php
echo $_GET['email'];
echo $_GET['sm'];
?>
If you're just going to to post some strings or numbers or something, use GET instead, POST is better when you're posting big strings, numbers and so on...
Posted: Wed Oct 29, 2003 7:08 pm
by McGruff
This sounds like a register globals issue, as mentioned above.
Btw it's best not to use "get" as a form method - "post" is slightly more secure.
Posted: Thu Oct 30, 2003 10:07 am
by vigge89
McGruff wrote:This sounds like a register globals issue, as mentioned above.
Btw it's best not to use "get" as a form method - "post" is slightly more secure.
nope, but when just submitting email and screen name, i don't think its needed to use POST, but that's renaxgade's choice
Posted: Thu Oct 30, 2003 1:40 pm
by d3ad1ysp0rk
if post is more secure, is there anything better about get?
Posted: Thu Oct 30, 2003 3:00 pm
by JayBird
you would want to use get if you have an online catalogue of products. Then people will be able to bookmark a specific product page because the query will be saved also.
Mark