Jump to content


Photo

INSERT & $_POST['NAME']


  • Please log in to reply
7 replies to this topic

#1 cK

cK
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 21 May 2003 - 02:27 PM

Offcourse this doesnt work; I know...


$query = "INSERT INTO application_form (something, email) VALUES (\'something\',\'$_POST[\'Email\']\')"; 


So how can I use $_POST[\'NAME\'] when inserting?

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 21 May 2003 - 02:47 PM

$email = $_POST[\'Email\'];
$query = \"INSERT INTO application_form (something, email) VALUES (\'something\',\'$email\')\";
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 cK

cK
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 21 May 2003 - 04:14 PM

I know ;-) But then I would need to define all vars; isn\'t there better solution?

#4 Avalanche

Avalanche
  • Members
  • PipPipPip
  • Advanced Member
  • 73 posts

Posted 21 May 2003 - 06:16 PM

I think you could do that with a for each thing, but I don\'t use for each myself.

Anyway, I believe what you had at first would work if you got rid of the apostrophes in your POST variables.

So, instead of $_POST[\'name\'] use $_POST[name]. See if that works.
DEFINE("YOU","Spending Too Much Time On The Computer");

#5 metalblend

metalblend
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCalifornia, USA

Posted 21 May 2003 - 06:30 PM

Actually it\'s much simpler than you think.. break from the string:
$query = "INSERT INTO application_form (something, email) VALUES (\'something\',\'".$_POST[\'Email\']."\')";

Hope that helps.

#6 wompus

wompus
  • Members
  • Pip
  • Newbie
  • 8 posts
  • LocationNY

Posted 21 May 2003 - 06:47 PM

Convert all your posted variables

<?php

foreach($_POST as $key => $item)

{

$key = $_POST[$key];

}

?>

$_POST[\'name\'] could then be used just as $name
Free the West Memphis 3 http://wm3.org

#7 Nairb

Nairb
  • Members
  • PipPip
  • Member
  • 18 posts
  • LocationCanada

Posted 21 May 2003 - 07:38 PM

Convert all your posted variables


<?php

foreach($_POST as $key => $item)

{

$key = $_POST[$key];

}

?>

$_POST[\'name\'] could then be used just as $name



OMG THANK YOU!!!!!!!

#8 cK

cK
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 22 May 2003 - 04:06 PM

metalblend thanks! I Forgot that PHP was so easy :D

wompus, that\'s easy. But how about?

$_POST[\'Name\'] and
$_POST[\'Two words\']

Because that\'s actually why I use [\'Name\'] and not [name]....




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users