if (!isset($_POST[´submit´])) not working… (2 replies)
Here’s my code:
<?php
session_start();
// is the one accessing this page logged in or not?
if (!isset($_SESSION[’basic_is_logged_in’])
|| $_SESSION[’basic_is_logged_in’] !== true) {
// not logged in, move to login page
header(’Location: index.php’);
exit;
}
$link = mysql_connect(’x',’x',’x');
if (!$link) {
die(’Could not connect: ‘ . mysql_error());
}
if (!isset($_POST[’submit’])) {
echo "
<html>
…etc…
<body>
<div align=center valign=top>
<form name=adder method=post action=preview.php ta get=preview>
…etc…
</form>
</div>
</body>
</html>
";
} else {
mysql_select_db(CTC_data);
if ($_POST[’report_name’] == NULL) {
$report_name = $_POST[’report_list’];
} else {
$report_name = $_POST[’report_name’];
}
if ($_POST[’section’] == NULL) {
$section = $_POST[’section_list’];
} else {
$section = $_POST[’section’];
}
$field_desc = $_POST[’field_desc’];
$input_name = $_POST[’input_name’];
$preset = $_POST[’preset’];
$field_type = $_POST[’field_type’];
$unit_type = $_POST[’unit_type’];
$required = (isset($_POST[’required’]) && $_POST[’required’] == ‘1′)? 1 : 0;
$add_preset = (isset($_POST[’add_preset’]) && $_POST[’add_preset’] == ‘1′)? 1 : 0;
$preset_name = $_POST[’preset_name’];
$query = "INSERT INTO reports VALUES (’$report_name’,'$section’,'$field_desc’,'$input_name’,'$preset’,'$field_type’,'$unit_type’,'$required’,'$add_preset’,'$preset_name’)";
mysql_query($query,$link) or die (’MYSQL error: ‘ . mysql_error());;
}
?>
Without "if (!isset($_POST[’submit’]))" it inserts blank values into the upon refresh, expectedly. I’ve looked all over the net for various examples on how to do this and I’m following everything I’ve seen and I can’t figure out why it isn’t working.
Help!
