Newbie here!!! Need help with the "$_post"???
Moderator: General Moderators
-
ibanezrg770
- Forum Newbie
- Posts: 4
- Joined: Tue May 20, 2003 9:05 pm
Newbie here!!! Need help with the "$_post"???
Hey guys, great site!!!
First let me say that I have read this post, http://www.devnetwork.net/forums/viewtopic.php?t=511
I will try and specify the jist of things... I am making a form that a person can type in information and then submit it and it will put it in a database. I am using
<form action="post_member.php" method="POST"> to do this.
My fields have the variable names 'nickname',' f_name',' l_name',' city', 'state', etc.... Here is an example:
printf('<input type="text" size="20" name="nickname" ><input type="text" size="20" name="F_Name" ><input type="text" size="20" name="L_Name" >
If I call the variables up using echo $_post['nickname'], it will display the variable for 'nickname'. But when I use the variable with the Insert command ie;
$sql = "INSERT INTO members (nickname) VALUES ($_POST['nickname'])";
I get Notice: Undefined variable: _post in D:\Web\Tim\gonzo\post_member.php on line 6
I know there is something stupid and easy I am missing, I just can't figure out what. Thanks for your help and again, sorry for the clutter.
Timmay!!!
First let me say that I have read this post, http://www.devnetwork.net/forums/viewtopic.php?t=511
I will try and specify the jist of things... I am making a form that a person can type in information and then submit it and it will put it in a database. I am using
<form action="post_member.php" method="POST"> to do this.
My fields have the variable names 'nickname',' f_name',' l_name',' city', 'state', etc.... Here is an example:
printf('<input type="text" size="20" name="nickname" ><input type="text" size="20" name="F_Name" ><input type="text" size="20" name="L_Name" >
If I call the variables up using echo $_post['nickname'], it will display the variable for 'nickname'. But when I use the variable with the Insert command ie;
$sql = "INSERT INTO members (nickname) VALUES ($_POST['nickname'])";
I get Notice: Undefined variable: _post in D:\Web\Tim\gonzo\post_member.php on line 6
I know there is something stupid and easy I am missing, I just can't figure out what. Thanks for your help and again, sorry for the clutter.
Timmay!!!
Last edited by ibanezrg770 on Wed May 21, 2003 7:47 am, edited 2 times in total.
- Wayne Herbert
- Forum Commoner
- Posts: 34
- Joined: Tue Apr 29, 2003 3:13 pm
- Location: Houston, Texas
That's a Gawd Awfull Mess!
You think you could tidy that code up a tad, then put it into php headers so we could see the gist of the problem? I get bored after about 8 lines of <color = "<span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>">.
try enclosing with single quotes. note that string values should be always enclosed with quotes. check the mysql manual for further reference.
e.g.:
Code: Select all
$_POSTї'nickname']e.g.:
Code: Select all
<?php
$sql="INSERT INTO tablename (fieldname1, fieldname2, ...) VALUES ('strvalue', numvalue, ...)";
?>-
ibanezrg770
- Forum Newbie
- Posts: 4
- Joined: Tue May 20, 2003 9:05 pm
Hey guys, thanks for the replys, I will try and specify the jist of things... I am making a form that a person can type in information and then submit it and it will put it in a database. I am using
<form action="post_member.php" method="POST"> to do this.
My fields have the variable names 'nickname',' f_name',' l_name',' city', 'state', etc.... Here is an example:
printf('<input type="text" size="20" name="nickname" ><input type="text" size="20" name="F_Name" ><input type="text" size="20" name="L_Name" >
If I call the variables up using echo $_post['nickname'], it will display the variable for 'nickname'. But when I use the variable with the Insert command ie;
$sql = "INSERT INTO members (nickname) VALUES ($_POST['nickname'])";
I get Notice: Undefined variable: _post in D:\Web\Tim\gonzo\post_member.php on line 6
I know there is something stupid and easy I am missing, I just can't figure out what. Thanks for your help and again, sorry for the clutter. Timmay!!!
<form action="post_member.php" method="POST"> to do this.
My fields have the variable names 'nickname',' f_name',' l_name',' city', 'state', etc.... Here is an example:
printf('<input type="text" size="20" name="nickname" ><input type="text" size="20" name="F_Name" ><input type="text" size="20" name="L_Name" >
If I call the variables up using echo $_post['nickname'], it will display the variable for 'nickname'. But when I use the variable with the Insert command ie;
$sql = "INSERT INTO members (nickname) VALUES ($_POST['nickname'])";
I get Notice: Undefined variable: _post in D:\Web\Tim\gonzo\post_member.php on line 6
I know there is something stupid and easy I am missing, I just can't figure out what. Thanks for your help and again, sorry for the clutter. Timmay!!!
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Instead of:
you can do
or
or
Mac
Code: Select all
$sql = "INSERT INTO members (nickname) VALUES ($_POST['nickname'])";Code: Select all
$sql = "INSERT INTO members (nickname) VALUES ('{$_POST['nickname']}')";or
Code: Select all
$sql = "INSERT INTO members (nickname) VALUES ('".$_POST['nickname']."')";Code: Select all
$sql = "INSERT INTO members (nickname) VALUES ('$_POST[nickname]')";-
ibanezrg770
- Forum Newbie
- Posts: 4
- Joined: Tue May 20, 2003 9:05 pm
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK