I need my web page to auto scroll to the bottom of the page when the user submits the form. This is what I have added to accomplish that.
- header(‘Location: script.php#bottomOfPage’);
- <a name=“bottomOfPage”></a>
My question is, where do I place #1?
This is my form:
<!--START FORM-->
<?php
include('inc/config.inc');
include('inc/header.php');
// Read in options
// $ax_reCaptcha = false;
// $px_recaptcha_challenge_field = isset($_POST['recaptcha_challenge_field']) ? $_POST['recaptcha_challenge_field'] : '';
// $px_recaptcha_response_field = isset($_POST['recaptcha_response_field']) ? $_POST['recaptcha_response_field'] : '';
$nameError = "";
$emailError = "";
$phoneNumberError = "";
$commentError = "";
$sourceError = "";
// $recaptchaError = "";
// See if we're using reCaptcha
// if (isset($ax_publicKey) && $ax_publicKey != '' && isset($ax_privateKey) && $ax_privateKey != '') {
// $ax_reCaptcha = true;
// require_once('libs/recaptcha.php');
// $resp = recaptcha_check_answer ($ax_privateKey, $_SERVER['REMOTE_ADDR'], $px_recaptcha_challenge_field, $px_recaptcha_response_field);
// }
// See if form was submitted
if (isset($_POST['axMail'])) {
// Validate Name
$contactName = filter_input(INPUT_POST, 'contactName', FILTER_SANITIZE_STRING);
if ($contactName == '') {
$nameError = 'Please enter a valid name.';
$hasError = true;
}
// Validate Email
$email = filter_input( INPUT_POST, 'email', FILTER_SANITIZE_EMAIL );
// if (!filter_var( $email, FILTER_VALIDATE_EMAIL )) {
// $emailError = '' . $email . ' is <strong>NOT</strong> a valid email address.';
// $hasError = true;
// }
// Validate Phone
$phoneNumber = filter_input(INPUT_POST, 'phoneNumber', FILTER_SANITIZE_STRING);
// if ($phoneNumber == '' || empty($phoneNumber)) {
// $phoneNumberError = 'Please enter a valid phone number.';
// $hasError = true;
// }
// Validate Message
$message = filter_input( INPUT_POST, 'message', FILTER_SANITIZE_STRING);
// if ($message == '') {
// $commentError = 'Please enter a message to send.<br/>';
// $hasError = true;
// }
// Validate Address
$source = filter_input(INPUT_POST, 'source', FILTER_SANITIZE_STRING);
// if ($address == '') {
// $addressError = 'Please enter a valid address.';
// $hasError = true;
// }
// Validate reCaptcha
// if ($ax_reCaptcha && !$resp->is_valid) {
// $recaptchaError = 'The reCAPTCHA wasn\\'t entered correctly. Please try again.';
// $hasError = true;
// }
// Capture Send To Email Addy
$ax_mailTo = filter_input( INPUT_POST, 'emailTo', FILTER_SANITIZE_EMAIL);
if (!filter_var( $ax_mailTo, FILTER_VALIDATE_EMAIL )) {
$emailError = '' . $ax_mailTo . ' is <strong>NOT</strong> a valid email address.';
$hasError = true;
}
// If we didn't hit an error, send the email
if (!isset($hasError)) {
// Body:
$body = '
Name: ' . $contactName . '
Email: ' . $email . '
Phone: ' . $phoneNumber . '
Message: ' . $message . '
Source: ' . $source . '
';
// Headers
$headers = 'From: ' . $email . "\\r\
" .
'Reply-To: ' . $email . "\\r\
";
// Send it
@ini_set('sendmail_from', $email);
mail($ax_mailTo, $ax_mailSubject . ' : ' . $subject , $body, $headers);
$emailSent = true;
}
}
// Output template
echo '<div class="ax-outer">';
if (isset($emailSent) && $emailSent == true) {
echo '
<h1>Thanks, ' . $contactName . '</h1>
<p>' . $finishedtext . '</p>
';
} else {
?>
<?php /*?><?php if ($ax_reCaptcha) { ?>
<script type="text/javascript">
var RecaptchaOptions = {
theme : '<?php echo $ax_recaptchaTheme; ?>'
};
</script>
<?php } ?><?php */?>
<form action="index.php" id="ax-contactForm" method="post">
<?php if ($nameError != '') { ?>
<p class="error"><?php echo $nameError; ?></p>
<?php } ?>
<input type="text" name="contactName" id="contactName" title="name" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" value="Full Name<?php if (isset($contactName)) echo $contactName;?>" class="requiredField ax-input" />
<?php if ($emailError != '') { ?>
<p class="error"><?php echo $emailError; ?></p>
<?php } ?>
<input type="text" name="email" id="email" title="email" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" value="Email<?php if (isset($email)) echo $email;?>" class="requiredField email ax-input" />
<?php if ($phoneNumber == '') { ?>
<p class="error"><?php echo $phoneNumberError; ?></p>
<?php } ?>
<input type="text" name="phoneNumber" id="phoneNumber" title="number" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" value="Phone #<?php if (isset($phoneNumber)) echo $phoneNumber;?>" class="ax-input" />
<?php if ($commentError != '') { ?>
<p class="error"><?php echo $commentError; ?></p>
<?php } ?>
<textarea name="message" id="message" title="message" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" rows="20" cols="30" class="requiredField ax-textarea">Message<?php if (isset($message)) { if (function_exists('stripslashes')) { echo stripslashes($message); } else { echo $message; } } ?></textarea>
<?php if ($source == '') { ?>
<p class="error"><?php echo $sourceError; ?></p>
<?php } ?>
<select type="text" name="source" id="source" title="source" class="requiredField ax-input" />
<option value="">How did you find us?</option>
<?php
$choices = array('Internet','Word of Mouth','Sign','Truck','Yellowpages','Other');
foreach($choices as $choice){
if(isset($source) && $source ==str_replace(' ', '_', strtolower($choice)) ){
$selected = 'selected="selected"';
}
echo "<option ".$selected." value='".str_replace(' ', '_', strtolower($choice))."'>".$choice."</option>";
}
?>
</select>
<div style="display:none;">
<label for="emailTo" class="ax-label">Send To</label>
<select id="emailTo" name='emailTo' class="requiredField ax-select">
<?php
for($i=0; $i < count($adminemail); $i++) {
foreach($adminemail[$i] as $key => $val) {
echo '<option value="'.$key.'">'.$val.'</option>';
}
}
?>
</select>
</div>
<?php /*?>
<?php if ($ax_reCaptcha) { ?>
<?php if ($recaptchaError != '') { ?>
<p class="error"><?php echo $recaptchaError ; ?></p>
<?php } ?>
<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=<?php echo $ax_publicKey; ?>"></script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=<?php echo $ax_publicKey; ?>" height="300" width="300" frameborder="0"></iframe><br />
<textarea name="recaptcha_challenge_field" rows="3" cols="40"> </textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge" />
</noscript>
<?php } ?>
<?php */?>
<input type="hidden" name="axMail" id="axMail" value="true" />
<p><button type="submit" class="ax-button">Send Message</button></p>
</form>
<?php
}
echo '</div>';
include('inc/footer.php');
?>
Thanks!
-Sam