I have an html / php page with a Require statement which includes another page which includes a form. On completion of the form I use an Echo statement to display the result of the form submission to the user. That all works but I want the page to position itself at the bottom so that the user can see the message.
I've tried specifying a location (bottomOfPage) and using it in the header command, but I can't get it to work.
Can you help me out?
Mohammad, I tried incorporating your solution as follows, but it still does not scroll to botttom:
QUICK FORM<?php
if(isset($_GET['send'])) //check the submit button was pressed
//get variables from POST array. Remember we specified POST method
$fn = $_GET['firstname'];
$ln = $_GET['lastname'];
$em = $_GET['emailadd'];
$pn = $_GET['phonenum'];
$message = $fn . "\r\n" . $ln . "\r\n";
$message .= $em . "\r\n" . $pn;
$to = "trevor.reeves@webthemes.com.au";
$subject = "webThemes Contact";
//set up headers
$headers = 'From: trevor.reeves@webthemes.com.au' . "\r\n" .
'Reply-To: trevor.reeves@webthemes.com.au' . "\r\n" .
'X-Mailer: PHP/' . phpversion ();
//send the email and save the result
$result = mail ( $to, $subject, $message, $headers );
//was it sent?
if ($result) {
echo "<p>Thank you for sending the message</p>";
echo "<script>\n";
$str = "window scrollTo ( 0, document . body . scrollHeight );";
echo $str;
echo "\n</script>";
} else {
echo "<p>Sorry. An error has occurred. Please email trevor.reeves@webthemes.com.au</p>";
}
That's not the problem as the PHP script does send an email and display a message. The issue is that the scroll doesn't work:
echo "<script>\n";
$str = "window scrollTo ( 0, document . body . scrollHeight );";
echo $str;