PDA

View Full Version : How can I change success message font size on Bootstrap Contact form?



mlegg
02-21-2017, 05:18 PM
On this page http://newfieldshome.com/contact.html I am using a responsive contact form I saw for Bootstrap. When you submit it gives you a success message from the contact.php page.

$okMessage = 'Contact form successfully submitted. Thank you, I will get back to you soon!
How can I make that message larger? This is from the contact.php page


<?php

// configure
$from = 'contact form <John@SamonasGroup.com>';
$sendTo = 'contact form <John@SamonasGroup.com>';
$subject = 'New message from contact form';
$fields = array('name' => 'Name', 'surname' => 'Surname', 'phone' => 'Phone', 'email' => 'Email', 'message' => 'Message'); // array variable name => Text to appear in the email
$okMessage = 'Contact form successfully submitted. Thank you, I will get back to you soon!';
$errorMessage = 'There was an error while submitting the form. Please try again later';

// let's do the sending

try
{
$emailText = "You have new message from contact form\n=============================\n";

foreach ($_POST as $key => $value) {

if (isset($fields[$key])) {
$emailText .= "$fields[$key]: $value\n";
}
}

$headers = array('Content-Type: text/html; charset="UTF-8";',
'From: ' . $from,
'Reply-To: ' . $from,
'Return-Path: ' . $from,
);

mail($sendTo, $subject, $emailText, implode("\n", $headers));

$responseArray = array('type' => 'success', 'message' => $okMessage);
}
catch (\Exception $e)
{
$responseArray = array('type' => 'danger', 'message' => $errorMessage);
}

if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
$encoded = json_encode($responseArray);

header('Content-Type: application/json');

echo $encoded;
}
else {
echo $responseArray['message'];
}


this is the custom css page if you need it http://www.newfieldshome.com/css/custom.css

styxlawyer
02-21-2017, 06:02 PM
That is just a text message echoed to the browser. If you want to style it you will have to enclose in an HTML page so that you can add styling.

styxlawyer
02-21-2017, 06:12 PM
Replace the last three lines of your PHP file with this:




else {
echo '<!doctype html><html lang="en"><head><title>Response page</title>';
echo '<style> .myStyle { /* Your styling goes in here */ }</style>';
echo '</head><body>';
echo '<p class="myStyle">'.$responseArray['message'].'</p>';
echo '</body></html>';
}
?>

mlegg
02-21-2017, 09:17 PM
Thank you