Hi.. i have 4 combolist (combobox).
for action i want just one submit button.
how to make it on action

Dani AI

Generated

For (and confirming : yes, this is a PHP task) — give each combobox a distinct name and a default empty option, then handle which selects are non-empty in your PHP handler. You can either save all non-empty selections, or pick one (for example the first non-empty or a priority order). Sanitize and validate each value, use prepared statements for DB writes, and use header() + exit to redirect (make sure there is no output before the header).

Example HTML (four comboboxes, one submit):

<form method="post" action="save.php">
<select name="combo1">
<option value="">-- choose --</option>
<option value="1">Item 1</option>
</select>

<select name="combo2">
<option value="">-- choose --</option>
<option value="2">Item 2</option>
</select>

<select name="combo3">
<option value="">-- choose --</option>
<option value="3">Item 3</option>
</select>

<select name="combo4">
<option value="">-- choose --</option>
<option value="4">Item 4</option>
</select>

<button type="submit">Submit</button>
</form>

Minimal PHP handler (pick first non-empty, validate as integer, insert, redirect):

<?php
if ($_SERVER['REQUEST_METHOD'] !== 'POST') exit;

$selected = null;
for ($i = 1; $i <= 4; $i++) {
$key = 'combo' . $i;
if (!empty($_POST[$key])) {
$val = filter_var($_POST[$key], FILTER_VALIDATE_INT);
if ($val !== false) { $selected = $val; break; }
}
}

if ($selected === null) { exit('No selection made.'); }

$pdo = new PDO('mysql:host=localhost;dbname=yourdb', 'user', 'pass', [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
$stmt = $pdo->prepare('INSERT INTO selections (item_id, created_at) VALUES (:id, NOW())');
$stmt->execute([':id' => $selected]);

header('Location: details.php?id=' . urlencode($selected));
exit;
?>

Quick tips: validate against an allow-list or the DB before inserting, protect the form with a CSRF token, handle multiple selections by using name="combo[]" or loop through all non-empty values, and always avoid sending any output before header() redirects.

Recommended Answers

All 2 Replies

Member Avatar for Member #120589

What are you on about? Is this a php question?

yes this is php question, can you help me ?
after choose or select on more combobox, there is a submit button on the form and is saves information to my database and redirects me to another page in my site about information item selected....Yes for action i want just one submit button. how to make it on php ? do you have idea ? thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.