So for work I have to make some interactive forms that will are submitted online and then are connected to a MySQL table. However, everytime I hit the submit on the form, all that happens is that the form just stays on the same page and nothing changes except for a little line at the top that says thanks. It's suppose to redirect to a new page. Any ideas on how to fix this problem? Thanks. When I made the form I just replaced the information on an already working form which is why I'm confused as to why it's not working. Sorry if the code came out a little weird, it's a long file.
Code: Select all
<?php $basesite = "http://www.fitrec.northwestern.edu/"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- #BeginTemplate "<?php echo $basesite; ?>Templates/nudar-3rd-classes.dwt" --><!-- DW6 -->
<head>
<!-- WebComm Template System1 -->
<!--startindex -->
<!-- #BeginEditable "header" -->
<title>Staff Feedback</title>
<!--more meta-->
<meta name="dc.title" content="Staff Feedback" />
<meta name="dc.subject.name.corporate" content="Northwestern University (Evanston, IL)" />
<meta name="dc.subject" content="Administrative,Athletics,Fitness,Staff" />
<meta name="dc.publisher" content="Administration and Planning,Fitness and Recreation Division, Athletics and Rec" />
<meta name="dc.description" content="Staff Performance Feedback Form" />
<meta name="dc.date.modified" content="2010/11/07" />
<meta name="dc.language" content="eng" />
<meta name="keywords" content="Administrative,Athletics,Fitness,Staff,Feedback," />
<meta name="robot" content="INDEX, FOLLOW" />
<meta name="revisit-after" content="1 Day" />
<meta name="generator" content="DC Metatag Generator for Northwestern University" />
<meta name="MSSmartTagsPreventParsing" content="TRUE" />
<style type="text/css" media="all">
/* <![CDATA[ */
.cpt{text-align:center}
.cpt img{margin:2px 15px 2px 2px;vertical-align:middle}
.inp{margin:10px}
#scratch_submit{padding:2px 20px}
.error{text-align:center;color:#f00}
/* ]]> */
</style>
<script type="text/javascript">
function resetta()
{
var obj=document.getElementById('captchaForm');
var n=obj.elements.length;
for(var i=0;i<n;i++){if(obj.elements[i].type == "text" || obj.elements[i].type == 'textarea'){obj.elements[i].value = ''}};
for(var i=0;i<n;i++){if(obj.elements[i].type == "checkbox"){obj.elements[i].checked = 0}};
return false;
}
</script>
<!-- #EndEditable -->
<!--stopindex -->
<link rel="stylesheet" href="<?php echo $basesite; ?>style/style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#520063" alink="#666145" vlink="#520063" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
<div id="zheadspace"> </div>
<div id="butsportclub"><a href="<?php echo $basesite; ?>sportclubs/index.html"><img src="<?php echo $basesite; ?>images/butsportclub.gif" alt="Sport Clubs, Leagues & Intramurals" width="105" height="105" border="0" /></a></div>
<div id="butmembership"><a href="<?php echo $basesite; ?>membership/index.html"><img src="<?php echo $basesite; ?>images/butmembership.gif" alt="Membership" width="96" height="96" border="0" /></a></div>
<div id="butclasses"><a href="<?php echo $basesite; ?>classes/index.html"><img src="<?php echo $basesite; ?>images/butclasseson.gif" alt="Classes & Services" width="87" height="87" border="0" /></a></div>
<div id="butfacilities"><a href="<?php echo $basesite; ?>facilities/index.html"><img src="<?php echo $basesite; ?>images/butfacilities.gif" alt="Facilities & Schedules" width="78" height="78" border="0" /></a></div>
<div id="butchicago"><a href="<?php echo $basesite; ?>chicago.html"><img src="<?php echo $basesite; ?>images/butchicago.gif" alt="Chicago Campus" width="59" height="59" border="0" /></a></div>
<div id="butforms"><a href="<?php echo $basesite; ?>forms.html"><img src="<?php echo $basesite; ?>images/butforms.gif" alt="Forms" width="47" height="47" border="0" /></a></div>
<div id="butfaq"><a href="<?php echo $basesite; ?>faq.html"><img src="<?php echo $basesite; ?>images/butfaq.gif" alt="FAQ" width="39" height="39" border="0" /></a></div>
<div id="buthome"><a href="<?php echo $basesite; ?>index.html"><img src="<?php echo $basesite; ?>images/buthome.gif" alt="Home" width="37" height="37" border="0" /></a></div>
<div id="arlogo">
<table border="0" cellspacing="0" cellpadding="0" width="436" height="61" id="arlogo">
<tr align="right" valign="top">
<td width="375" height="40"><a href="<?php echo $basesite; ?>index.html"><img src="<?php echo $basesite; ?>images/artitle.gif" alt="Department of Athletics and Recreation: Fitness, Aquatics, and Recreational Sports" width="375" height="40" border="0" /></a></td>
<td width="61" height="61" rowspan="2"><a href="<?php echo $basesite; ?>index.html"><img src="<?php echo $basesite; ?>images/arlogo.gif" alt="Athletics and Recreation logo" width="61" height="61" border="0" /></a></td>
</tr>
<tr align="right" valign="top">
<td width="375" height="21"><img src="<?php echo $basesite; ?>images/common/bit.gif" alt="" width="375" height="21" border="0" /></td>
</tr>
</table>
</div>
<div id="header"><img src="<?php echo $basesite; ?>images/headclasses.gif" alt="Northwestern University" width="725" height="140" border="0" /></div>
<div id="main">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr align="left" valign="top">
<td width="250" id="znav">
<div id="znavspace"><img src="<?php echo $basesite; ?>images/common/bit.gif" alt="" width="240" height="10" border="0" /></div>
<!-- #BeginLibraryItem "/Library/zasknu.lbi" --><!-- #EndLibraryItem --><div id="znavclasses"><!-- #BeginEditable "nav" -->
<p> </p>
<p> </p>
<!-- #EndEditable -->
<p><a href="<?php echo $basesite; ?>index.html">Athletics and Recreation Home</a></p>
</div></td>
<td id="content" width="99%">
<div id="zcontentspace"> </div>
<div id="zbreadcrumb"><a href="<?php echo $basesite; ?>index.html">NUFitRec</a> > <a href="<?php echo $basesite; ?>classes/group/index.html">Group Exercise Classes</a> > <span class="zbccurrent"><!-- #BeginEditable "currentBreadcrumb" -->Staff Performance Feedback Form<!-- #EndEditable --></span></div>
<!--startindex-->
<a name="top"></a>
<h1><!-- #BeginEditable "title" -->Staff Performance Feedback Form<!-- #EndEditable --></h1>
<!-- #BeginEditable "content" -->
<?php
require_once('../webtools/recaptcha/recaptchalib.php');
require_once('../webtools/recaptcha/recaptchakeys.php');
$resp = null;
$error = null;
// $_SESSION = $_POST;
# was there a reCAPTCHA response?
if ($_POST["recaptcha_response_field"])
{ // +1
echo ("captcha check entered");
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($resp->is_valid)
{ //+2
echo "Thank you for your response";
//$_SESSION = $_POST;
// setTimeout("location.href = 'process-form.php';
// header("Location: process-form.php");
//DATABASE connectivity to insert data
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Connect to mysql server
$link = mysql_connect("pubdb.tech.northwestern.edu", "nufitrec", "n0f1tr3c");
if(!$link)
{
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db("nufitrec");
if(!$db)
{
die("Unable to select database");
}
else { //+3
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str)
{
if(!get_magic_quotes_gpc())
{
return @trim(mysql_real_escape_string($str));
}
else
{
return @trim($str);
}
}
// Sanitize the session variables
$First_Name = clean($_POST['First_Name']);
$Last_Name = clean($_POST['Last_Name']);
$Facility = clean($_POST['Facility']);
$Area_Worked = clean($_POST['Area_Worked']);
$Date = clean($_POST['Date']);
$Pcomment = clean($_POST['Pcomment']);
$Ocomment = clean($_POST['Ocomment']);
$Bcomment = clean($_POST['Bcomment']);
$Reported = clean($_POST['Reported']);
$Email = clean($_POST['Email']);
//$Class = clean($_POST['Class']);
//Create INSERT query
$qry = "INSERT INTO stafffeedback (First_Name, Last_Name, Facility, Area_Worked, Date, Pcomment, Ocomment, Bcomment, Reported, Email) VALUES ('$First_Name', '$Last_Name', '$Facility', '$Area_Worked', '$Date', '$Pcomment', '$Ocomment', '$Bcomment', '$Reported', '$Email')";
$result = mysql_query($qry);
//Check whether the query was successful or not
//echo "Success";
if($result)
{//+4
//echo ('Uploaded to database');
// EMAIL content begins here - send form content to an email address
// $to = 'leo-spornstarr@u.northwestern.edu' . ', ';
$to = 'nirajanrk@gmail.com' . ', ';
// //multiple email addresses
// //$to .= 'wez@example.com';
// subject
$subject = 'Staff Feedback';
$post = $_POST;
// $post = $_SESSION['post'];
// message
$message = '
<html>
<head>
<title>Staff Feedback Form submitted.</title>
</head>
<body>
<p>Here is the info for the form submitted:</p>
<table>';
foreach($post as $key => $value)
{
if ($value != '')
{
$message = $message.('<tr><th>'.$key.": </th><td>".$value.'</td> </tr>');
}
}//end foreach
$message = $message.'
</table>
<br/><br/>
List of all submissions can be viewed <a href="http://fitrec.mccormick.northwestern.edu/stafffeedback/list.php" target="_blank">here.</a>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
//$headers .= 'To: NU FitRec <fitrec@northwestern.edu>, Ed Scott <e-scott@northwestern.edu, Nancy Tierney <n-tierney@northwestern.edu>, Peter Parcell <p-parcell@northwestern.edu>' . "\r\n";
$headers .= 'From: NU FitRec <fitrec@northwestern.edu>' . "\r\n";
// $headers .= 'Cc: nirajanrajkarnikar2007@u.northwestern.edu' . "\r\n";
// $headers .= 'Bcc: nirajanrajkarnikar2007@u.northwestern.edu' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
//Display info on the webpage
//echo("<span class=\"error\">Thanks for your interest in our Mind/Body program. ");
//Redirect users to the page
?>
<script>location.href='http://www.fitrec.northwestern.edu/index.html'</script>
<?php
//header( 'Location: http://www.fitrec.northwestern.edu/classes/group/fallhalfprice-thankyou.html' ) ;
//This displays the entered information on the screen.
// foreach($post as $key => $value)
// {
//
// if ($value != '')
// {
// echo("".$key.": ".$value.'\n');
// //session_destroy();
// }
//
// else{
// $post=NULL; echo('fail');
// // header("Location: cardio_renewal_form_no_captcha.php");
// } //end else
// }//end foreach
} //end if(result)
} //end else($db)
} //end if(resp->is valid)
else
{
# set the error code so that we can display it
$error = $resp->error;
} //end else if(resp->is valid)
}//end if ($_POST["recaptcha_response_field"])
else
{
?>
<h2>Fill in the form below to voice your concern or to praise staff performance.</h2>
<?php
}//end else if ($_POST["recaptcha_response_field"])
?>
<p> </p>
<form onsubmit="" id="Staff-Feedback" name="Staff-Feedback" method="post" action="" >
<input type="hidden" name="code" value="nudar-feedback" />
<input name="Form Type" type="hidden" id="Form Type" value="Staff-Feedback" />
<table width="600" border="0">
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<th width="117" scope="row"><div align="right">First Name</div></th>
<td width="144"><label>
<input type="text" name="First_Name" id="First_Name" value="<?php if(isset($_POST['First_Name'])){echo $_POST['First_Name'];} ?>" />
</label></td>
<td width="225" rowspan="6"> </td>
</tr>
<tr>
<th scope="row"><div align="right">Last Name</div></th>
<td><label>
<input type="text" name="Last_Name" id="Last_Name" value="<?php if(isset($_POST['Last_Name'])){echo $_POST['Last_Name'];} ?>"/>
</label></td>
</tr>
<tr>
<th scope="row"><div align="right">Facility</div></th>
<td>
<select name="Facility" id="Facility">
<option value="SPAC" <?php if(isset($_POST['Facility']) && ($_POST['Facility'] == "SPAC")){echo "selected=\"selected\"";} ?>>SPAC</option>
<option value="Patten" <?php if(isset($_POST['Facility']) && ($_POST['Facility'] == "Patten")){echo "selected=\"selected\"";} ?>>Patten</option>
<option value="Blomquist" <?php if(isset($_POST['Facility']) && ($_POST['Facility'] == "Blomquist")){echo "selected=\"selected\"";} ?>>Blomquist</option>
</select></td>
</tr>
<tr>
<th scope="row"><div align="right">Area Worked</div></th>
<td><select name="Area" id="Area">
<option value="Aquatics" <?php if(isset($_POST['Area_Worked']) && ($_POST['Area_Worked'] == "Aquatics")){echo "selected=\"selected\"";} ?>>Aquatics</option>
<option value="Building Supervisor" <?php if(isset($_POST['Area_Worked']) && ($_POST['Area_Worked'] == "Supervisor")){echo "selected=\"selected\"";} ?>>Building Supervisor</option>
<option value="Front Desk" <?php if(isset($_POST['Area_Worked']) && ($_POST['Area_Worked'] == "Desk")){echo "selected=\"selected\"";} ?>>Front Desk</option>
<option value="Fitness" <?php if(isset($_POST['Area_Worked']) && ($_POST['Area_Worked'] == "Fitness")){echo "selected=\"selected\"";} ?>>Fitness</option>
<option value="Intramurals" <?php if(isset($_POST['Area_Worked']) && ($_POST['Area_Worked'] == "Intramurals")){echo "selected=\"selected\"";} ?>>Intramurals</option>
<option value="Pro Shop" <?php if(isset($_POST['Area_Worked']) && ($_POST['Area_Worked'] == "Shop")){echo "selected=\"selected\"";} ?>>Pro Shop</option>
<option value="Membership" <?php if(isset($_POST['Area_Worked']) && ($_POST['Area_Worked'] == "Membership")){echo "selected=\"selected\"";} ?>>Membership</option>
<option value="Sailing" <?php if(isset($_POST['Area_Worked']) && ($_POST['Area_Worked'] == "Sailing")){echo "selected=\"selected\"";} ?>>Sailing</option>
<option value="Wildcat Camp" <?php if(isset($_POST['Area_Worked']) && ($_POST['Area_Worked'] == "Camp")){echo "selected=\"selected\"";} ?>>Wildcat Camp</option>
<option value="Other" <?php if(isset($_POST['Area_Worked']) && ($_POST['Area_Worked'] == "Other")){echo "selected=\"selected\"";} ?>>Other</option>
</select></td>
</tr>
<tr>
<th scope="row"><div align="right">Date (MM/DD/YY)</div></th>
<td><label>
<input type="text" name="Date" id="Date" value="<?php if(isset($_POST['Date'])){echo $_POST['Date'];} ?>" />
</label></td>
</tr>
<tr>
<th scope="row"><div align="right">"High Five!" Comment</div></th>
<td><label>
<textarea rows="5" cols="20" name="Pcomment" id="Pcomment" value="<?php if(isset($_POST['Pcomment'])){echo $_POST['Pcomment'];} ?>" />
</textarea></label></td>
</tr>
<tr>
<th scope="row"><div align="right">"Oops! Comment"</div></th>
<td><label>
<textarea rows="5" cols="20" name="Ocomment" id="Ocomment" value="<?php if(isset($_POST['Ocmment'])){echo $_POST['OComment'];} ?>" />
</textarea></label></td>
</tr>
<tr>
<th scope="row"><div align="right">"Red Alert!" Comment</div></th>
<td><label>
<textarea rows="5" cols="20" name="Bcomment" id="Bcomment" value="<?php if(isset($_POST['Bcomment'])){echo $_POST['Bcomment'];} ?>" />
</textarea></label></td>
</tr>
<tr>
<th scope="row"><div align="right">Reported by:</div></th>
<td><label>
<input type="text" name="Reported" id="Reported" value="<?php if(isset($_POST['Reported'])){echo $_POST['Reported'];} ?>" />
</label></td>
</tr>
<tr>
<th scope="row"><div align="right">Email</div></th>
<td><label>
<input type="text" name="Email" id="Email" value="<?php if(isset($_POST['Email'])){echo $_POST['Email'];} ?>" />
</label></td>
</tr>
<tr >
<th colspan="2" scope="row" >
<label>
<div >
<a name="captcha"></a> <br/> <br/>
<p>Please insert the same letters and numbers you see in this image into the box to your bottom.</p>
<div class="cpt">
<?php
echo recaptcha_get_html($publickey, $error);
?>
</div>
<br/>
<input type="submit" name="scratch_submit" id="scratch_submit" value="Submit" />
<input name="Reset" type="reset" id="Reset" value="Reset" onclick="return resetta()"/>
</div>
</label></th>
</tr>
</table>
</form>
<p> </p>
<!-- #EndEditable -->
<!--stopindex--> </td>
</tr>
</table>
</div>
<div id="zfooter">
<table id="zsearchrow" border="0" cellspacing="0" cellpadding="0" width="100%" height="80">
<tr align="right" valign="bottom">
<td id="znav" width="250" height="80"><img src="<?php echo $basesite; ?>images/common/bit.gif" alt="" width="240" height="80" border="0" /></td>
<td id="zsearchclasses" width="99%" height="80"><div id="search"><!-- #BeginLibraryItem "/Library/zsearch.lbi" --><p align="left"><a href="http://www.northwestern.edu/search/help/">Search</a></p>
<form action="http://search.northwestern.edu/query.html" method="get">
<table cellpadding="0" cellspacing="2" border="0">
<tr>
<td colspan="2"><input type="text" name="qt" size="25" /></td>
<td rowspan="2">
<table cellpadding="0" cellspacing="2" border="0">
<tr>
<td><input type="radio" name="qp" value="" checked="checked" /></td>
<td valign="middle"><a href="http://www.northwestern.edu/">Northwestern</a></td>
</tr>
<tr>
<td><input type="radio" name="qp" value="url:www.fitrec.northwestern.edu/" /></td>
<td valign="middle" nowrap="nowrap"><a href="<?php echo $basesite; ?>index.html">Athletics and Recreation</a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><a href="http://www.northwestern.edu/search/help/">Help</a></td>
<td align="right"><input type="image" src="/shared/images/search/soft/search-button.gif" alt="Search" width="64" height="12" border="0" /></td>
</tr>
</table>
</form>
<!-- #EndLibraryItem --></div></td>
</tr>
</table>
<table id="footer" border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td id="seal"><a href="http://www.northwestern.edu/"><img src="<?php echo $basesite; ?>images/common/seal-white.gif" alt="Northwestern University" width="200" height="119" border="0" /></a></td>
<td id="footlinks"><!-- #BeginLibraryItem "/Library/zfooter.lbi" -->
<p>
<a href="<?php echo $basesite; ?>sportclubs/index.html">Sport Clubs, Leagues & Intramurals</a> |
<a href="<?php echo $basesite; ?>membership/index.html">Membership</a> |
<a href="<?php echo $basesite; ?>classes/index.html">Classes & Services</a> |
<a href="<?php echo $basesite; ?>facilities/index.html">Facilities & Schedules</a>
<br />
<a href="<?php echo $basesite; ?>chicago.html">Chicago Campus</a> |
<a href="<?php echo $basesite; ?>forms.html">Forms</a> |
<a href="<?php echo $basesite; ?>faq.html">FAQ</a>
<br />
<a href="http://www.northwestern.edu/">Northwestern Home</a> |
<a href="http://planitpurple.northwestern.edu">Northwestern Calendar: Plan-It Purple</a> |
<a href="http://www.northwestern.edu/search/">Northwestern Search</a>
<br />
Fitness and Recreation 2311 Campus Drive Evanston, IL 60208-4230<br />
Phone: 847-491-4300 Fax: 847-467-1405 E-mail: <a href="mailto:fitrec@northwestern.edu">FitRec@northwestern.edu</a>
<br />
Last updated
<!--#config timefmt="%m/%d/%Y" --><!--#echo var="LAST_MODIFIED" -->
<a href="http://www.northwestern.edu/disclaimer.html">World Wide Web Disclaimer</a> and <a href="http://www.northwestern.edu/policy.html">University
Policy Statements</a>
© 2005 Northwestern University</p>
<!-- #EndLibraryItem --></td>
</tr>
</table>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-7798879-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
<!-- #EndTemplate -->