Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Help making button do two actions: send data and open new page

Thread Tools

Help making button do two actions: send data and open new page

jrlbandl jrlbandl is offline
Junior Member
Join Date: Jul 2009
Posts: 1
I have a contact page where I have a form setup to mail me using the mail function. It does everything it is supposed to and gives a little thanks for getting in touch by means of an echo. What I want to do now is instead of echoing the text, I want it to take the person to a completely new thanks.php page. I am a complete newbie and it is amazing that I was able to make sense of other stuff to get this to work. Please help me. It seems so simple, but everything I try doesn't work for me. Thanks. Here is all of the code that I have in the include. Oh this is php and it is in an include. Sorry.

function spamcheck($field)
//filter_var() sanitizes the e-mail
$field=filter_var($field, FILTER_SANITIZE_EMAIL);

//filter_var() validates the e-mail
if(filter_var($field, FILTER_VALIDATE_EMAIL))
return TRUE;
return FALSE;

//Begins by clearing the output variable
$output = '';

//Sets up an array of required names
$required = array('email','name','message');

//Creates an empty array to hold any errors
$errors = array();

//Check to see if the form was submitted
if (isset($_REQUEST['submit'])) {

//Breaks the required array into individual values
foreach ($required as $field) {

//If the required field is empty, adds an error message (key and value) to the error array
if (empty($_REQUEST[$field])) {

$errors[$field] = 'this is required';


//If there are no errors
if (count($errors)<1) {

//Send an email with the form data or otherwise process the form data - currently this does nothing
$to = '(E-Mail Removed)';
$subject = 'Message from BandL Contact Form';
$from = 'From: '.$_POST['email'];
$name = 'Name: '.$_POST['name'];
$company = 'Company: '.$_POST['company'];
$email = 'Email: '.$_POST['email'];
$message = 'Message:
'.wordwrap($_POST['message'], 70);

$body = "$name\n$company\n$email\n\n$message";

$break = '<br />';
$newline = "\n";
$message = str_replace($break, $newline, $message);

mail ($to, $subject, $body, $from);

$output.= '<p class="feedback">';
$output.= 'Thank you for getting in touch. We will address this as soon as possible.';
$output.= '</p>';

echo $output;


// If the form has not be submitted, if builds a string to display the form on the page
$output.= '
<form method="post" id="contactform" action="'.$_SERVER['PHP_SELF'].'"><fieldset>';

$fields = array(
'name' => 'text',
'company' => 'text',
'email' => 'text',
'message' => 'textarea'

foreach ($fields as $field => $type) {

$output.= '
<label for="'.$field.'">';
$output.= ucwords($field); //ucwords changes the text to upper-case
if (isset($errors[$field])) {
$output.= ' <strong class="error">is required</strong>';
$output.= '</label>';

switch ($type) {

case 'textarea':
$output.= '
<textarea name="'.$field.'" id="'.$field.'" cols="30" rows="10">';
if (isset($_REQUEST[$field])) {
$output.= htmlspecialchars($_REQUEST[$field]); //htmlspecialchars escapes any potentially harmful markup including < or > or \ or ' or " characters
$output.= '
</textarea><br />';

$output.= '
<input type="text" name="'.$field.'" id="'.$field.'"';
if (isset($_REQUEST[$field])) {
$output.= ' value="'.htmlspecialchars($_REQUEST[$field]).'"';
$output.= ' /><br />';



$output.= '

<input type="submit" name="submit" value="Submit" />
<br />

echo $output;

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
On Clicking on Open button in asp download dialog it open two copy ofexcell file?? chandan ASP .Net Web Controls 0 11-17-2008 08:46 AM
On Clicking on Open button in asp download dialog it open two copy ofexcell file?? chandan ASP .Net 0 11-17-2008 08:44 AM
Master Page Button and Detail Page Button Mark Olbert ASP .Net 4 02-03-2006 12:27 AM
Making new Flavors : Making a custom transferhandler for and drop applications Java 5 01-12-2005 11:10 AM
submit form data and open a new page is not necessary replace the existing page Matt ASP General 1 05-29-2004 03:32 AM