Dysan Posted November 10, 2007 Share Posted November 10, 2007 How do i store data from three textboxs, as one field? e.g. If textbox 1 contains "one", textbox 2 contains "two", and textbox 3 contains "three", then the field should contain "onetwothree". <?php $sql="INSERT INTO Person (Firstname, Lastname, Sex) VALUES ('$_POST[Firstname]','$_POST[Lastname]','$_POST[sex]')"; if (!mysql_query($sql,$con)) { die(mysql_error()); } echo $_POST[Name] . "'s Record Added Successfully!"; mysql_close($con) ?> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 10, 2007 Share Posted November 10, 2007 <?php $var = $_POST['field1'].$_POST['field2'].$_POST['field3']; echo $var; ?> Give that a try. Quote Link to comment Share on other sites More sharing options...
kratsg Posted November 11, 2007 Share Posted November 11, 2007 add a mysql_real_escape_string($variable) for all user-inputs to keep yourself safe from sql injections. Quote Link to comment Share on other sites More sharing options...
AndyB Posted November 11, 2007 Share Posted November 11, 2007 It's hard to imagine any benefit to concatenating three pieces of different data into one variable. Seesm like you're just making trouble for yourself in the future when you decide you want to display data for a particular value, e.g. every record with the same sex or same first name. If you really must concatenate the data, I'd recommend adding a delimiter character between the individual values: then one|two|three can be split into its original components since you know where each value ends and the next begins ... but then you'll realise it would have been better not to concatenate them in the first place. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 11, 2007 Share Posted November 11, 2007 how was the north pole andy? Quote Link to comment Share on other sites More sharing options...
AndyB Posted November 11, 2007 Share Posted November 11, 2007 how was the north pole andy? fine - www.andybowers.com/alert Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.