
Originally Posted by
Alex Mac
Please use the [code] tag to display code.
Or [html] or [php], as appropriate.
Note that, when properly indented, you can see structural problems with your code.
HTML Code:
<BODY>
<FORM METHOD="post" ACTION="send_simpleform.php">
<P><strong>Su Nombre:</strong><br>
<INPUT type="text" NAME="sender_name" SIZE=30></p>
<P><strong>Su E-Mail Address:</strong><br>
<INPUT type="text" NAME="sender_email" SIZE=30></p>
<P><strong>Mensaje:</strong><br>
<TEXTAREA NAME="message" COLS=30 ROWS=5 WRAP=virtual></TEXTAREA></p>
<P><INPUT TYPE="submit" NAME="submit" VALUE="Send This Form"></p>
</FORM>
</BODY>
</HTML>
The unclosed <input>s and use of the non-semantic <br/> should be fixed. <strong> is also misused; it's supposed to denote strong emphasis, not simply a replacement for <b>. You should be using <label> to markup input labels. If you want them to be bold, use styling.
HTML Code:
<html>
<head>
<style type="text/css">
label {
font-weight: bold;
display: block;
}
input[type='submit'] {
display: block;
}
input[type='text'],
input:not([type='submit']),
textarea#message
{
width: 30em;
}
textarea#message {
height: 6em;
}
</style>
</head>
<body>
<form method="POST" action="send_simpleform.php">
<label for="sender_name">Su Nombre:</label>
<input id="sender_name" name="sender_name" />
<label for="sender_email">Su E-Mail Address:</label>
<input id="sender_email" name="sender_email" />
<label for="message">Mensaje:</label>
<textarea id="message" name="message" wrap="virtual"></textarea>
<input type="submit" name="submit" value="send this form" />
</form>
</body>
</html>
PHP Code:
<?php
$msg = "ESTOS SON LOS DATOS RECIBIDOS:\n";
$msg .= "Nombre: $_post['sender_name'])\n";
Unlike function and class names, variable names are case sensitive. $_post is a different variable from $_POST.
With heredocs, you can readily create multiline strings (though it should be noted that quoted strings can also span multiple lines).
PHP Code:
<?php
if ("\n" == "\x0D\x0A") {
$eol = '';
} else {
$eol = "\r";
}
$to = "maulikan@agmr.x10.bz";
$subject = "Send test";
$mailheaders =<<<EOS
From: Alberto Marambio <> $eol
Reply-To: $sender_email$eol
$eol
EOS;
$msg =<<<EOS
ESTOS SON LOS DATOS RECIBIDOS:$eol
Nombre: $_POST[sender_name]$eol
E-Mail: $_POST[sender_email]$eol
Mensaje: $_POST[message]$eol
$eol
EOS;
if (mail($to, $subject, $msg, $mailheaders)):
// very basic error handling. More should be done.
?>
<p class="error">Message sent.</p>
<?php else: ?>
<p class="error">I couldn't send your message. Please try again later.</p>
<?php endif; ?>