Willard
Willard

Reputation: 89

2 Text field inputs into 1 record

How can i link this 2 input field basically 3 inputs into 1 record in database using php mysql

<form name="addtrucks" id="addtrucks" method="POST" action="<?php echo $editFormAction; ?>">
            <label>Truck Plate Number:</label>
            <input type="text" name="truck_plate_no" id="truck_plate_no"/>
            <br/>
            <input name="button" type="submit" id="button" onclick="MM_validateForm('truck_plate_no','','R');return document.MM_returnValue"/>
            <input type="hidden" name="MM_insert" value="add" />
</form>

With this form the user has to type a plate number like this ABC-123 i want to create 2 input fields and 1 for ABC and another one for "-" and then finally another input field for 123 and it will insert into the database like ABC-123

Upvotes: 0

Views: 58

Answers (1)

HTTP
HTTP

Reputation: 1724

Use the dot (.) to concatenate variables like

$abc = $_POST('abc');
$das = $_POST('das');
$num = $_POST('123');

//this is what you would concatenate
$concat = $abc . $das . $num;
//to check just echo 
echo $concat;

query

INSERT INTO tablename(fieldname) VALUES('$concat');

Upvotes: 1

Related Questions