Jump to content

Archived

This topic is now archived and is closed to further replies.

cK

INSERT & $_POST['NAME']

Recommended Posts

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?

Share this post


Link to post
Share on other sites

$email = $_POST[\'Email\'];

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Convert all your posted variables


<?php

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

{

$key = $_POST[$key];

}

?> 

 

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

Share this post


Link to post
Share on other sites
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!!!!!!!

Share this post


Link to post
Share on other sites

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]....

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.