website moved and php form not working (old php version) - php

I moved website from to other hosting server and contact form doesn't work. Current version of php is 5.2 and before was older. I saw on forums that in order for older php code to work i should turn globals on which I did (I know it's insecure and I will replace that code completely, but right now I have to make it work). Before I turned globals on nothing was working and now I'm getting message if some field is missing but nothing more than that. Any suggestions how to make this contact form work? Any answer will be very appreciated.
<?
$contact = 'contact';
require('inc_meta.php');
if($form)
{
$error = Array();
if(!trim($c_name)){ $error[sizeof($error)] = "Name"; }
if(!trim($email)){ $error[sizeof($error)] = "E-mail Address"; }
else {
if(!eregi("^[_\.0-9a-z-]+#([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$",$email)){ $error[sizeof($error)] = "'" . $email . "' is not avalid E-mail Address."; }
}
}
$filePath = getenv("SCRIPT_NAME");
if($_SERVER['HTTP_REFERER'] == 'http://'.$_SERVER['SERVER_NAME'].''.$filePath.'')
{
if($form && !$error)
{
$contents = "Name: $c_name\r
Address:\r
$c_address\r
$c_city, $c_state $c_zip\n
Phone: $c_phone\r
Fax: $c_fax\r
Email: $email\n
Comments or Questions:\r
$c_comments";
mail("$EMAILADMIN","email from $c_name","$contents","From: $c_name<$email>");
$status = "Thank You, <b>$c_name</b><br><br>";
$status .= "Your e-mail message has been sent. We will contact you shortly about your inquiry. ";
$status .= "If you need more assistance or have questions, please call us at <b>1234567</b><br><br>";
$status .= "Thank You,<br><b>Owner</b><br>";
}}
?>
<table width="860" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="325">
<? include('inc_sideBar.php'); ?>
</td>
<td width="535">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<? include('inc_header.php'); ?>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td align="center" valign="top">
<? if(!$status){ ?>
<br>
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<form name="form" method="post" action="<? echo $PHP_SELF; ?>">
<td>
<? if(sizeof($error)){ ?>
<font color="#FADE82"><b> The following fields are still
required:<br>
<?
for($i = 0; $i < sizeof($error); $i++) {
echo " *", " ", $error[$i];
}
?>
</b></font><br>
<br>
<? } ?>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="54%" valign="top"><font color="#FFF9DD">Name</font><font color="#CC0000">
<font color="#FADE82"></font></font><b><font color="#CC0000"><font color="#FADE82">*</font><br>
<input type="text" name="c_name" value="<? echo $c_name; ?>" size="23">
</font></b></td>
<td width="46%" valign="top"><font color="#FFF9DD">State</font><b><br>
</b>
<select name="c_state">
<option>
<? echo $c_state; ?>
</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="DC">Washington, D.C.</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
</td>
</tr>
<tr>
<td valign="top" width="54%"><font color="#FFF9DD">E-mail</font><font color="#CC0000">
<font color="#FADE82"></font></font><b><font color="#CC0000"><font color="#FADE82">*</font>
<br>
<input type="text" name="email" value="<? echo $email; ?>" size="23">
</font></b></td>
<td valign="top" width="46%"><font color="#FFF9DD">Zip</font><b><br>
</b>
<input type="text" name="c_zip" value="<? echo $c_zip; ?>" size="20">
</td>
</tr>
<tr>
<td valign="top" width="54%"><font color="#FFF9DD">Address</font><b><br>
<input type="text" name="c_address" value="<? echo $c_address; ?>" size="23">
</b></td>
<td valign="top" width="46%"><font color="#FFF9DD">Phone</font><b><br>
</b>
<input type="text" name="c_phone" value="<? echo $c_phone; ?>" size="20">
</td>
</tr>
<tr>
<td valign="top" width="54%"><font color="#FFF9DD">City</font><b><br>
<input type="text" name="c_city" value="<? echo $c_city; ?>" size="23">
</b></td>
<td valign="top" width="46%"><font color="#FFF9DD">Fax</font><b><br>
</b>
<input type="text" name="c_fax" value="<? echo $c_fax; ?>" size="20">
</td>
</tr>
<tr>
<td valign="top" width="54%"> </td>
<td valign="top" width="46%"> </td>
</tr>
<tr>
<td valign="top" colspan="2"> <font color="#FFF9DD">Comments
or Questions?:</font><br>
<textarea name="c_comments" wrap="VIRTUAL" cols="30" rows="5"><? echo $c_comments; ?></textarea>
<br>
<br>
</td>
</tr>
<tr>
<td valign="top" colspan="2">
<input type="image" border="0" name="imageField" src="images/submit.gif" class="select">
</td>
</tr>
</table>
<input type="hidden" name="form" value="one">
</td>
</form>
</tr>
</table>
<? }else{ ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> <br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<font color="#FFF9DD"><? echo $status; ?></font>
</td>
</tr>
</table>
</td>
</tr>
</table>
<? } ?>
</td>
</tr>
</table>
<br>
<? include('footer_info.php'); ?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<? require('inc_footer.php'); ?>

You should access the form data using the $_POST array.
Read the Warning in this page of the php docs: http://www.php.net/manual/en/language.variables.predefined.php

Related

upload file on three drop down selected values using php

