I created a form using Dreamweaver and am trying to figure out how to get the form contents saved to a database. Does anyone know of a way to to do this.

Dani AI

Generated

A concise, modern plan for : saving a Dreamweaver form to a database needs three pieces — a proper HTML form (method="post" and name attributes on each input), a server-side processor that validates/sanitizes and uses parameterized SQL, and a DB user with the right credentials and privileges. 's post points toward server-side code but used deprecated functions and lacked input checks; is right to request the form HTML for diagnosis; 's suggestion to study tutorials is sensible. The snippet below shows a safe, minimal PHP pattern using PDO and prepared statements.

<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $name  = trim($_POST['name'] ?? '');
    $email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);

    if ($name !== '' && $email !== false) {
        $dsn = 'mysql:host=localhost;dbname=your_db;charset=utf8mb4';
        $opts = [
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_EMULATE_PREPARES => false,
        ];
        $pdo = new PDO($dsn, 'dbuser', 'dbpass', $opts);

        $stmt = $pdo->prepare('INSERT INTO subscribers (name, email) VALUES (:name, :email)');
        $stmt->execute(['name' => $name, 'email' => $email]);

        header('Location: thank-you.html');
        exit;
    }
}
?>

Dreamweaver notes and troubleshooting: ensure the form tag uses method="post" and every input has a name attribute (missing names produce empty $_POST). Check the form action points to the processing script. Verify PHP has PDO/MySQL enabled (phpinfo), confirm DB credentials and user privileges, and set the connection charset to utf8mb4 to avoid encoding problems. If insertion fails, enable PDO exceptions during development, var_dump($_POST) to confirm submitted values, and inspect PHP error logs.

Security and final cautions: never trust raw input — validate and escape output with htmlspecialchars when showing values. Avoid the old mysql_* API; use PDO or mysqli prepared statements. Official references: PDO manual and filter_input.

Recommended Answers

All 3 Replies

<?php if isset() //validate data entered howver you require
 { { define ('MYSQL_SERVER', 'MYSQLHOST');
 define ('MYSQL_PASSWORD', 'MYSQLPASS' );
 define ('MYSQL_USERNAME', 'MYSQLUSER');
 define ('MYSQL_DB', 'MYSQLDB');
 if (!(@mysql_pconnect(MYSQL_SERVER, MYSQL_USERNAME, MYSQL_PASSWORD) and @mysql_select_db(MYSQL_DB)))
 die(sprintf("Cannot connect to database, error: %s", mysql_error()));
}
if (!mysql_query(sprintf("insert into MYSQLDB_table
		(data1, data2, data3, data4, data5, ) values ('%s', '%s', '%s', '%s', '%s', '%s');", $data1, $data2,
$data3, $data4, $data5,)))
	{ echo "error adding your geoip entry to database!<br>";
	echo mysql_errno().": ".mysql_error()."<BR>";
	return false;
	}
return true; }
?>
<form action='<?php echo $_server['PHP_SELF']; ?>'>
<!-- input form -->

if u can post ur forum's html i can post back the whole php code for it :)

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.