Jump to content

sandari

New Members
  • Posts

    7
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

sandari's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Is this better? <?php session_start(); $page_title='Substance Abuse History'; ?> <!-- START OF CENTRE COLUMN --> <td class="midpanel" valign="top"> <?php // Next lines are error checking code echo "<h5>Line 10: GET Array = ".print_r($_GET,TRUE)."<br /> POST Array= ".print_r($_POST,TRUE)."<br /> SESSION Array= ".print_r($_SESSION,TRUE)."</h5>"; // End of error checking code require_once ('./secure/transformations_mysqli_connect.php'); $errors=array(); $drug=array(); $drug_usage=array('AgeFirstUsed','AgeRegularUse','YearsDailyUse','DailyAmount','DaysUsedLast4Weeks','DaysUsedLast7Days','LastUsed'); $drug_used=array('DrugOfUse'=>$drug,'usage'=>$drug_usage); if(isset($_POST['submitted'])){ //ClientID is set for testing purposes only $ClientID = 1; $errors=array(); if(empty($_POST['Used'])){ if(empty($_POST['AgeFirstUsed'])){ $errors[]="Please tell us AgeFirstUsed {$_POST['DrugOfUse']}"; } else{ $drug_used['DrugOfUse'][]=@mysqli_real_escape_string($dbc,$_POST['AgeFirstUsed']); } // End if(empty($_POST['AgeFirstUsed'])) if(empty($_POST['AgeRegularUse'])){ $errors[]="Please tell us AgeRegularUse of {$_POST['DrugOfUse']}"; } else{ $drug_used['DrugOfUse'][]=@mysqli_real_escape_string($dbc,$_POST['AgeRegularUse']); } // End if(empty($_POST['AgeRegularUse'])) if(empty($_POST['YearsDailyUse'])){ $errors[]="Please tell us YearsDailyUse of {$_POST['DrugOfUse']}"; } else{ $drug_used['DrugOfUse'][]=@mysqli_real_escape_string($dbc,$_POST['YearsDailyUse']); } // End if(empty($_POST['YearsDailyUse'])) if(empty($_POST['DailyAmount'])){ $errors[]="Please tell us DailyAmount of {$_POST['DrugOfUse']}"; } else{ $drug_used['DrugOfUse'][]=@mysqli_real_escape_string($dbc,$_POST['DailyAmount']); } // End if(empty($_POST['DailyAmount'])) if(empty($_POST['DaysUsedLast4Weeks'])){ $errors[]="Please tell us DaysUsedLast4Weeks {$_POST['DrugOfUse']}"; } else{ $drug_used['DrugOfUse'][]=@mysqli_real_escape_string($dbc,$_POST['DaysUsedLast4Weeks']); } // End if(empty($_POST['DaysUsedLast4Weeks'])) if(empty($_POST['DaysUsedLast7Days'])){ $errors[]="Please tell us DaysUsedLast7Days {$_POST['DrugOfUse']}"; } else{ $drug_used['DrugOfUse'][]=@mysqli_real_escape_string($dbc,$_POST['DaysUsedLast7Days']); } // End if(empty($_POST['DaysUsedLast7Days'])) if(empty($_POST['DateLastUsed'])){ $errors[]="Please tell us DateLastUsed {$_POST['DrugOfUse']}"; } else{ $drug_used['DrugOfUse'][]=@mysqli_real_escape_string($dbc,$_POST['DateLastUsed']); } // End if(empty($_POST['DateLastUsed'])) } // End if(!empty($_POST['DrugOfUse'])) // Next lines are error checking code echo"<h5>Line 82 - Drug: $drug | Usage = $drug_usage</h5>"; echo "<h5>Line 114: Errors contain ".print_r($errors,true)."<br />ClientID = $ClientID</h5>"; // End of error checking code if(isset($ClientID)){ if(empty($errors)){ //If there were no errors $query="insert into tblSubstanceHistory (ClientID, Substance, AgeFirstUsed, AgeRegularUse, YearsDailyUse, DailyAmount, DaysUsedLast4Weeks, DaysUsedLast7Days, DateLastUsed) values ($ClientID, foreach($drug as $drug=>$drug_used){ foreach($drug_used as $key=>$value){ '$value' } } );"; $result=mysqli_query($dbc, $query); $rows=mysqli_affected_rows($dbc); // Next lines are error checking code echo "<h5>Line 111: Query = $query"; echo "<h5>Line 88 Rows affected = $rows</h5>"; //End of error checking code if($result){ //If a insert was successful // Next line is error checking code echo "<h5>Line 106 - Next Page is Admin.php</h5>"; //End of error checking code /* $url.='./admin.php'; header("location: $url"); exit(); */ } //End of if INSERT successful else{ //If not INSERT successful ?> <div class="login" align="center" valign="top" width="90%"> <p class="error"> <h2 align="center"><label>Your reponses could not be recorded.</label><br /> <label>Please call your System Administrator.</label></h2></p> <div class="buttons" align="center" width="25%"> <form method="POST" action="admin.php"> <input type="submit" value=" Return "> </form> </div> </div> <!-- END OF CENTRE COLUMN --> <?php } //End if no match found } //End if no errors else{ //If there are errors //echo "<h5>Line 119</h5>"; // include('./includes/header.html'); // include('./includes/expandingMenu.html'); echo"<br />"; foreach($errors as $key=>$value){ echo "<h4 align=\"center\">$value</h4>"; } // echo "<h4 align=\"center\">Please answer ALL questions</h4>"; ?> <h3> <!-- Start of Centre Column --> <?php $query="select DrugOfUse from tblDrugs;"; $result=mysqli_query($dbc,$query) or trigger_error("$query\n<br />MySQL Error: ".mysqli_error($dbc)); echo "<h6>Line 157 - Query : $query</h6>"; ?> <div class="login" align="center" valign="top" width="70%"> <form action="substance_abuse_history1" method="POST"> <h2 align="center" ><strong>SUBSTANCE ABUSE HISTORY</strong></h2> <!-- DISPLAY THE DRUG USAGE TABLE --> <table valign="center" align="centre" cellspacing="0" cellpadding="5" border="1"> <tr class="tablehead"> <h5> <th valign="center" align="centre">Substance</th> <th valign="center" align="centre">Age<br />First<br />Used</th> <th valign="center" align="centre">Age<br />Regular<br />Use</th> <th valign="center" align="centre">Years<br />of<br />Daily<br />Use</th> <th valign="center" align="centre">Amount<br />Used<br />Daily</th> <th valign="center" align="centre">Days<br />Used<br />in<br />Last<br />4<br />Weeks</th> <th valign="center" align="centre">Days<br />Used<br />in<br />Last<br />7<br />Days</th> <th valign="center" align="centre">Date Last Used</th> </h5> </tr> <?php $DrugNo=0; while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){ echo "<tr><h6>"; echo "<td>{$row['DrugOfUse']}</td>"; $drug[]=$row['DrugOfUse']; $DrugNo++; echo "<td><input type=\"radio\" name=\"Used\" value=\"True\"/>Yes<input type=\"radio\" name=\"Used\" value=\"False\"/>No</td>"; echo "<td align=\"center\"><input type=\"text\" name=\"AgeFirstUsed\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"AgeRegularUse\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"YearsDailyUse\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DailyAmount\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DaysUsedLast4Weeks\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DaysUsedLast7Days\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DateLastUsed\" align=\"center\" size=\"20\" maxlength=\"50\" value=\" \"/></td>"; echo "</h6></tr>"; } ?> </table> <br /> <br /> <div class="buttons" align="center" width="25%"> <!-- <form action="substance_abuse_history1.php" method="POST"> --> <input type="submit" value=" NEXT "> <input type="hidden" name="submitted" value="TRUE" /> <!-- </form> --> <br /><br /> </div> </form> </div> </h3> <!-- End of Centre Column --> <?php } //End if there were errors }//End if(isset($_POST['ClientID'] else{ // if(!isset($_POST['ClientID'] echo"<h3 align=\"center\">This page has been accessed in error<br /><br /><br /><br /><br /></h3>"; ?> <div class="buttons" align="center" width="25%"> <form method="POST" action="admin.php"> <input type="submit" value=" Return "> </form> </div> <?php }// End if(!isset($_POST['ClientID'] } else{// if NOT Submitted ?> <!-- Start of Centre Column --> <?php $query="select DrugOfUse from tblDrugs;"; $result=mysqli_query($dbc,$query) or trigger_error("$query\n<br />MySQL Error: ".mysqli_error($dbc)); //echo "<h6>Line 191 - Query : $query</h6>"; ?> <div class="login" align="center" valign="top" width="70%"> <form action="substance_abuse_history1.php" method="POST"> <h2 align="center" ><strong>SUBSTANCE ABUSE HISTORY</strong></h2> <!-- DISPLAY THE DRUG USAGE TABLE --> <table valign="center" align="centre" cellspacing="0" cellpadding="5" border="1"> <tr class="tablehead"> <h5> <th valign="center" align="centre">Substance</th> <th valign="center" align="centre">Used</th> <th valign="center" align="centre">Age<br />First<br />Used</th> <th valign="center" align="centre">Age<br />Regular<br />Use</th> <th valign="center" align="centre">Years<br />of<br />Daily<br />Use</th> <th valign="center" align="centre">Amount<br />Used<br />Daily</th> <th valign="center" align="centre">Days<br />Used<br />in<br />Last<br />4<br />Weeks</th> <th valign="center" align="centre">Days<br />Used<br />in<br />Last<br />7<br />Days</th> <th valign="center" align="centre">Date Last Used</th> </h5> </tr> <?php $DrugNo=0; while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){ echo "<tr><h6>"; echo "<td>{$row['DrugOfUse']}</td>"; $drug[$DrugNo]=$row['DrugOfUse']; $DrugNo++; echo "<td><input type=\"radio\" name=\"Used\" value=\"True\"/>Yes<input type=\"radio\" name=\"Used\" value=\"False\"/>No</td>"; echo "<td align=\"center\"><input type=\"text\" name=\"AgeFirstUsed\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"AgeRegularUse\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"YearsDailyUse\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DailyAmount\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DaysUsedLast4Weeks\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DaysUsedLast7Days\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DateLastUsed\" align=\"center\" size=\"20\" maxlength=\"50\" value=\" \"/></td>"; echo "</h6></tr>"; } ?> </table> <br /> <br /> <div class="buttons" align="center" width="25%"> <!-- <form method="POST" action="substance_abuse_history1.php"> --> <input type="submit" value=" NEXT "> <input type="hidden" name="submitted" value="TRUE" /> <!-- </form> --> <br /><br /> </div> </form> </div> </h3> <!-- End of Centre Column --> <?php }// End if(isset($_POST['submitted'])) ?>
  2. Just to clarify things. Here is the actual code - all 317 lines of it. <?php session_start(); $page_title='Substance Abuse History'; ?> <!-- START OF CENTRE COLUMN --> <td class="midpanel" valign="top"> <?php // Next lines are error checking code echo "<h5>Line 10: GET Array = ".print_r($_GET,TRUE)."<br /> POST Array= ".print_r($_POST,TRUE)."<br /> SESSION Array= ".print_r($_SESSION,TRUE)."</h5>"; // End of error checking code require_once ('./secure/transformations_mysqli_connect.php'); $errors=array(); $drug=array(); $drug_usage=array('AgeFirstUsed','AgeRegularUse','YearsDailyUse','DailyAmount','DaysUsedLast4Weeks','DaysUsedLast7Days','LastUsed'); $drug_used=array('DrugOfUse'=>$drug,'usage'=>$drug_usage); if(isset($_POST['submitted'])){ //ClientID is set for testing purposes only $ClientID = 1; $errors=array(); if(empty($_POST['Used'])){ if(empty($_POST['AgeFirstUsed'])){ $errors[]="Please tell us AgeFirstUsed {$_POST['DrugOfUse']}"; } else{ $drug_used['DrugOfUse'][]=@mysqli_real_escape_string($dbc,$_POST['AgeFirstUsed']); } // End if(empty($_POST['AgeFirstUsed'])) if(empty($_POST['AgeRegularUse'])){ $errors[]="Please tell us AgeRegularUse of {$_POST['DrugOfUse']}"; } else{ $drug_used['DrugOfUse'][]=@mysqli_real_escape_string($dbc,$_POST['AgeRegularUse']); } // End if(empty($_POST['AgeRegularUse'])) if(empty($_POST['YearsDailyUse'])){ $errors[]="Please tell us YearsDailyUse of {$_POST['DrugOfUse']}"; } else{ $drug_used['DrugOfUse'][]=@mysqli_real_escape_string($dbc,$_POST['YearsDailyUse']); } // End if(empty($_POST['YearsDailyUse'])) if(empty($_POST['DailyAmount'])){ $errors[]="Please tell us DailyAmount of {$_POST['DrugOfUse']}"; } else{ $drug_used['DrugOfUse'][]=@mysqli_real_escape_string($dbc,$_POST['DailyAmount']); } // End if(empty($_POST['DailyAmount'])) if(empty($_POST['DaysUsedLast4Weeks'])){ $errors[]="Please tell us DaysUsedLast4Weeks {$_POST['DrugOfUse']}"; } else{ $drug_used['DrugOfUse'][]=@mysqli_real_escape_string($dbc,$_POST['DaysUsedLast4Weeks']); } // End if(empty($_POST['DaysUsedLast4Weeks'])) if(empty($_POST['DaysUsedLast7Days'])){ $errors[]="Please tell us DaysUsedLast7Days {$_POST['DrugOfUse']}"; } else{ $drug_used['DrugOfUse'][]=@mysqli_real_escape_string($dbc,$_POST['DaysUsedLast7Days']); } // End if(empty($_POST['DaysUsedLast7Days'])) if(empty($_POST['DateLastUsed'])){ $errors[]="Please tell us DateLastUsed {$_POST['DrugOfUse']}"; } else{ $drug_used['DrugOfUse'][]=@mysqli_real_escape_string($dbc,$_POST['DateLastUsed']); } // End if(empty($_POST['DateLastUsed'])) } // End if(!empty($_POST['DrugOfUse'])) // Next lines are error checking code echo"<h5>Line 82 - Drug: $drug | Usage = $drug_usage</h5>"; echo "<h5>Line 114: Errors contain ".print_r($errors,true)."<br />ClientID = $ClientID</h5>"; // End of error checking code if(isset($ClientID)){ if(empty($errors)){ //If there were no errors $query="insert into tblSubstanceHistory (ClientID, Substance, AgeFirstUsed, AgeRegularUse, YearsDailyUse, DailyAmount, DaysUsedLast4Weeks, DaysUsedLast7Days, DateLastUsed) values ($ClientID, foreach($drug as $drug=>$drug_used){ foreach($drug_used as $key=>$value){ '$value' } } );"; $result=mysqli_query($dbc, $query); $rows=mysqli_affected_rows($dbc); // Next lines are error checking code echo "<h5>Line 111: Query = $query"; echo "<h5>Line 88 Rows affected = $rows</h5>"; //End of error checking code if($result){ //If a insert was successful // Next line is error checking code echo "<h5>Line 106 - Next Page is Admin.php</h5>"; //End of error checking code /* $url.='./admin.php'; header("location: $url"); exit(); */ } //End of if INSERT successful else{ //If not INSERT successful ?> <div class="login" align="center" valign="top" width="90%"> <p class="error"> <h2 align="center"><label>Your reponses could not be recorded.</label><br /> <label>Please call your System Administrator.</label></h2></p> <div class="buttons" align="center" width="25%"> <form method="POST" action="admin.php"> <input type="submit" value=" Return "> </form> </div> </div> <!-- END OF CENTRE COLUMN --> <?php } //End if no match found } //End if no errors else{ //If there are errors //echo "<h5>Line 119</h5>"; // include('./includes/header.html'); // include('./includes/expandingMenu.html'); echo"<br />"; foreach($errors as $key=>$value){ echo "<h4 align=\"center\">$value</h4>"; } // echo "<h4 align=\"center\">Please answer ALL questions</h4>"; ?> <h3> <!-- Start of Centre Column --> <?php $query="select DrugOfUse from tblDrugs;"; $result=mysqli_query($dbc,$query) or trigger_error("$query\n<br />MySQL Error: ".mysqli_error($dbc)); echo "<h6>Line 157 - Query : $query</h6>"; ?> <div class="login" align="center" valign="top" width="70%"> <form action="substance_abuse_history1" method="POST"> <h2 align="center" ><strong>SUBSTANCE ABUSE HISTORY</strong></h2> <!-- DISPLAY THE DRUG USAGE TABLE --> <table valign="center" align="centre" cellspacing="0" cellpadding="5" border="1"> <tr class="tablehead"> <h5> <th valign="center" align="centre">Substance</th> <th valign="center" align="centre">Age<br />First<br />Used</th> <th valign="center" align="centre">Age<br />Regular<br />Use</th> <th valign="center" align="centre">Years<br />of<br />Daily<br />Use</th> <th valign="center" align="centre">Amount<br />Used<br />Daily</th> <th valign="center" align="centre">Days<br />Used<br />in<br />Last<br />4<br />Weeks</th> <th valign="center" align="centre">Days<br />Used<br />in<br />Last<br />7<br />Days</th> <th valign="center" align="centre">Date Last Used</th> </h5> </tr> <?php $DrugNo=0; while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){ echo "<tr><h6>"; echo "<td>{$row['DrugOfUse']}</td>"; $drug[]=$row['DrugOfUse']; $DrugNo++; echo "<td><input type=\"radio\" name=\"Used\" value=\"True\"/>Yes<input type=\"radio\" name=\"Used\" value=\"False\"/>No</td>"; echo "<td align=\"center\"><input type=\"text\" name=\"AgeFirstUsed\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"AgeRegularUse\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"YearsDailyUse\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DailyAmount\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DaysUsedLast4Weeks\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DaysUsedLast7Days\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DateLastUsed\" align=\"center\" size=\"20\" maxlength=\"50\" value=\" \"/></td>"; echo "</h6></tr>"; } ?> </table> <br /> <br /> <div class="buttons" align="center" width="25%"> <!-- <form action="substance_abuse_history1.php" method="POST"> --> <input type="submit" value=" NEXT "> <input type="hidden" name="submitted" value="TRUE" /> <!-- </form> --> <br /><br /> </div> </form> </div> </h3> <!-- End of Centre Column --> <?php } //End if there were errors }//End if(isset($_POST['ClientID'] else{ // if(!isset($_POST['ClientID'] echo"<h3 align=\"center\">This page has been accessed in error<br /><br /><br /><br /><br /></h3>"; ?> <div class="buttons" align="center" width="25%"> <form method="POST" action="admin.php"> <input type="submit" value=" Return "> </form> </div> <?php }// End if(!isset($_POST['ClientID'] } else{// if NOT Submitted ?> <!-- Start of Centre Column --> <?php $query="select DrugOfUse from tblDrugs;"; $result=mysqli_query($dbc,$query) or trigger_error("$query\n<br />MySQL Error: ".mysqli_error($dbc)); //echo "<h6>Line 191 - Query : $query</h6>"; ?> <div class="login" align="center" valign="top" width="70%"> <form action="substance_abuse_history1.php" method="POST"> <h2 align="center" ><strong>SUBSTANCE ABUSE HISTORY</strong></h2> <!-- DISPLAY THE DRUG USAGE TABLE --> <table valign="center" align="centre" cellspacing="0" cellpadding="5" border="1"> <tr class="tablehead"> <h5> <th valign="center" align="centre">Substance</th> <th valign="center" align="centre">Used</th> <th valign="center" align="centre">Age<br />First<br />Used</th> <th valign="center" align="centre">Age<br />Regular<br />Use</th> <th valign="center" align="centre">Years<br />of<br />Daily<br />Use</th> <th valign="center" align="centre">Amount<br />Used<br />Daily</th> <th valign="center" align="centre">Days<br />Used<br />in<br />Last<br />4<br />Weeks</th> <th valign="center" align="centre">Days<br />Used<br />in<br />Last<br />7<br />Days</th> <th valign="center" align="centre">Date Last Used</th> </h5> </tr> <?php $DrugNo=0; while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){ echo "<tr><h6>"; echo "<td>{$row['DrugOfUse']}</td>"; $drug[$DrugNo]=$row['DrugOfUse']; $DrugNo++; echo "<td><input type=\"radio\" name=\"Used\" value=\"True\"/>Yes<input type=\"radio\" name=\"Used\" value=\"False\"/>No</td>"; echo "<td align=\"center\"><input type=\"text\" name=\"AgeFirstUsed\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"AgeRegularUse\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"YearsDailyUse\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DailyAmount\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DaysUsedLast4Weeks\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DaysUsedLast7Days\" align=\"center\" size=\"2\" maxlength=\"2\" value=\" \"/></td>"; echo "<td align=\"center\"><input type=\"text\" name=\"DateLastUsed\" align=\"center\" size=\"20\" maxlength=\"50\" value=\" \"/></td>"; echo "</h6></tr>"; } ?> </table> <br /> <br /> <div class="buttons" align="center" width="25%"> <!-- <form method="POST" action="substance_abuse_history1.php"> --> <input type="submit" value=" NEXT "> <input type="hidden" name="submitted" value="TRUE" /> <!-- </form> --> <br /><br /> </div> </form> </div> </h3> <!-- End of Centre Column --> <?php }// End if(isset($_POST['submitted'])) ?> Hope this helps.
  3. My database is in 4th normal form. Connection has been made to MySQL database. I need to know how to write the PHP code to assemble the multi-dimensional array in PHP from the rows in the table so I can create the query (in PHP) to write to te database. I was thinking of something like: $answers=array($topic=array($answer1,$answer1,$answer1,$answer1)); then: $query="insert into TableName(Topic, Answer1, answer2, answer3, answer4) values(foreach($topic as$row=>$answer){foreach($answer as $col=>$value){'$value'}}); So that the input table might look like: ____________________________________________________________________________ | Title | Question1 | Question2 | Question3 | Question4 | -------------------------------------------------------------------------------------------------------------------------- | Topic1 | [Topic1]['Answer1'] | [Topic1]['Answer2'] | [Topic1]['Answer3'] | [Topic4]['Answer4'] | -------------------------------------------------------------------------------------------------------------------------- | Topic2 | [Topic2]['Answer1'] | [Topic2]['Answer2'] | [Topic2]['Answer3'] | [Topic2]['Answer4'] | -------------------------------------------------------------------------------------------------------------------------- | Topic3 | [Topic3]['Answer1'] | [Topic3]['Answer2'] | [Topic3]['Answer3'] | [Topic3]['Answer4'] | -------------------------------------------------------------------------------------------------------------------------- | Topic4 | [Topic4]['Answer1'] | [Topic4]['Answer2'] | [Topic4]['Answer3'] | [Topic4]['Answer4'] | -------------------------------------------------------------------------------------------------------------------------- | Topic5 | [Topic5]['Answer1'] | [Topic5]['Answer2'] | [Topic5]['Answer3'] | [Topic5]['Answer4'] | -------------------------------------------------------------------------------------------------------------------------- Or, have I just answered my own question???
  4. I have a data input table like this: ____________________________________________ | Title | Question1 | Question2 | Question3 | Question4 | ----------------------------------------------------------------------- | Topic1 | Answer1 | Answer2 | Answer3 | Answer4 | ----------------------------------------------------------------------- | Topic2 | Answer1 | Answer2 | Answer3 | Answer4 | ----------------------------------------------------------------------- | Topic3 | Answer1 | Answer2 | Answer3 | Answer4 | ----------------------------------------------------------------------- | Topic4 | Answer1 | Answer2 | Answer3 | Answer4 | ----------------------------------------------------------------------- | Topic5 | Answer1 | Answer2 | Answer3 | Answer4 | ----------------------------------------------------------------------- I need to save the answers for each topic into a MySQL table with the following structure: TableName Topic Varchar(100), Answer1 Varchar(20), Answer2 Varchar(20), Answer3 Varchar(20), Answer4 Varchar(20). Right now I am getting quite confused with the makeup of the multi-dimensional array needed to do the job. Any help will be appreciated.
  5. All is OK! The problem turned out to be with my ISP who has turned off some features :-(
  6. Sorry. Here it is. Header.html: <!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> <?php // Start output buffering ob_start(); //Initialise a session //session_start(); ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="keywords" content="drug, drugs, alcohol, rehabilitation,Fraser Coast, Hervey Bay, Torquay" /> <title><?php echo $page_title;?></title> <!-- <link rel="stylesheet" type="text/css" href="./css/layout.css"> --> <link rel="stylesheet" type="text/css" href="./css/transformations.css"> <link rel="shortcut icon" href="./images/TMI.ico" type="image/x-icon"/> <!--<link rel="shortcut icon" href="./images/ClubLogo.ico" type="image/x-icon"/>--> <script language="javascript" type="text/javascript" src="./js/datetimepicker.js"></script> <script type="text/javascript" src="/jwplayer/jwplayer.js"></script> <div class="mainmenu" align="left"> <!-- Main Banner --> <table border="0" width="90%"> <tr width="100%"> <td border="1" width="100%"> <div id="header" valign="top"> <img src="./images/TMI.png" border="0" height="110px" align="left"/> <br /> <br /> </div> </td> </tr> </table> </div> <?php require_once ('./secure/transformations_mysqli_connect.php'); ?> </head> <body> index.php: <?php session_start(); $page_title='Welcome to Transformations'; if(isset($_POST['submitted'])){ $errors=array(); if(isset($_SESSION['email'])){ $email=@mysqli_real_escape_string($dbc,$_SESSION['email']); } else{ if (empty($_POST['email'])){ $errors[]="Please enter your email address."; } //End if no email entered else{ $email=@mysqli_real_escape_string($dbc,$_POST['email']); } // End if email has been entered } if(isset($_SESSION['password'])){ $password=@mysqli_real_escape_string($dbc,$_SESSION['password']); } else{ if(empty($_POST['password'])){ $errors[]="Please enter your password"; } // End no password else{ $password=@mysqli_real_escape_string($dbc,$_POST['password']); } // End password entered } if(empty($errors)){ //If there were no errors $query="select id, GivenName1, Surname, Campus, Classification from tblstaff where ((email='$email') and (password='$password'));"; $result=@mysqli_query($dbc, $query); $row=@mysqli_fetch_array($result, MYSQL_BOTH); if($row){ //If a match is found $_SESSION['ClientID'] = $row[0]; $_SESSION['GivenName1'] = $row[1]; $_SESSION['Surname'] = $row[2]; //Redirect the user to the loggedin page $url='http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']); // Check for a trailing slash if((substr($url,-1)=='/') or (substr($url,-1)=='\\')){ $url=substr(url,0,-1); //Remove the slash } //End check for trailing slash $url.='./admin.php'; header("location: $url"); exit(); } //End of if match found else{ //If no match found // include('./includes/header.html'); ?> <div class="login" align="center" valign="top" width="90%"> <h2 align="center">Login</h2> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST"> <p class="error"> <h3 align="center"><label>Your email and/or password are not on file.</label><br /> <label>Please Register as a New User.</label></h3></p> <div class="buttons" align="center" width="25%"> <br /><br /> <form method="LINK" action="forgot_password.php"> <input type="submit" value=" Forgot Password?"> </form> <br /> <br /> <br /> <form method="LINK" action="register.php"> <input type="submit" value="Register New Client"> </form> </div> <div> <form></form> </div> </div> <!-- END OF CENTRE COLUMN --> <?php } //End if no match found } //End if no errors else{ // include('./includes/header.html'); foreach($errors as $key=>$value){ echo "<h5 align=\"center\">$value</h5>"; } echo"<h5 align=\"center\">Or Use the Button Below to <br />Register as a New Client</h5>"; ?> <h4> <div class="buttons" align="center" width="25%"> <form method="LINK" action="register.php"> <input type="submit" value=" New Client "> </form> </div> </h4> <!-- Start of Centre Column --> <div class="login" align="center" valign="top" width="90%"> <h2 align="center">Login</h2> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST"> <fieldset> <h4 align="center"> <label>Email Address:</label><br > <input type="text" name="email" value=" " size="20" maxlength="40" border="2"/> <br /> <label>Password:</label><br /> <input type="password" name="password" value=" " size="20" maxlength="20" border="2"/></h4> <div class="buttons" align="center" width="25%"> <form method="POST" action="login.php"> <input type="submit" value=" Login "> <input type="hidden" name="submitted" value="TRUE" /> </form> <br /><br /> <form method="LINK" action="forgot_password.php"> <input type="submit" value=" Forgot Password?"> </form> <br /><!-- <form method="LINK" action="register.php"> <input type="submit" value=" Register "> </form> --> </div> </fieldset> </form> </div> <!-- End of Centre Column --> <?php } //End if there were errors } //End if(isset($_POST['submitted']) //} //End if submitted else{ //If form not submitted // include('./includes/header.html'); $_SESSION=array(); session_destroy(); $_POST=array(); $_GET=array(); ?> <!-- Start of Centre Column --> <table class="login" align="center" valign="top" width="90%"> <tr> <td> <fieldset> <h2 align="center">New Client</h2> <div class="buttons" align="center" width="25%"> <form method="LINK" action="register.php"> <strong> <input type="submit" value=" Register "> </strong> </form> </div> </h2> </fieldset> </td> </tr> <tr> <td> <fieldset> <h2 align="center">Login</h2> <form method="POST" action="login.php"> <h4 align="center"> <label>Email Address:</label><br /> <input type="text" name="email" value=" " size="50" maxlength="100" border="2"/> <br /> <label>Password:</label><br /> <input type="password" name="password" value=" " size="20" maxlength="20" border="2"/> </h4> <div class="buttons" align="center" width="25%"> <h4> <input type="submit" value=" Login "> <input type="hidden" name="submitted" value="TRUE" /> <br /><br /> </div> </form> <div class="buttons" align="center" width="25%"> <form method="LINK" action="forgot_password.php"> <input type="submit" value="Forgot Password?"> </form> </div> </h4> </fieldset> </td> </tr> </table> <!-- End of Centre Column --> <?php }// End if form not submitted include ('./includes/footer.html'); ?> footer.html: <table border="0" width="90%"> <tr border="0" width="100%"> <td border="0" width="100%"> <div class="footer" align="center"> <hr /> <?php echo '<h5 align="center"> <label>Copyright 2012 SandySoft </label><br /> ?> <hr /> </div> <!-- End of div:footer --> </td> </tr> </table> </body> </html> mod edit: code in code tags please
  7. Using localhost my web page displays pefectly (i.e. header.html, index.php, footer.html) with header.html and footer.html being included files. However, in a live situation calling the web page only displays the header.html and nothing else. If I comment out the header.html I get the index.php and footer.html displaying. I have checked it in Firefox and IE. Anyone???
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.