I want to upload file on specific of selection from three dropdown menus.
For example:
if course (vfx), faculty (john), assignment (1) selected then on submit file should be uploaded to specific folder or location.
Thank You.
<form action="" method="post" enctype="multipart/form-data">
<table width="1561" height="1441" border="0" align="center">
<tr>
<td height="505" align="center" valign="middle">
<table width="500" border="0" align="center">
<tbody>
<tr>
<td height="42" align="left"> </td>
<td colspan="2" align="left" valign="middle"><img src="download.jfif" width="167" height="151" alt="" /></td>
</tr>
<tr>
<td height="42" align="left">Course</td>
<td align="left" valign="middle">:</td>
<td align="left" valign="middle">
<select name="Course" size="0" required="required" id="Course">
<option disabled selected>Select</option>
<option value="animation">Animation</option>
<option value="vfx">Vfx</option>
<option value="graphic">Graphic Design</option>
<option value="first">F.y. Bsc</option>
<option value="second">S.y.Bsc</option>
<option value="third">T.y.Bsc</option>
</select>
</td>
</tr>
<tr>
<td width="128" height="31" align="left">Assignment No.</td>
<td width="27" align="left" valign="middle">:</td>
<td width="331" align="left" valign="middle">
<select name="assignment" size="0" required id="assignment">
<option disabled selected>Select</option>
<option value="one">Assignment 1</option>
<option value="two">Assignment 2</option>
<option value="three">Assignment 3</option>
<option value="four">Assignment 4</option>
<option value="five">Assignment 5</option>
<option value="six">Assignment 6</option>
<option value="seven">Assignment 7</option>
<option value="eight">Assignment 8</option>
<option value="nine">Assignment 9</option>
<option value="ten">Assignment 10</option>
</select>
</td>
</tr>
<tr>
<td height="38" align="left">Faculty</td>
<td align="left" valign="middle">:</td>
<td align="left" valign="middle">
<select name="Faculty" size="0" required id="Faculty">
<option disabled selected>Select</option>
<option value="john">john</option>
<option value="andrew">andrew</option>
<option value="juli">juli</option>
<option value="parkar">parkar</option>
<option value="other">Other</option>
</select>
</td>
</tr>
First of all you have to create the form element around your form, if you have already created then I am considering its method to be POST and considering the button name is btn and the code for your problem is as follows :
<?php
//Enter your code here, enjoy!
if(isset($_POST['btn']) )
{
// getting the values from the form
$courseValue = $_POST['Course'];
$assignment = $_POST['assignment'];
$faculty = $_POST['Faculty'];
// condition to check for file uploading
if($courseValue =="vfx" && $assignment == "1" && $faculty == "john")
{
// code to upload file or some other actions
}
}

How to print in newline in php?

