form radio buttons not inserting or retrieveing

[php]

Ticket Tracker <?php error_reporting(E_ALL); ini_set("display_errors", 1); // the rest of your script... if (mysql_connect('localhost', 'root', 'root') && mysql_select_db('tickets')) { $time = time(); $errors = array(); if (isset($_POST['ticket_name'], $_POST['ticket_email'], $_POST['ticket_message'], $_POST['ticket_priority'])) { $ticket_name = mysql_real_escape_string(htmlentities($_POST['ticket_name'])); $ticket_email = mysql_real_escape_string(htmlentities($_POST['ticket_email'])); $ticket_message = mysql_real_escape_string(htmlentities($_POST['ticket_message'])); $ticket_priority = mysql_real_escape_string(htmlentities($_POST['ticket_priority'])); if (empty($ticket_name) || empty($ticket_email) || empty($ticket_message)) { $errors[] = 'All fields required'; } if (strlen($ticket_name)>25 || strlen($ticket_email)>255 || strlen($ticket_message)>16000) { $errors[] = 'One or more fields exceed the character limit.'; } if (empty($errors)) { $insert = "INSERT INTO `entries` VALUES ('', '$time', '$ticket_name', '$ticket_email', '$ticket_message', '$ticket_priority')"; if (mysql_query($insert)) { header('Location: '.$_SERVER['PHP_SELF']); } else { $errors[] = 'Something went wrong. Please try again soon.'; } } else { foreach($errors as $error) { echo '

' .$error. '

'; } } } $entries = mysql_query("SELECT `timestamp`, `name`, `email`, `message`, `priority` FROM `entries` ORDER BY `timestamp` DESC"); if (mysql_num_rows($entries)==0) { echo 'No entries yet'; } else { while ($entries_row = mysql_fetch_assoc($entries)) { $entries_timestamp = date('D M Y @ h:i:s', $entries_row['timestamp']); $entries_name = $entries_row['name']; $entries_email = $entries_row['email']; $entries_message = $entries_row['message']; $entries_priority = $entries_row['priority']; echo '

Posted by '.$entries_name.' ('.$entries_email.') on '.$entries_timestamp.':
'.$entries_message. 'Priority:'.$entries_priority.'

'; } } } else { echo 'Could not connect at this time.'; } ?>

HCA Ticket Tracker

Create a new ticket:

all fields are required!

Name:


Email:
<input type="text" name="ticket_email" maxlength="255"


Enter Ticket Details:
Low
Medium
High


[/php]

Not entirely sure what’s going on atm, but i’ll look at it in more depth when i get home tonight. One major thing though - never, ever do this - if (mysql_connect(‘localhost’, ‘root’, ‘root’) && mysql_select_db(‘tickets’)) {. All your connect details should be in a seperate file and then included in your main file. If someone were to get a hold of this file, they’d be hog heaven. If you want do that check, then put it into a function and then return a variable.

in your error message for the insert, add mysql_error() in there to see what’s going on with it. Also, what data type are you using for $time? that could be what’s causing it to screw up, i always have problems with it. If its datetime or time, you can use NOW() instead of the $time variable right in the query.

Sponsor our Newsletter | Privacy Policy | Terms of Service