0

I created an and I can not style it.. The problem I have is that the form I wiant to show in the email shows up right on top of form and it won't reveal in email with the inputs displaying?

Can someone give me some sources/assistance/snippets/etc. for this?

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by <M/>
0

Sorry guys, here is my code if you need it in order to assist me:

<?php

$fn = $_POST['fn'];
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$comments = $_POST['comments'];

mail($to, $subject, $message, $headers);

$to = "email@gmail.com";

$subject = "Form Submission";

    $headers = "From: " . strip_tags($_POST["req-email"]) . "\r\n";
    $headers .= "Reply-To: ". strip_tags($_POST["req-email"]) . "\r\n";
    $headers .= "CC: email2@gmail.com\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content=Type: text/html; charset=ISO-8859-1\r\n";

    $message = "<html><body>";
    $message = "<h1>Hello, this form has been submitted!</h1>";
    $message = "</body></html>";

    $message = "<html><body>";
    $message .= '<img src= "logo.png" />';
    $message .= '<table rules="all" style="border-color: #ffb300;" cellpadding="10">';
    $message .= '<tr style="background: #ffb300;"><td><strong>Name:</strong> </td><td>' . strip_tags($_POST['req-name']) . '</td></tr>';
    $message .= '<tr><td><strong>Email:</strong> </td><td>' . strip_tags($_POST['req-email']) . '</td></tr>';
    $message .= '<tr><td><strong>Phone:</strong> </td><td>' . strip_tags($_POST['req-phone']) . '</td></tr>';
    $message .= '<tr><td><strong>Comments:</strong> </td><td>' .strip_tags($_POST['comments']) . '</td></tr>';

$message .= "</table>";
$message .= "</body></html>";

?>

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PHP Form</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="<?=$_SERVER['PHP_SELF'];?>">
<table class="formatTblClass">
<tr>
<th colspan="6"><?=$message;?></th>
</tr>
<tr>
<td width="68"><span>Name</span></td>
<td width="215"><input class="<?=$aClass;?>" type="text" name="fn" id="fn" /></td>
</tr>
<tr>
<td><span>Email</span></td>
<td><input class="<?=$aClass;?>" type="text" name="email" id="email" /></td>
</tr>
<tr>
<td><span>Phone</span></td>
<td><input class="<?=$aClass;?>" type="text" name="phone" id="phone" /></td>
</tr>
<tr>
<td colspan="6"><span>Comments
<textarea name="comments" id="comments" col="45" rows="5"></textarea>
</span>
<div align="center">
<input type="submit" name="Submit" id="Submit" value="Submit" />
</div></td>
</tr>
</table>
</form>

<?php

$fn = $_POST['fn'];
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$comments = $_POST['comments'];
//$emailMe = (isset($_POST['emailMe'])) ? $_POST['emailMe'] : 'No';

//validate
if(empty($fn) || empty($name) || empty($email) || empty($phone)){
$message = 'Fill in areas in red!';
$aClass = 'errorClass';}

$cvsData = $fn . "," . $name . "," . $email . "," . $phone . "," . $comments . "\n";

$fp = fopen("data.csv", "a" );


if($fp){
    fwrite($fp, $cvsData);
    fclose($fp);
    }
?>

</body>
</html>
0

The problem I have is that the form I wiant to show in the email shows up right on top of form and it won't reveal in email with the inputs displaying?

I dont understand what you mean by that statement.

I created an and I can not style it..
First, I noticed that you are building your email message, with more than one set of HTML and BODY elements. You should only have one set of each. You may want to delete lines 23-25.

Secondly, to style the HTML just update line 21 as follows (for example):

    $message = "<html><head>";
    $message = "<style>";
    $message = "h1 {color:#blue;}";
    $message = "table {border:1px solid black;}";
    $message = "</style></head><body>";
0

Well, what I meant to say is that the table that I want to see in the email shows up ontop of the form..

<?php
$fn = $_POST['fn'];
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$comments = $_POST['comments'];
mail($to, $subject, $message, $headers);
$to = "email@gmail.com";
$subject = "Form Submission";
    $headers = "From: " . strip_tags($_POST["req-email"]) . "\r\n";
    $headers .= "Reply-To: ". strip_tags($_POST["req-email"]) . "\r\n";
    $headers .= "CC: email2@gmail.com\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content=Type: text/html; charset=ISO-8859-1\r\n";

    $message = "<html><head>";
    $message = "<style>";
    $message = "h1 {color:#blue;}";
    $message = "table {border:1px solid black;}";
    $message = "</style></head><body>";

    $message = "<h1>Hello, this form has been submitted!</h1>";

    $message .= '<img src= "logo.png" />';
    $message .= '<table rules="all" style="border-color: #ffb300;" cellpadding="10">';
    $message .= '<tr style="background: #ffb300;"><td><strong>Name:</strong> </td><td>' . strip_tags($_POST['req-name']) . '</td></tr>';
    $message .= '<tr><td><strong>Email:</strong> </td><td>' . strip_tags($_POST['req-email']) . '</td></tr>';
    $message .= '<tr><td><strong>Phone:</strong> </td><td>' . strip_tags($_POST['req-phone']) . '</td></tr>';
    $message .= '<tr><td><strong>Comments:</strong> </td><td>' .strip_tags($_POST['comments']) . '</td></tr>';
$message .= "</table>";
$message .= "</body></html>";
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PHP Form</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="<?=$_SERVER['PHP_SELF'];?>">
<table class="formatTblClass">
<tr>
<th colspan="6"><?=$message;?></th>
</tr>
<tr>
<td width="68"><span>Name</span></td>
<td width="215"><input class="<?=$aClass;?>" type="text" name="fn" id="fn" /></td>
</tr>
<tr>
<td><span>Email</span></td>
<td><input class="<?=$aClass;?>" type="text" name="email" id="email" /></td>
</tr>
<tr>
<td><span>Phone</span></td>
<td><input class="<?=$aClass;?>" type="text" name="phone" id="phone" /></td>
</tr>
<tr>
<td colspan="6"><span>Comments
<textarea name="comments" id="comments" col="45" rows="5"></textarea>
</span>
<div align="center">
<input type="submit" name="Submit" id="Submit" value="Submit" />
</div></td>
</tr>
</table>
</form>
<?php
$fn = $_POST['fn'];
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$comments = $_POST['comments'];
//$emailMe = (isset($_POST['emailMe'])) ? $_POST['emailMe'] : 'No';
//validate
if(empty($fn) || empty($name) || empty($email) || empty($phone)){
$message = 'Fill in areas in red!';
$aClass = 'errorClass';}
$cvsData = $fn . "," . $name . "," . $email . "," . $phone . "," . $comments . "\n";
$fp = fopen("data.csv", "a" );
if($fp){
    fwrite($fp, $cvsData);
    fclose($fp);
    }
?>
</body>
</html>

This is what it looks like right now, but it looks the same as before unfortunately... Anymore solutions? But I do see what you are trying to do it makes sense, but now I have to fix what I see.

I also forgot to mention, the inputs/data that is supposed to be in the custom table don't show up in my email... can you also assist me with that?
Screen_Shot_2012-10-19_at_3.31_.49_PM_

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.