Hello freinds i am unable to print in newline after clicking submit form i am getting all the data in a same row even I have used "\r\n", here is my MWE for html coding
<html>
<head>
<script type="text/javascript" src="validate.js"></script>
</head>
<body>
<form name="StudentRegistration" action="proces.php" method="post">
<table cellpadding="2" width="20%" bgcolor="99FFFF" align="center" cellspacing="2">
<tr>
<td colspan=2>
<center><font size=4><b>Student Registration Form</b></font></center>
</td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td>Name</td>
<td><input type=text name=textnames id="textname" size="30"></td>
</tr>
<tr>
<td>Father Name</td>
<td><input type="text" name="fathername" id="fathername" size="30"></td>
</tr>
<tr>
<td>Mother Name</td>
<td><input type="text" name="mothername" id="mothername" size="30"></td>
</tr>
<tr>
<td>Institute</td>
<td><select name="institute">
<option value=" " selected>Select..</option>
<option value="Institute-1">Institute-1</option>
<option value="Institute-2">Institute-2</option>
</select></td>
</tr>
<td>Category</td>
<td><select name="category">
<option value=" " selected>Select..</option>
<option value="Regular">Regular</option>
<option value="Private">Private</option>
</select></td>
</tr>
<tr>
<td>Sex</td>
<td><input type="radio" name="sex" value="Male" size="10">Male
<input type="radio" name="sex" value="Female" size="10">Female</td>
</tr>
<td>Stream</td>
<td><select name="stream">
<option value=" " selected>Select..</option>
<option value="ARTS">ARTS</option>
<option value="COMMERCE">COMMERCE</option>
<option value="SCIENCE">SCIENCE</option>
</select></td>
</tr>
<tr>
<td>Core-1</td>
<td><select name="core-1">
<option value=" " selected>Select..</option>
<option value="ENGL">English</option>
</select></td>
</tr>
<tr>
<td>Core-2</td>
<td><select name="core-2">
<option value=" " selected>Select..</option>
<option value="ALTE">Alternative English</option>
</select></td>
</tr>
<tr>
<td>Elective-1</td>
<td><select name="elective-1">
<option value=" " selected>Select..</option>
<option value="HIST">History</option>
<option value="LOPH">Logic & Philosophy</option>
<option value="MATH">Mathematics</option>
<option value="MBEN">MIL (Bengali)</option>
<option value="MBOD">MIL (Bodo)</option>
<option value="MHIN">MIL (Hindi)</option>
<option value="MNEP">MIL (Nepali)</option>
<option value="PHYS">Physics</option>
<option value="POSC">Political Science</option>
<option value="SOCI">Sociology</option>
<option value="STAT">Statistics</option>
</select></td>
</tr>
<tr>
<td>Elective-2</td>
<td><select name="elective-2">
<option value=" " selected>Select..</option>
<option value="HIST">History</option>
<option value="LOPH">Logic & Philosophy</option>
<option value="MATH">Mathematics</option>
<option value="MBEN">MIL (Bengali)</option>
<option value="MBOD">MIL (Bodo)</option>
<option value="MHIN">MIL (Hindi)</option>
<option value="MNEP">MIL (Nepali)</option>
<option value="PHYS">Physics</option>
<option value="POSC">Political Science</option>
<option value="SOCI">Sociology</option>
<option value="STAT">Statistics</option>
</select></td>
</tr>
<tr>
<td>Elective-3</td>
<td><select name="elective-3">
<option value=" " selected>Select..</option>
<option value="HIST">History</option>
<option value="LOPH">Logic & Philosophy</option>
<option value="MATH">Mathematics</option>
<option value="MBEN">MIL (Bengali)</option>
<option value="MBOD">MIL (Bodo)</option>
<option value="MHIN">MIL (Hindi)</option>
<option value="MNEP">MIL (Nepali)</option>
<option value="PHYS">Physics</option>
<option value="POSC">Political Science</option>
<option value="SOCI">Sociology</option>
<option value="STAT">Statistics</option>
</select></td>
</tr>
<tr>
<td>Elective-4</td>
<td><select name="elective-4">
<option value=" " selected>Select..</option>
<option value="HIST">History</option>
<option value="LOPH">Logic & Philosophy</option>
<option value="MATH">Mathematics</option>
<option value="MBEN">MIL (Bengali)</option>
<option value="MBOD">MIL (Bodo)</option>
<option value="MHIN">MIL (Hindi)</option>
<option value="MNEP">MIL (Nepali)</option>
<option value="PHYS">Physics</option>
<option value="POSC">Political Science</option>
<option value="SOCI">Sociology</option>
<option value="STAT">Statistics</option>
</select></td>
</tr>
<tr>
<td>Compulsory</td>
<td><select name="compulsory">
<option value=" " selected>Select..</option>
<option value="ENVE">Environmental Education</option>
</select></td>
</tr>
<tr>
<td><input type="reset"></td>
<td colspan="2"><input type="submit" value="Submit Form" /></td>
</tr>
</table>
</form>
</body>
</html>
Here is MWE for php for exporting data to .csv file to save data, I want for every each Submit Form i want to print data in newlines
<?php
$fieldAA = $_POST[" "];
$fieldA = $_POST["textnames"];
$fieldB = $_POST["fathername"];
$fieldC = $_POST["mothername"];
$fieldD = $_POST["institute"];
$fieldE = $_POST["category"];
$fieldF = $_POST["sex"];
$fieldG = $_POST["stream"];
$fieldH = $_POST["core-1"];
$fieldI = $_POST["core-2"];
$fieldJ = $_POST["elective-1"];
$fieldK = $_POST["elective-2"];
$fieldL = $_POST["elective-3"];
$fieldM = $_POST["elective-4"];
$fieldN = $_POST["compulsory"];
$keys = array($fieldAA,$fieldA,$fieldB,$fieldC,$fieldD,$fieldE,$fieldF,$fieldG,$fieldH,'','',$fieldI,'','',$fieldJ,'','',$fieldK,'','',$fieldL,'','',$fieldM,'','',$fieldN,''); //THIS IS WHERE YOU PUT THE FORM ELEMENTS ex: array('$fieldA','$fieldB',etc)
$csv_line = $keys;
foreach( $keys as $key ){
array_push($csv_line,'' . $_GET[$key]);
}
$fname = 'data.csv'; //NAME OF THE FILE
$csv_line = implode(',',$csv_line);
if(!file_exists($fname)){$csv_line = "\r\n" . $csv_line ;}
$fcon = fopen($fname,'a');
$fcontent = $csv_line ;
fwrite($fcon,$csv_line);
fclose($fcon);
echo "Successfully done! $keys[1]"
?>
In php we can use the PHP_EOL to echo out the end of a line, using this method will not rely on the current document(s)/platforms line endings.
Example:-
$string = "I want a new line here" . PHP_EOL . "This is my new line";
Line breaks in csvs are dependent on what you use to view them also.
Also you probably want to explain what MWE means in your question.

Echo data in same form after submitting

I have a simple html form, which is included in a Spry Tabbed Panel.
So, i would like to know, is it possible to submit that form, and only that form in the Panel, and then echo the submitted data back in the correct fields.
The echo part is not a problem doing it on a different page, or redirect after submitting, but my issue comes in with the other forms that should/can not be cleared if this one is submitted.
A hint in the right direction would be greatly appreciated!
Thank you in advance.
see code below:
(i know that the form action should not direct to a different file, but that is just how I've been using it until now...)
<form action="caller_upd.php" method="post" name="contact" >
<table width="200" border="0">
<?php
$_SESSION['uid'] = $uid;
?>
<tr>
<td width="68">Title</td>
<td width="4">:</td>
<td width="144"><select name="title" id="title">
<option selected="selected" disabled="disabled"</option>
<option value="Mr">Mr</option>
<option value="Ms">Ms</option>
<option value="Dr">Dr</option>
</select></td>
<td width="6"> </td>
<td width="53">Number</td>
<td width="3">:</td>
<td width="301"><input style="color:rgb(255,0,0);" autofocus="autofocus" type="text" name="contactnr" id="contactnr" /></td>
</tr>
<tr>
<td>Name</td>
<td>:</td>
<td><input type="text" name="fname" id="fname" /></td>
<td> </td>
<td>Surname</td>
<td>:</td>
<td><input type="text" name="sname" id="sname" /></td>
</tr>
<tr>
<td>Nature of Call</td>
<td>:</td>
<td><select name="type" id="type">
<option disabled="disabled" selected="selected"></option>
<option value="Domestic">Domestic</option>
<option value="MVA">MVA</option>
<option value="Assult">Assult</option>
<option value="Padestrian">Padestrian</option>
<option value="Transfer">Transfer</option>
<option value="Private">Private</option>
</select></td>
<td> </td>
<td>Nr of Patients:</td>
<td>:</td>
<td><select name="nop" id="nop">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10+">10+</option>
</select></td>
</tr>
<tr>
<td>Location</td>
<td><label for="location"></label></td>
<td colspan="5"><input name="location" type="text" id="location" size="50" /> <?php if (!empty($location)){ ?>Show Map<?php } else { } ; ?></td>
</tr>
<tr>
<td>Comments:</td>
<td colspan="6"><textarea name="comment" id="comment" cols="70" rows="5"></textarea></td>
</tr>
<tr>
<td colspan="7" class="form"><input type="submit" name="submit" id="submit" value="Update" /></td>
</tr>
</table>
</form>
Check if the post value exists, and if so either select the option or put the value in the input element...
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="contact" >
<table width="200" border="0">
<tr>
<td width="68">Title</td>
<td width="4">:</td>
<td width="144"><select name="title" id="title">
<option value="Mr" <?php if(isset($_POST['title']) && $_POST['title'] == "Mr") echo "selected"; ?>>Mr</option>
<option value="Ms" <?php if(isset($_POST['title']) && $_POST['title'] == "Ms") echo "selected"; ?>>Ms</option>
<option value="Dr" <?php if(isset($_POST['title']) && $_POST['title'] == "Dr") echo "selected"; ?>>Dr</option>
</select></td>
<td width="6"> </td>
<td width="53">Number</td>
<td width="3">:</td>
<td width="301"><input style="color:rgb(255,0,0);" autofocus="autofocus" type="text" name="contactnr" id="contactnr" value="<?php if(isset($_POST['contactnr'])) echo $_POST['contactnr']; ?>" /></td>
</tr>
<tr>
<td>Name</td>
<td>:</td>
<td><input type="text" name="fname" id="fname" value="<?php if(isset($_POST['fname'])) echo $_POST['fname']; ?>" /></td>
<td> </td>
<td>Surname</td>
<td>:</td>
<td><input type="text" name="sname" id="sname" value="<?php if(isset($_POST['sname'])) echo $_POST['sname']; ?>" /></td>
</tr>
...
</table>
</form>

JavaScript to Post PHP action

My below code is posting at both times when the checkbox is checked or not checked. When its not checked I am getting alert and then posting. But when checked its posting automatically.
I need JavaScript to post the form when Submit button is clicked and checkbox should be kept checked. Else it should just provide me an alert. But unfortunately the page is reloading even when keeping the checkbox unchecked and using submit button.
My code is
<script type="text/javascript">
function check()
{
if(document.getElementById("privacy").checked == true)
{
document.print.submit();
}
else{
alert('Please read and accept our privacy statments to proceed.');
};
}
</script>
</head>
<body>
<form id="print" action="printfile.php">
<div id="express">
<table width="800">
<tr>
<td colspan="2"><span style="color:#FF0000; font-size:26px;">Express Application</span></td>
</tr>
<tr>
<td width="300"> </td>
<td width="500"> </td>
</tr>
<tr>
<td>First Name (Required) </td>
<td><input name="firstname" type="text" size="30"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Last Name </td>
<td><input name="lastname" type="text" size="30"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Email (Required) </td>
<td><input name="email" type="text" id="email" size="30"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Purpose of finance (Required) </td>
<td><select name="purpose" id="purpose">
<option selected="selected">Home Loan</option>
<option>Refinance</option>
<option>Investment Loan</option>
<option>Debit Consolidation</option>
<option>Others</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Your deposit amount </td>
<td><input name="depositamount" type="text" size="30"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Amount you need to borrow? </td>
<td><input name="borrowamount" type="text" size="30"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Brief description of purpose of <br />
finance (Required) <br />
<br />
<br />
<br />
<br />
<br /></td>
<td><textarea name="purposedesc" cols="60" rows="10" id="purposedesc"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Application Type<br />
<br /></td>
<td><label>
<input type="radio" name="apptype" value="Single" onclick="document.getElementById('singleapp').style.visibility = 'visible'; document.getElementById('jointapp').style.visibility = 'hidden';" />
Single Application</label>
<br />
<label>
<input type="radio" name="apptype" value="Joint" onclick="document.getElementById('singleapp').style.visibility = 'visible'; document.getElementById('jointapp').style.visibility = 'visible';" />
Joint Application</label></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2"><input name="privacy" type="checkbox" id="privacy" value="checkbox" />
Privacy Act (Required) <br />
<br />
I have read the Privacy Act 1988 (as Amended) and understand that by selecting the submit button I/we authorise Best Aussie Broker to act on my/our behalf and manage personal information in relation to this application. </td>
</tr>
</table>
<br />
Last step then we will get all listed Australian vendors to fight it out for your best deal.<br />
<br />
<table width="800" border="0" style="">
<tr>
<td width="400">
<div id="singleapp">
<table width="400" border="0">
<tr>
<td colspan="2" bgcolor="#333300"><span class="style1">Your application </span></td>
</tr>
<tr>
<td width="150"> </td>
<td width="240"> </td>
</tr>
<tr>
<td>Date of Birth</td>
<td><select name="day1" id="day1">
<option selected="selected">1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
<select name="month1" id="month1">
<option selected="selected">Jan</option>
<option>Feb</option>
<option>Mar</option>
<option>Apl</option>
<option>May</option>
<option>Jun</option>
<option>Jul</option>
<option>Aug</option>
<option>Sep</option>
<option>Oct</option>
<option>Nov</option>
<option>Dec</option>
</select>
<input name="year1" type="text" id="year1" style="padding:1.2px;" size="8" maxlength="4" /> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Address</td>
<td><input name="address1" type="text" id="address1" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Suburb</td>
<td><input name="suburb1" type="text" id="suburb1" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>PostCode</td>
<td><input name="postcode1" type="text" id="postcode1" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>State</td>
<td><select name="state1" id="state1">
<option value="Victoria" selected="selected">VIC</option>
<option value="New South Wales">NSW</option>
<option value="QueensLand">QLD</option>
<option value="South Australia">SA</option>
<option value="Western Australia">WA</option>
<option value="Tasmania">TAS</option>
<option value="New Zeland">NZ</option>
<option value="Other">Other</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Best contact </td>
<td><select name="phone1" id="phone1">
<option>Phone</option>
<option>Email</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Phone number </td>
<td><input name="number1" type="text" id="number1" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Marital status </td>
<td><select name="maried1" id="maried1">
<option>Single</option>
<option>Married</option>
<option>Other</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Residential status </td>
<td><select name="rstatus1" id="rstatus1">
<option selected="selected">Renting</option>
<option>Home Owner</option>
<option>Home Mortgaged</option>
<option>Board</option>
<option>Other</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Children/dependents</td>
<td><select name="childs1" id="childs1">
<option value="0" selected="selected">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6 or more">6 or more</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Net income </td>
<td><input name="netincome1" type="text" id="netincome1" size="10"/>
per
<select name="months1" id="months1">
<option>Month</option>
<option>Year</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Current employer </td>
<td><input name="cemployer1" type="text" id="cemployer1" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Time at this<br />
employer </td>
<td> Years
<select name="years1" id="years1">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="More">More</option>
</select>
Months
<select name="emonth1" id="emonth1">
<option value="0" selected="selected">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input name="submit" type="submit" value="Submit my Application" onclick="check();" /></td>
</tr>
</table>
</div>
</td>
<td width="400">
<div id="jointapp">
<table width="400" border="0">
<tr>
<td colspan="2" bgcolor="#333300"><span class="style1">Your partner's application </span></td>
</tr>
<tr>
<td width="150"> </td>
<td width="240"> </td>
</tr>
<tr>
<td>Date of Birth</td>
<td><select name="day11" id="day11">
<option selected="selected">1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
<select name="month11" id="month11">
<option selected="selected">Jan</option>
<option>Feb</option>
<option>Mar</option>
<option>Apl</option>
<option>May</option>
<option>Jun</option>
<option>Jul</option>
<option>Aug</option>
<option>Sep</option>
<option>Oct</option>
<option>Nov</option>
<option>Dec</option>
</select>
<input name="year2" type="text" size="8" maxlength="4" style="padding:1.2px;" /> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Address</td>
<td><input name="address12" type="text" id="address12" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Suburb</td>
<td><input name="suburb12" type="text" id="suburb12" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>PostCode</td>
<td><input name="postcode12" type="text" id="postcode12" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>State</td>
<td><select name="state12" id="state12">
<option value="Victoria" selected="selected">VIC</option>
<option value="New South Wales">NSW</option>
<option value="QueensLand">QLD</option>
<option value="South Australia">SA</option>
<option value="Western Australia">WA</option>
<option value="Tasmania">TAS</option>
<option value="New Zeland">NZ</option>
<option value="Other">Other</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Best contact </td>
<td><select name="phone11" id="phone11">
<option>Phone</option>
<option>Email</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Phone number </td>
<td><input name="number11" type="text" id="number11" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Marital status </td>
<td><select name="married12" id="married12">
<option>Single</option>
<option>Married</option>
<option>Other</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Residential status </td>
<td><select name="rstatus12" id="rstatus12">
<option selected="selected">Renting</option>
<option>Home Owner</option>
<option>Home Mortgaged</option>
<option>Board</option>
<option>Other</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Children/dependents</td>
<td><select name="childs12" id="childs12">
<option value="0" selected="selected">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6 or more">6 or more</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Net income </td>
<td><input name="netincome12" type="text" id="netincome12" size="10"/>
per
<select name="months12" id="months12">
<option>Month</option>
<option>Year</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Current employer </td>
<td><input name="cemployer12" type="text" id="cemployer12" size="20"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Time at this<br />
employer </td>
<td> Years
<select name="years12" id="years12">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="More">More</option>
</select>
Months
<select name="emonths12" id="emonths12">
<option value="0" selected="selected">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select></td>
</tr>
</table>
<br />
<br />
<br />
<br />
<br />
</div>
</td>
</tr>
</table>
<p><br />
<br />
<center>
</center>
<br />
</p>
</div>
</form>
With the inline event handler syntax you're using it is easiest to return false so the default action (the submitting) isn't executed:
<input name="submit"
type="submit"
value="Submit my Application"
onclick="check(); return false;" />
You need to make the submit return false, otherwise it will just do the regular thing a form does when you click submit.
if(document.getElementById("privacy").checked == true)
{
document.print.submit();
}
else
{
alert('Please read and accept our privacy statments to proceed.');
return false;
}
Technically as it will be submitting anyway. You could just get it to check and only intercept if it is not checked.
if(document.getElementById("privacy").checked == false)
{
alert('Please read and accept our privacy statments to proceed.');
return false;
}
Also add return to the submit onclick (link #AndreKR said)
<input name="submit" type="submit" value="Submit my Application" onclick="return check();" />

Problem with Http redirect using HTML meta tags

please see the following code
// redirect to success page
if ($success){
header( 'Location: ../Scripts/_lib/phpmailer-fe.php');
}
else{
print "<meta http-equiv="refresh" content="0;URL=error.html">";
}
its not working
<form method="post" action="" enctype="multipart/form-data" name="quest">
<input type="hidden" value="valvedevelopertool.html" name="referer">
<table cellspacing="0" cellpadding="0"width="650" align="center">
<tr class="tablerow">
<td id="apptitlebox" colspan="2"><span class="valvedevelopertitle">Valve Specification Developer Tool</span></td></tr>
</table>
<br /><br />
<p align="center">Please enter known details to help assist us in processing your enquiry accuratly and quickly.</p>
<table cellspacing="0" cellpadding="0" width="650" align="center" class="tablecontainer">
<tr>
<td class="valvedevelopertoolreftitle">Reference</td><td><input type="text" style="width:204px" class="border" name="vdt_ref"/></td><td class="valvedevelopertoolreftitle">Date</td><td><input type="text" style="width:204px" class="border" name="vdt_date"/></td>
</tr>
</table>
<br />
<table cellspacing="0" cellpadding="0" width="650" align="center" class="tablecontainer">
<tr><td class="valvedevelopertoolreftitle">Enquiry 1</td></tr>
<tr class="tablerow">
<td width="154" class="titlebg"></td><td width="243" class="valvedevelopertooltexttitle titlebg">Select Known Specifications</td><td width="99" class="valvedevelopertooltexttitle titlebg"></td>
<td width="252" class="valvedevelopertooltexttitle titlebg">Add More Detail</td>
</tr>
<tr class="tablerow">
<td class="valvedevelopertoolleft">Qty</td>
<td class="valvedevelopertooltext">
<select name="vdt_qty" id="Type" class="border" style="width:204px" onchange="qty1(document.quest.vdt_qty.value); qty2(document.quest.vdt_qty.value)">
<option selected value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="otherqty">Other (specify to the right)</option>
</select>
</td>
<td class="valvedevelopertoolextratext"><span id="otherqtytitle" class="border"></span></td>
<td class="valvedevelopertooltext"><span id="otherqty" class="border"></span>
</td>
</tr>
<tr class="tablerow">
<td class="valvedevelopertoolleft highlight1">Type</td>
<td class="valvedevelopertooltext highlight1">
<select name="vdt_type" id="vdt_type" class="border" style="width:204px" onchange="type1(document.quest.vdt_type.value); type2(document.quest.vdt_type.value)">
<option selected value="">Please Select</option>
<option value="PSV">PSV (Pressure Safety/Relief Valve)</option>
<option value="Controll Valve">Control Valve</option>
<option value="Ball Valve">Ball Valve</option>
<option value="Wedge Gate Valve">Wedge Gate Valve</option>
<option value="Parallel Slide Gate Valve">Parallel Slide Gate Valve</option>
<option value="Through Conduit Gate Valve">Through Conduit Gate Valve</option>
<option value="Knife Gate Valve">Knife Gate Valve</option>
<option value="Globe Valve">Globe Valve</option>
<option value="checkvalve">Check Valve</option>
<option value="Plug Valve">Plug Valve</option>
<option value="Choke Valve">Choke Valve</option>
<option value="Butterfly Valve">Butterfly Valve</option>
<option value="Needle Valve">Needle Valve</option>
<option value="Double Block/Bleed Valve">Double Block / Bleed Valve</option>
<option value="3 Way Valve">3 Way Valve</option>
<option value="4 Way Valve">4 Way Valve</option>
</select></td>
<td class="valvedevelopertoolextratext highlight1"><span id="checkvalvetypetitle" class="border"></span></td>
<td class="valvedevelopertooltext highlight1"><span id="checkvalvetype" class="border"></span></td>
</tr>
<tr class="tablerow">
<td class="valvedevelopertoolleft">Size</td>
<td class="valvedevelopertooltext">
<select name="vdt_size" id="Type" class="border" style="width:204px" onchange="size1(document.quest.vdt_size.value); size2(document.quest.vdt_size.value)">
<option selected value="">Please Select</option>
<option value="0.5">0.5"</option>
<option value="1">1"</option>
<option value="1.5">1.5"</option>
<option value="2">2"</option>
<option value="4">4"</option>
<option value="6">6"</option>
<option value="8">8"</option>
<option value="10">10"</option>
<option value="12">12"</option>
<option value="14">14"</option>
<option value="16">16"</option>
<option value="18">18"</option>
<option value="20">20"</option>
<option value="24">24"</option>
<option value="30">30"</option>
<option value="36">36"</option>
<option value="40">40"</option>
<option value="othersize">Other (specify to the right)</option>
</select>
</td>
<td class="valvedevelopertoolextratext"><span id="othersizetitle" class="border"></span></td>
<td class="valvedevelopertooltext"><span id="othersize" class="border"></span></td>
</tr>
<tr class="tablerow">
<td class="valvedevelopertoolleft highlight1">Pressure Class</td>
<td class="valvedevelopertooltext highlight1">
<select name="vdt_class" onchange="class1(document.quest.vdt_class.value); class2(document.quest.vdt_class.value)" class="border" style="width:204px">
<option value="">Please Select</option>
<option value="ANSI">ANSI</option>
<option value="PN">PN</option>
<option value="API">API</option>
</select>
</td>
<td class="valvedevelopertoolextratext highlight1" align="right"><span id="classname" class="border"></span></td>
<td class="valvedevelopertooltext highlight1"><span id="classtypes" class="border"></span></td>
</tr>
<tr class="tablerow">
<td class="valvedevelopertoolleft">End Connections</td>
<td class="valvedevelopertooltext">
<select name="vdt_end" id="Type" class="border" style="width:204px">
<option selected value="">Please Select</option>
<option value="Flanged Raised Face">Flanged Raised Face</option>
<option value="Flanged Flat Face">Flanged Flat Face</option>
<option value="Flanged Ring Type Joint">Flanged Ring Type Joint</option>
<option value="Socket Weld Female">Socket Weld Female</option>
<option value="Socket Weld Male">Socket Weld Male</option>
<option value="Screwed Female">Screwed Female</option>
<option value="Screwed Male">Screwed Male</option>
</select>
</td>
<td class="valvedevelopertooltext"> </td>
<td class="valvedevelopertooltext"> </td>
</tr>
<tr class="tablerow">
<td class="valvedevelopertoolleft highlight1">Bore</td>
<td class="valvedevelopertooltext highlight1">
<select name="vdt_bore" id="Type" class="border" style="width:204px">
<option selected value="">Please Select</option>
<option value="Full">Full</option>
<option value="Reduced">Reduced</option>
</select>
</td>
<td class="valvedevelopertooltext highlight1"> </td>
<td class="valvedevelopertooltext highlight1"> </td>
</tr>
<tr class="tablerow">
<td class="valvedevelopertoolleft">Body Material</td>
<td class="valvedevelopertooltext">
<select name="vdt_body" id="Type" class="border" style="width:204px" onchange="body1(document.quest.vdt_body.value); body2(document.quest.vdt_body.value)">
<option selected value="">Please Select</option>
<option value="Carbon Steel">Carbon Steel</option>
<option value="Stainless Steel">Stainless Steel</option>
<option value="Duplex">Duplex</option>
<option value="Alloy">Alloy</option>
<option value="Bronzes">Bronzes</option>
<option value="Leaded Gunmetal">Leaded Gunmetal</option>
<option value="Low Temp Nickel Alloy Steel">Low Temp Nickel Alloy Steel</option>
<option value="Titanium">Titanium</option>
<option value="Hastelloy">Hastelloy</option>
<option value="Monel">Monel</option>
<option value="Cast Iron">Cast Iron</option>
</select>
</td>
<td class="valvedevelopertoolextratext"><span id="bodytitle" class="border"></span></td>
<td class="valvedevelopertooltext"><span id="bodytypes" class="border"></span></td>
</tr>
<tr class="tablerow">
<td class="valvedevelopertoolleft highlight1">Trim Material</td>
<td class="valvedevelopertooltext highlight1">
<select name="vdt_trim" id="Type" class="border" style="width:204px" onchange="trim1(document.quest.vdt_trim.value); trim2(document.quest.vdt_trim.value)">
<option selected value="">Please Select</option>
<option value="Carbon Steel">Carbon Steel</option>
<option value="Stainless Steel">Stainless Steel</option>
<option value="Duplex">Duplex</option>
<option value="Alloy">Alloy</option>
<option value="13% Chrome Steel">13% Chrome Steel</option>
<option value="Bronze and Aluminium Bronze">Bronze & Aluminium Bronze</option>
<option value="Nickel Aluminium Bronze">Nickel Aluminium Bronze</option>
<option value="Leaded Gunmetal">Leaded Gunmetal</option>
<option value="Titanium">Titanium</option>
<option value="Low Temp Nickel Alloy Steel">Low Temp Nickel Alloy Steel</option>
<option value="Monel">Monel</option>
<option value="Cast Iron">Cast Iron</option>
<option value="Ceramics">Ceramics</option>
</select>
</td>
<td class="valvedevelopertoolextratext highlight1"><span id="trimtitle" class="border"></span></td>
<td class="valvedevelopertooltext highlight1"><span id="trimtypes" class="border"></span></td>
</tr>
<tr class="tablerow">
<td class="valvedevelopertoolleft">Seat Material</td>
<td class="valvedevelopertooltext">
<select name="vdt_seat" id="Type" class="border" style="width:204px" onchange="seat1(document.quest.vdt_seat.value); seat2(document.quest.vdt_seat.value)">
<option selected value="">Please Select</option>
<option value="PTFE">PTFE</option>
<option value="Nylon">Nylon</option>
<option value="Peek">Peek</option>
<option value="Viton">Viton</option>
<option value="Metal">Metal</option>
</select>
</td>
<td class="valvedevelopertoolextratext" align="right"><span id="seatgradetitle" class="border"></span></td>
<td class="valvedevelopertooltext"><span id="seatgrade" class="border"></span></td>
</tr>
<tr class="tablerow">
<td class="valvedevelopertoolleft highlight1">NACE Materials</td>
<td class="valvedevelopertooltext highlight1">
<select name="vdt_nace" id="Type" class="border" style="width:204px">
<option selected value="">Please Select</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</td>
<td class="valvedevelopertooltext highlight1"> </td>
<td class="valvedevelopertooltext highlight1"> </td>
</tr>
<tr class="tablerow">
<td class="valvedevelopertoolleft">Operation</td>
<td class="valvedevelopertooltext">
<select name="vdt_operation" id="Type" class="border" style="width:204px" onchange="operation1(document.quest.vdt_operation.value); operation2(document.quest.vdt_operation.value)">
<option selected value="">Please Select</option>
<option value="Manual Hand Lever">Manual Hand Lever</option>
<option value="Manual Handwheel">Manual Handwheel</option>
<option value="Manual Gearbox">Manual Gearbox</option>
<option value="Automated/Actuated">Automated / Actuated</option>
<option value="otheroperation">Other (specify to the right)</option>
</select>
</td>
<td class="valvedevelopertoolextratext"><span id="otheroperationtitle" class="border"></span></td>
<td class="valvedevelopertooltext"><span id="otheroperation" class="border"></span>
</td>
</tr>
<tr>
<td class="valvedevelopertoolleft highlight1">Other Information</td>
<td class="valvedevelopertooltextarea highlight1" colspan="3" align="left" style="padding-left:23px; padding-top:3px; height:95px"><span class="valvedevelopertooltextarea highlight1" style="padding-top:3px; height:95px">
<textarea name="textarea" cols="5" rows="4" class="border" style="width:550px"></textarea>
</span></td>
</tr>
</table>
<br />
<table cellspacing="0" cellpadding="0" width="650" align="center" class="tablecontainer">
<tr class="tablerow">
<td width="154" class="titlebg"></td><td width="243" class="valvedevelopertooltexttitle titlebg">Your Details</td><td width="99" class="valvedevelopertooltexttitle titlebg"></td>
<td width="252" class="valvedevelopertooltexttitle titlebg"></td>
</tr>
<tr>
<td class="valvedevelopertoolleft" width="154">Name</td>
<td class="valvedevelopertooltext" width="243"><input name="contact_name" style=" width: 200px;" type="text" maxlength="200" class="border"></td>
<td class="valvedevelopertoolextratext" width="99"> </td>
<td class="valvedevelopertooltext" width="252"> </td>
</tr>
<tr>
<td class="valvedevelopertoolleft highlight1" width="154">Email Address</td>
<td class="valvedevelopertooltext highlight1" width="243"><input name="contact_email" style=" width: 200px;" type="text" maxlength="200" class="border"></td>
<td class="valvedevelopertoolextratext highlight1" width="99"> </td>
<td class="valvedevelopertooltext highlight1" width="252"> </td>
</tr>
<tr>
<td class="valvedevelopertoolleft" width="154">Telephone Number</td>
<td class="valvedevelopertooltext" width="243"><input name="contact_tel" style=" width: 200px;" type="text" maxlength="200" class="border"></td>
<td class="valvedevelopertoolextratext" width="99"> </td>
<td class="valvedevelopertooltext" width="252"> </td>
</tr>
<tr>
<td class="valvedevelopertoolleft highlight1" width="154">Company</td>
<td class="valvedevelopertooltext highlight1" width="243"><input name="contact_company" style=" width: 200px;" type="text" maxlength="200" class="border"></td>
<td class="valvedevelopertoolextratext highlight1" width="99"> </td>
<td class="valvedevelopertooltext highlight1" width="252"> </td>
</tr>
</table>
<br />
<table cellspacing="0" cellpadding="0" width="650" align="center" class="tablecontainer">
<tr>
<td colspan="4">
<?php
# Get the reCAPTCHA library
require_once('../recaptcha/recaptchalib.php');
# These are /not/ real keys - you must replace them with your *own* keys
# obtained from http://recaptcha.net/api/getkey
define('PUBLIC_KEY', '[MY PUBLIC KEY]');
define('PRIVATE_KEY', '[MY PRIVATE KEY]');
# Did the user fail the captcha test?
$error = null;
# This is where we process the user's response. We don't
# do this when the form is initially displayed - only
# when the user submits it.
if ($_POST["recaptcha_response_field"]) {
$response = recaptcha_check_answer(
PRIVATE_KEY, $_SERVER['REMOTE_ADDR'],
$_POST['recaptcha_challenge_field'],
$_POST['recaptcha_response_field']
);
if ( $response->is_valid ) {
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['vdt_type']));
$EmailTo = "MAIL#MAIL.COM";
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
print '<meta http-equiv="refresh" content="0;URL=error.html">';
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "n";
$Body .= "n";
$Body .= "Email: ";
$Body .= $EmailFrom;
$Body .= "n";
$Body .= "n";
$Body .= "Company: ";
$Body .= $Company;
$Body .= "n";
$Body .= "n";
$Body .= "Telephone: ";
$Body .= $Telephone;
$Body .= "n";
$Body .= "n";
$Body .= "Fax: ";
$Body .= $Fax;
$Body .= "n";
$Body .= "n";
$Body .= "Location: ";
$Body .= $Location;
$Body .= "n";
$Body .= "n";
$Body .= "How Did You Hear About Us: ";
$Body .= $HowDidYouHearAboutUs;
$Body .= "n";
$Body .= "n";
$Body .= "Enquiry Type: ";
$Body .= $EnquiryType;
$Body .= "n";
$Body .= "n";
$Body .= "Comments: ";
$Body .= $Comments;
$Body .= "n";
$Body .= "n";
$Body .= "Join Mailing List: ";
$Body .= $MailingList;
$Body .= "n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: noreply#score-training.com");
// redirect to success page
if ($success){
if (isset($_POST['submit'])) {
header ("Location: ../Scripts/_lib/phpmailer-fe.php");
}
else{
print '<meta http-equiv="refresh" content="0;URL=error.html">';
}
}
# For example
# ... validate user input ...
# ... store form data in a database ...
# ... redirect to 'thank you' page
}
else {
# The user failed the reCAPTCHA test so we need
# to fill in the error message and re-try the
# form submission
$error = $response->error;
}
}
# Display the reCAPTCHA challenge. The first time
# through $error will be null.
echo recaptcha_get_html( PUBLIC_KEY, $error );
?>
</td></tr>
<tr>
<td colspan="4" align="center"><input type="submit" value="Submit Enquiry" class="border" name="submit"> <input type="reset" value="Clear Form" class="border"></td>
</tr>
</table>
</form>
You are quoting your string in a wrong way. Encapsulate it in single quotes:
print '<meta http-equiv="refresh" content="0;URL=error.html">';
You should be able to find such errors with any editor that provides decent syntax highlighting (it can even be seen with the syntax highlighter in your question).
I don't know whether this solves the problem, you don't give enough information.
Also note that according to Wikipedia, this method of refreshing is deprecated.
If you are using HTTP 1.1, the URL provided to Location must be absolute:
Note: HTTP/1.1 requires an absolute URI as argument to ยป Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. You can usually use $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF'] and dirname() to make an absolute URI from a relative one yourself.

Categories