<?php
if (get_magic_quotes_gpc())
{
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process))
{
foreach ($val as $k => $v)
{
unset($process[$key][$k]);
if (is_array($v))
{
$process[$key][stripslashes($k)] = $v;
$process[] = &$process[$key][stripslashes($k)];
}
else
{
$process[$key][stripslashes($k)] = stripslashes($v);
}
}
}
unset($process);
}
if (isset($_GET['addform']))
{
include 'form.html.php';
exit();
}
try
{
$pdo = new PDO('mysql:host=localhost;dbname=chiorform', 'formuser', 'pass');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec('SET NAMES "utf8"');
}
catch (PDOException $e)
{
$error = 'unable to connect to database.';
include 'error.html.php';
exit();
}
if (isset($_POST['name'], $_POST['state']))
{
try
{
$sql = 'INSERT INTO form SET
name = :name,
state = :state';
$s = $pdo->prepare($sql);
$s->bindvalue(':name', $_POST['name']);
$s->bindvalue(':state', $_POST['state']);
$pdo->execute();
}
catch (PDOException $e)
{
$error = 'error adding submitted form: ' . $e->getMessage();
include 'error.html.php';
exit();
}
header('location: . ');
exit();
}
try
{
$sql = 'SELECT name, state FROM form';
$result = $pdo->query($sql);
}
catch (PDOException $e)
{
$error= 'error fetching form: ' . $e->getMessage();
include 'error.html.php';
exit();
}
while ($row = $result->fetch())
{
$names[] = $row['name'];
$names[] = $row['state'];
}
include 'jokes.html.php';
?>
Hi gidiboi, welcome to the forums,
Sorry, but I don’t understand what you’re asking.
Is it giving you error message(s)?
Not working as expected?
Works, but something you don’t understand?