Skip to content

Instantly share code, notes, and snippets.

@good-orbit
Created June 30, 2011 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save good-orbit/0710ed4d975fc11d4214 to your computer and use it in GitHub Desktop.
Save good-orbit/0710ed4d975fc11d4214 to your computer and use it in GitHub Desktop.
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/includes/system/init.php');
enforce_auth();
$ProfileBreadcrumbs= "/ Ask A Question";
$ProfileIcon = "questions";
if(isset($_POST['subAskQuestion'])) {
$valid = true;
if($_POST['category'] == "null") {
$valid = false;
$error_msgs[] = "Whoops! Please select a category for your question.";
}
if($valid) {
$query = "INSERT INTO `cysticQuestions` (
`title`,
`body`,
`date`,
`time`,
`userID`,
`category`
) VALUES (
'" . mysql_real_escape_string($_POST['title']) ."',
'" . mysql_real_escape_string($_POST['body']) ."',
'" . date("Y-m-d") ."',
'" . date("G:i:s") ."',
'" . $auth->id ."',
'" . mysql_real_escape_string($_POST['category']) ."')";
mysql_query($query, $connection) or die (mysql_error());
header("Location: Questions.php");
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="javascripts/jquery/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="javascripts/jquery/jquery.corners.min.js"></script>
<script type="text/javascript" src="plugins/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="javascripts/system/config.js"></script>
<title>Ask A Question</title>
<link type="text/css" rel="stylesheet" media="screen" href="http://www.cysticlife.org/styles/cysticStyles.css" />
<link type="text/css" rel="stylesheet" media="screen" href="http://www.cysticlife.org/styles/global.css" />
<link type="text/css" rel="stylesheet" media="screen" href="http://www.cysticlife.org/styles/dashboard.css" />
<link type="text/css" rel="stylesheet" media="screen" href="http://www.cysticlife.org/styles/profile.css" />
<link type="text/css" rel="stylesheet" media="screen" href="http://www.cysticlife.org/styles/NewCysticStyles.css" />
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "emotions",
// Theme options
theme_advanced_buttons1 : "bold,italic,underline,|,link,unlink,emotions,|,bullist,|,numlist,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_resizing : false,
});
</script>
</head>
<body class="new">
<?php require_once('includes/structural/masthead.php'); ?>
<div id="page_content_new" class="clearfix">
<div class="container clearfix">
<?php require_once('includes/structural/new_edit_prof_header.php'); ?>
<div id="ComposeLeft">
<?php require_once('includes/structural/future_idCard_edit.php'); ?>
</div>
<div id="ComposeRight">
<div id="ComposeTable_future">
<?php
if(isset($_POST['subAskQuestion']) && !$valid) {
foreach($error_msgs as $msg) { ?>
<div class="error">
<?php echo $msg; ?>
</div>
<?php }
} ?>
<form name="enterInfo" action="AskQuestion.php" method="post">
<table>
<tr>
<td class="ComposeTitle">
Title
</td>
<td class="ComposeTitleBox">
<input type="text" name="title" class="text" value="<?php echo $_POST['title']; ?>" />
</td>
</tr>
<tr>
<td class="ComposeTitle" style="text-align:right;">
Ask
</td>
<td class="ComposeTitleBox">
<textarea name="body"><?php echo $_POST['body']; ?></textarea>
</td>
</tr>
<tr>
<td>
</td>
<td class="ComposeTitleBox">
<select name="category">
<option value="null">Choose Category</option>
<?php
$query = "SELECT * FROM `cysticCategories_questions` ORDER BY `CategoryName` ASC";
$request = mysql_query($query,$connection);
while($result = mysql_fetch_array($request)) {
echo "<option value='" . $result['id'] . "'>" . $result['CategoryName'] . "</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td>
</td>
<td id="composeSub">
<input style="margin:0px 0px 0px 0px;" class="submit" type="submit" name="subAskQuestion" value="Submit" />
</td>
</tr>
</table>
</form>
</div>
</div>
<div style="clear:both;"></div>
</div>
</div>
<?php require_once('includes/structural/site_map_social.php'); ?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment