Like the title says, I'm building essentially a testing site that has a login and password to enter. They are stored in a DB and that's swell. What I need to do now is to have the answers to the questions passed through to the MySql, but I can't seem to find the right resource to teach me how.
Below is the code. In my DB that I want it to pass through has the following fields:
db name: dbaudit
(ID
, username
, Q
, value
, comment
)
The ID is Auto increment and Primary, the username is passed through to this page from the login. Q would be Q1 or Q1a (Question 1) or a combination of the two like Q2 & Q2a (from the second question). The value would of course be the numbers in the value area and then the comment would pass the text form the comment boxes.
This is the test page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://ift.tt/pWm1pE">
<html xmlns="http://ift.tt/lH0Osb">
<?php session_start() ?>
<head>
<link rel="stylesheet" type="text/css" href="css/mystyle.css">
<title>Audit test</title>
<style>
@import url(http://ift.tt/1unfZcG);
@import url(http://ift.tt/1fvKuRz? family=Source+Sans+Pro:700,400,300);
</style>
</head>
<div class="header1">
<div> generic name <span> <br> Title 1 <br> Title 2</span></div>
</div>
<br>
<div id="pageWrap" class="pageWrap"> </div>
<div class="pageContent"></div>
<ul class="accordion">
<!-- Header with one question drop down beginning -->
<li>
<a href="#S1S5.1 Header">Section 1</a>
<ul>
<li>
<a href="#S1S5.1Q1">5.1</a>
<div><span>
This is question 1<P>
<form METHOD ="POST">
<input type="checkbox" id=Check[1] name="Q1" value="10"> Answer 1 <br>
<input type="checkbox" id=Check[1] name="Q1a" value="0"> Answer 2 <br>
<form><p><br><b> Secondary information goes here</b><br><br><br>
Comments:<P>
<textarea rows="10" cols="55" name="comment" id="comment1 placeholder="Comment"></textarea><br>
</form>
</span></div>
</li>
</ul>
</li>
<!-- End -->
<li>
<a href="#S1S5.2 Header">Section 2</a>
<ul>
<li>
<a href="#S1S5.2Q1">5.2</a>
<div><span>
This is question 2<P>
<form METHOD ="POST">
<input type="checkbox" id=Check[2] name="Q2" value="10"> Answer 1 <br>
<input type="checkbox" id=Check[2] name="Q2a" value="15"> Answer 2 <br>
<input type="checkbox" id=Check[2] name="Q2b" value="0"> Answer 3 <br>
<form><p><br><b>Secondary information goes here.</b><br><br><br>
Comments:<P>
<textarea rows="10" cols="55" name="comment" id="comment2 placeholder="Comment"></textarea><br>
</form>
</span></div>
</li>
</ul>
</li>
</div>
</div>
<div class="login2">
<form action=auditsubmite.php>
<input type="submit" value="Save and Exit">
</form>
<form action=auditsubmits.php>
<input type="submit" value="Save and Submit">
</form>
</div>
<script src="js/auditor.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.accordion.source.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
// <![CDATA[
$(document).ready(function () {
$('ul').accordion();
});
// ]]>
</script>
</body>
</html>
This is audittest3.php
<?PHP
$Q1 = 'unchecked';
$Q1a = 'unchecked';
$Q2 = 'unchecked';
$Q2a = 'unchecked';
$Q2b = 'unchecked';
if (isset($_POST['Submit1'])) {
if (isset($_POST['Q1'])) {
$Q1 = $_POST['Q1'];
if ($Q1 = = '10') {
$Q1 = 'checked';
INSERT INTO `dbaudit` (`username`, `Q`, `value`, `comment`) VALUES ('chuck@email.com', 'Q1', '10', 'comment1');
}
}
if (isset($_POST['Q1a'])) {
$Q1a = $_POST['Q1a'];
if ($Q1a = = '0') {
$Q1a = 'checked';
}
}
if (isset($_POST['Q2'])) {
$Q2 = $_POST['Q2'];
if ($Q2 = = '10') {
$Q2 = 'checked';
}
}
if (isset($_POST['Q2a'])) {
$Q2a = $_POST['Q2a'];
if ($Q2a = = '15') {
$Q2a = 'checked';
}
}
if (isset($_POST['Q2b'])) {
$Q2b = $_POST['Q2b'];
if ($Q2b = = '0') {
$Q2b = 'checked';
}
}
}
?>
Can anyone tell me if I'm on the right track? once I figure out how to get the information TO MySQL, then I have to code the check to see if information exists, and if so populates the page when they log back in later.
Thank you for your time
Aucun commentaire:
Enregistrer un commentaire