Jump to content

Combining Data from form fields


petroz

Recommended Posts

Hi Guys,

 

Newb here and with php, sql and html... But I am trying.

 

I have a form that includes and address field. Each part of the address (IE. Street, City, State, etc..) is a separate field on the form. I would like to process all the fields of the address into one "address cell" on the mysql db.

 

So I guess I am looking to combine all the fields into

$address = $_POST['address'];

 

Any help would be greatly appreciated.

 

Thanks,

P

 

Link to comment
https://forums.phpfreaks.com/topic/173288-combining-data-from-form-fields/
Share on other sites

I cut out most of the countries, but here is everything related to address. Thanks!!

 

<li id="li_5"> <label class="description" for="element_5">Address </label>

<div> <input id="element_5_1" name="element_5_1" class="element text large" value="" type="text" />

<label for="element_5_1">Street Address</label>

</div>

<div> <input id="element_5_2" name="element_5_2" class="element text large" value="" type="text" />

<label for="element_5_2">Address Line 2</label>

</div>

<div class="left"> <input id="element_5_3" name="element_5_3" class="element text medium" value="" type="text" /> <label for="element_5_3">City</label>

</div>

<div class="right"> <input id="element_5_4" name="element_5_4" class="element text medium" value="" type="text" /> <label for="element_5_4">State

/ Province / Region</label> </div>

<div class="left"> <input id="element_5_5" name="element_5_5" class="element text medium" maxlength="15" value="" type="text" /> <label for="element_5_5">Postal / Zip Code</label> </div>

<div class="right">

<select class="element select medium" id="element_5_6" name="element_5_6"><option value="" selected="selected"></option><option value="Afghanistan">Afghanistan</option</select>

<label for="element_5_6">Country</label> </div>

</li>

name="element_5_1"

name="element_5_2"

name="element_5_3"

name="element_5_4"

name="element_5_5"

name="element_5_6"

 

These are the address form elements.

 

$address = $_POST['element_5_1']  . $_POST['element_5_2'] . $_POST['element_5_3'] . $_POST['element_5_4'] . $_POST['element_5_5'] . $_POST['element_5_6'];

Ok, so it should be working, but now I am getting "unexpected T_VARIABLE on line 10"

 

Please let me know where I have gone wrong.

 

Thanks,

P

 

<?PHP

 

include 'db.php';

 

$username = $_GET['user'];

$nickname = $_POST['element_1'];

$description = $_POST['element_7'];

$email = $_POST['element_4'];

$phone = $_POST['element_3_1'] . $_POST['element_3_2'] . $_POST['element_3_3'];

$address = $_POST['element_5_1'] . $_POST['element_5_2'] . $_POST['element_5_3'] . $_POST['element_5_4'] . $_POST['element_5_5'] . $_POST['element_5_6'];

$hours = $_POST['element_6'];

Archived

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

×
×
  • Create New...

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.