PHP Form Issue
Ozzu,
I am having trouble with transferring my website visitor’s information from the HTML form to my PHP file to my designated email address.
All I see when I open am email is this:
--------------------------------------------------------------------------------
Name:
Email:
Phone Number:
Comment:
The above displays the field name of each row, but the input data from the websites visitors.
Below is the PHP code I wrote, any suggestions?
Thanks cgfX
I am having trouble with transferring my website visitor’s information from the HTML form to my PHP file to my designated email address.
All I see when I open am email is this:
--------------------------------------------------------------------------------
Name:
Email:
Phone Number:
Comment:
The above displays the field name of each row, but the input data from the websites visitors.
Below is the PHP code I wrote, any suggestions?
Thanks cgfX
<?php
/* Subject and Email Variables */
$emailSubject = 'Contact Us!';
$webMaster = 'putEmailAddressHere';
/* Gathering Data Variables */
$name = $_POST ['name'];
$email = $_POST ['email'];
$phone = $_POST ['phone'];
$comment = $_POST ['comment'];
$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Phone Number: $phone <br>
Comment: $comment <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
/* Result rendered as HTML */
$theResults = <<<EOD
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
<title>Website Name | Thank You</title>
</head>
<body>
Thank you very much, your email will be answered very soon. <a href="websiteAddressHere/">Click here</a> to go back to our site.
</body>
</html>
EOD;
echo "$theResults";
?>
/* Subject and Email Variables */
$emailSubject = 'Contact Us!';
$webMaster = 'putEmailAddressHere';
/* Gathering Data Variables */
$name = $_POST ['name'];
$email = $_POST ['email'];
$phone = $_POST ['phone'];
$comment = $_POST ['comment'];
$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Phone Number: $phone <br>
Comment: $comment <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
/* Result rendered as HTML */
$theResults = <<<EOD
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
<title>Website Name | Thank You</title>
</head>
<body>
Thank you very much, your email will be answered very soon. <a href="websiteAddressHere/">Click here</a> to go back to our site.
</body>
</html>
EOD;
echo "$theResults";
?>
- <?php
- /* Subject and Email Variables */
- $emailSubject = 'Contact Us!';
- $webMaster = 'putEmailAddressHere';
- /* Gathering Data Variables */
- $name = $_POST ['name'];
- $email = $_POST ['email'];
- $phone = $_POST ['phone'];
- $comment = $_POST ['comment'];
- $body = <<<EOD
- <br><hr><br>
- Name: $name <br>
- Email: $email <br>
- Phone Number: $phone <br>
- Comment: $comment <br>
- EOD;
- $headers = "From: $email\r\n";
- $headers .= "Content-type: text/html\r\n";
- $success = mail($webMaster, $emailSubject, $body, $headers);
- /* Result rendered as HTML */
- $theResults = <<<EOD
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
- <title>Website Name | Thank You</title>
- </head>
- <body>
- Thank you very much, your email will be answered very soon. <a href="websiteAddressHere/">Click here</a> to go back to our site.
- </body>
- </html>
- EOD;
- echo "$theResults";
- ?>
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
November 6th, 2009, 2:04 pm
Another bit of code, below is the code of the form:
<div class="formContainer">
<fieldset>
<legend>Contact Us</legend>
<table width="250" border="0">
<tr>
<td width="135" class="formLabels">Name</td>
<td width="200"><form id="form1" name="form1" method="post" action="../contactformprocess.php">
<label>
<input name="name" type="text" id="name" onblur="MM_validateForm('name','','R');return document.MM_returnValue" />
</label>
</form></td>
</tr>
<tr>
<td class="formLabels">Email</td>
<td><form id="form2" name="form2" method="post" action="../contactformprocess.php">
<label onfocus="MM_validateForm('email','','RisEmail');return document.MM_returnValue">
<input name="email" type="text" id="email" onblur="MM_validateForm('email','','RisEmail');return document.MM_returnValue" />
</label>
</form></td>
</tr>
<tr>
<td class="formLabels">Phone</td>
<td><form id="form3" name="form3" method="post" action="../contactformprocess.php">
<label>
<input name="phone" type="text" id="phone" onblur="MM_validateForm('phone','','RisNum');return document.MM_returnValue" />
</label>
</form></td>
</tr>
<tr>
<td class="formLabels"><div align="right">Comment</div></td>
<td><form id="form5" name="form5" method="post" action="../contactformprocess.php">
<label>
<textarea name="comment" id="comment" cols="21" rows="2"></textarea>
</label>
</form></td>
</tr>
</table>
<form id="form4" name="form4" method="post" action="../contactformprocess.php">
<label>
<input type="submit" name="submit" id="submit" value="Submit" />
</label>
</form>
</fieldset>
</div>
<fieldset>
<legend>Contact Us</legend>
<table width="250" border="0">
<tr>
<td width="135" class="formLabels">Name</td>
<td width="200"><form id="form1" name="form1" method="post" action="../contactformprocess.php">
<label>
<input name="name" type="text" id="name" onblur="MM_validateForm('name','','R');return document.MM_returnValue" />
</label>
</form></td>
</tr>
<tr>
<td class="formLabels">Email</td>
<td><form id="form2" name="form2" method="post" action="../contactformprocess.php">
<label onfocus="MM_validateForm('email','','RisEmail');return document.MM_returnValue">
<input name="email" type="text" id="email" onblur="MM_validateForm('email','','RisEmail');return document.MM_returnValue" />
</label>
</form></td>
</tr>
<tr>
<td class="formLabels">Phone</td>
<td><form id="form3" name="form3" method="post" action="../contactformprocess.php">
<label>
<input name="phone" type="text" id="phone" onblur="MM_validateForm('phone','','RisNum');return document.MM_returnValue" />
</label>
</form></td>
</tr>
<tr>
<td class="formLabels"><div align="right">Comment</div></td>
<td><form id="form5" name="form5" method="post" action="../contactformprocess.php">
<label>
<textarea name="comment" id="comment" cols="21" rows="2"></textarea>
</label>
</form></td>
</tr>
</table>
<form id="form4" name="form4" method="post" action="../contactformprocess.php">
<label>
<input type="submit" name="submit" id="submit" value="Submit" />
</label>
</form>
</fieldset>
</div>
- <div class="formContainer">
- <fieldset>
- <legend>Contact Us</legend>
- <table width="250" border="0">
- <tr>
- <td width="135" class="formLabels">Name</td>
- <td width="200"><form id="form1" name="form1" method="post" action="../contactformprocess.php">
- <label>
- <input name="name" type="text" id="name" onblur="MM_validateForm('name','','R');return document.MM_returnValue" />
- </label>
- </form></td>
- </tr>
- <tr>
- <td class="formLabels">Email</td>
- <td><form id="form2" name="form2" method="post" action="../contactformprocess.php">
- <label onfocus="MM_validateForm('email','','RisEmail');return document.MM_returnValue">
- <input name="email" type="text" id="email" onblur="MM_validateForm('email','','RisEmail');return document.MM_returnValue" />
- </label>
- </form></td>
- </tr>
- <tr>
- <td class="formLabels">Phone</td>
- <td><form id="form3" name="form3" method="post" action="../contactformprocess.php">
- <label>
- <input name="phone" type="text" id="phone" onblur="MM_validateForm('phone','','RisNum');return document.MM_returnValue" />
- </label>
- </form></td>
- </tr>
- <tr>
- <td class="formLabels"><div align="right">Comment</div></td>
- <td><form id="form5" name="form5" method="post" action="../contactformprocess.php">
- <label>
- <textarea name="comment" id="comment" cols="21" rows="2"></textarea>
- </label>
- </form></td>
- </tr>
- </table>
- <form id="form4" name="form4" method="post" action="../contactformprocess.php">
- <label>
- <input type="submit" name="submit" id="submit" value="Submit" />
- </label>
- </form>
- </fieldset>
- </div>
- righteous_trespasser
- Sold Out


- Joined: Mar 12, 2007
- Posts: 6007
- Loc: South-Africa
- Status: Offline
I don't know if this will make a difference, but it's worth a try ... where you declare the variables like:
try it without the space like this:
See if that make's a difference first.
$name = $_POST ['name'];
try it without the space like this:
$name = $_POST['name'];
See if that make's a difference first.
RewriteEngine On
RewriteRule ^(awesome|excellent|extraordinary)$ RT
RewriteRule ^(awesome|excellent|extraordinary)$ RT
Why do you have all those forms in the HTML part? If you need that for the JavaScript, you can validate the values using PHP rather than JavaScript. Would make things a lot easier.
Just as a test: see if the following helps
smtp.class.php
formprocess.php
form.html
Just as a test: see if the following helps
smtp.class.php
<?php
// Mail.php
class mail
{
private $smtpServer = 'smtp.site.com';
private $port = '25';
private $timeout = 30;
private $username = 'smtp_user';
private $password = 'smtp_pass';
private $username_email = 'admin@site.com';
private $newline = "\r\n";
private $localdomain = 'site.com';
private $charset = 'windows-1251';
private $contentTransferEncoding = false;
// Do not change anything below
private $smtpConnect = false;
private $to = false;
private $subject = false;
private $message = false;
private $headers = false;
private $logArray = array(); // Array response message for debug
private $Error = '';
public function __construct($to, $subject, $message, $to2 = false) {
$this->to = (($to2 !== false)? $this->username_email : $to);
$this->subject = &$subject;
$this->message = &$message;
// Connect to server
if(!$this->Connect2Server()) {
// Display error message
echo '<pre>'.trim($this->Error).'</pre>'.$this->newline.'<!-- '.$this->newline;
print_r($this->logArray);
echo $this->newline.'-->'.$this->newline;
return false;
}
return true;
}
private function Connect2Server() {
$from = (($to2 == false)? $this->username_email : $to);
// Connect to server
$this->smtpConnect = fsockopen($this->smtpServer,$this->port,$errno,$error,$this->timeout);
$this->logArray['CONNECT_RESPONSE'] = $this->readResponse();
if (!is_resource($this->smtpConnect)) {
return false;
}
$this->logArray['connection'] = "Connection accepted: {$smtpResponse}";
// Hi, server!
$this->sendCommand("HELO {$this->localdomain}");
$this->logArray['HELO'] = $this->readResponse();
// Let's know each other
$this->sendCommand('AUTH LOGIN');
$this->logArray['AUTH_REQUEST'] = $this->readResponse();
// My name...
$this->sendCommand(base64_encode($this->username));
$this->logArray['REQUEST_USER'] = $this->readResponse();
// My password..
$this->sendCommand(base64_encode($this->password));
$this->logArray['REQUEST_PASSWD'] = $this->readResponse();
// If error in response auth...
if (substr($this->logArray['REQUEST_PASSWD'],0,3)!='235') {
$this->Error .= 'Authorization error! '.$this->logArray['REQUEST_PASSWD'].$this->newline;
return false;
}
// "From" mail...
$this->sendCommand("MAIL FROM: {$from}");
$this->logArray['MAIL_FROM_RESPONSE'] = $this->readResponse();
if (substr($this->logArray['MAIL_FROM_RESPONSE'],0,3)!='250') {
$this->Error .= 'Mistake in sender\'s address! '.$this->logArray['MAIL_FROM_RESPONSE'].$this->newline;
return false;
}
// "To" address
$this->sendCommand("RCPT TO: {$this->to}");
$this->logArray['RCPT_TO_RESPONCE'] = $this->readResponse();
if(substr($this->logArray['RCPT_TO_RESPONCE'],0,3) != '250')
{
$this->Error .= 'Mistake in reciepent address! '.$this->logArray['RCPT_TO_RESPONCE'].$this->newline;
}
// Send data to server
$this->sendCommand('DATA');
$this->logArray['DATA_RESPONSE'] = $this->readResponse();
// Send mail message
if (!$this->sendMail()) return false;
// Good bye server! =)
$this->sendCommand('QUIT');
$this->logArray['QUIT_RESPONSE'] = $this->readResponse();
// Close smtp connect
fclose($this->smtpConnect);
return true;
}
// Function send mail
private function sendMail() {
$this->sendHeaders();
$this->sendCommand($this->message);
$this->sendCommand('.');
$this->logArray['SEND_DATA_RESPONSE'] = $this->readResponse();
if(substr($this->logArray['SEND_DATA_RESPONSE'],0,3)!='250') {
$this->Error .= 'Mistake in sending data! '.$this->logArray['SEND_DATA_RESPONSE'].$this->newline;
return false;
}
return true;
}
// Function read response
private function readResponse() {
$data="";
while($str = fgets($this->smtpConnect,4096))
{
$data .= $str;
if(substr($str,3,1) == " ") { break; }
}
return $data;
}
// function send command to server
private function sendCommand($string) {
fputs($this->smtpConnect,$string.$this->newline);
return ;
}
// function send headers
private function sendHeaders() {
$from = (($to2 == false)? $this->username_email : $to);
$this->sendCommand("Date: ".date("D, j M Y G:i:s")." +0700");
$this->sendCommand("From: <{$from}>");
$this->sendCommand("Reply-To: <{$from}>");
$this->sendCommand("To: <{$this->to}>");
$this->sendCommand("Subject: {$this->subject}");
$this->sendCommand("MIME-Version: 1.0");
$this->sendCommand("Content-Type: text/html; charset={$this->charset}");
if ($this->contentTransferEncoding) $this->sendCommand("Content-Transfer-Encoding: {$this->contentTransferEncoding}");
return ;
}
public function __destruct() {
if (is_resource($this->smtpConnect)) fclose($this->smtpConnect);
}
}
?>
// Mail.php
class mail
{
private $smtpServer = 'smtp.site.com';
private $port = '25';
private $timeout = 30;
private $username = 'smtp_user';
private $password = 'smtp_pass';
private $username_email = 'admin@site.com';
private $newline = "\r\n";
private $localdomain = 'site.com';
private $charset = 'windows-1251';
private $contentTransferEncoding = false;
// Do not change anything below
private $smtpConnect = false;
private $to = false;
private $subject = false;
private $message = false;
private $headers = false;
private $logArray = array(); // Array response message for debug
private $Error = '';
public function __construct($to, $subject, $message, $to2 = false) {
$this->to = (($to2 !== false)? $this->username_email : $to);
$this->subject = &$subject;
$this->message = &$message;
// Connect to server
if(!$this->Connect2Server()) {
// Display error message
echo '<pre>'.trim($this->Error).'</pre>'.$this->newline.'<!-- '.$this->newline;
print_r($this->logArray);
echo $this->newline.'-->'.$this->newline;
return false;
}
return true;
}
private function Connect2Server() {
$from = (($to2 == false)? $this->username_email : $to);
// Connect to server
$this->smtpConnect = fsockopen($this->smtpServer,$this->port,$errno,$error,$this->timeout);
$this->logArray['CONNECT_RESPONSE'] = $this->readResponse();
if (!is_resource($this->smtpConnect)) {
return false;
}
$this->logArray['connection'] = "Connection accepted: {$smtpResponse}";
// Hi, server!
$this->sendCommand("HELO {$this->localdomain}");
$this->logArray['HELO'] = $this->readResponse();
// Let's know each other
$this->sendCommand('AUTH LOGIN');
$this->logArray['AUTH_REQUEST'] = $this->readResponse();
// My name...
$this->sendCommand(base64_encode($this->username));
$this->logArray['REQUEST_USER'] = $this->readResponse();
// My password..
$this->sendCommand(base64_encode($this->password));
$this->logArray['REQUEST_PASSWD'] = $this->readResponse();
// If error in response auth...
if (substr($this->logArray['REQUEST_PASSWD'],0,3)!='235') {
$this->Error .= 'Authorization error! '.$this->logArray['REQUEST_PASSWD'].$this->newline;
return false;
}
// "From" mail...
$this->sendCommand("MAIL FROM: {$from}");
$this->logArray['MAIL_FROM_RESPONSE'] = $this->readResponse();
if (substr($this->logArray['MAIL_FROM_RESPONSE'],0,3)!='250') {
$this->Error .= 'Mistake in sender\'s address! '.$this->logArray['MAIL_FROM_RESPONSE'].$this->newline;
return false;
}
// "To" address
$this->sendCommand("RCPT TO: {$this->to}");
$this->logArray['RCPT_TO_RESPONCE'] = $this->readResponse();
if(substr($this->logArray['RCPT_TO_RESPONCE'],0,3) != '250')
{
$this->Error .= 'Mistake in reciepent address! '.$this->logArray['RCPT_TO_RESPONCE'].$this->newline;
}
// Send data to server
$this->sendCommand('DATA');
$this->logArray['DATA_RESPONSE'] = $this->readResponse();
// Send mail message
if (!$this->sendMail()) return false;
// Good bye server! =)
$this->sendCommand('QUIT');
$this->logArray['QUIT_RESPONSE'] = $this->readResponse();
// Close smtp connect
fclose($this->smtpConnect);
return true;
}
// Function send mail
private function sendMail() {
$this->sendHeaders();
$this->sendCommand($this->message);
$this->sendCommand('.');
$this->logArray['SEND_DATA_RESPONSE'] = $this->readResponse();
if(substr($this->logArray['SEND_DATA_RESPONSE'],0,3)!='250') {
$this->Error .= 'Mistake in sending data! '.$this->logArray['SEND_DATA_RESPONSE'].$this->newline;
return false;
}
return true;
}
// Function read response
private function readResponse() {
$data="";
while($str = fgets($this->smtpConnect,4096))
{
$data .= $str;
if(substr($str,3,1) == " ") { break; }
}
return $data;
}
// function send command to server
private function sendCommand($string) {
fputs($this->smtpConnect,$string.$this->newline);
return ;
}
// function send headers
private function sendHeaders() {
$from = (($to2 == false)? $this->username_email : $to);
$this->sendCommand("Date: ".date("D, j M Y G:i:s")." +0700");
$this->sendCommand("From: <{$from}>");
$this->sendCommand("Reply-To: <{$from}>");
$this->sendCommand("To: <{$this->to}>");
$this->sendCommand("Subject: {$this->subject}");
$this->sendCommand("MIME-Version: 1.0");
$this->sendCommand("Content-Type: text/html; charset={$this->charset}");
if ($this->contentTransferEncoding) $this->sendCommand("Content-Transfer-Encoding: {$this->contentTransferEncoding}");
return ;
}
public function __destruct() {
if (is_resource($this->smtpConnect)) fclose($this->smtpConnect);
}
}
?>
- <?php
- // Mail.php
- class mail
- {
- private $smtpServer = 'smtp.site.com';
- private $port = '25';
- private $timeout = 30;
- private $username = 'smtp_user';
- private $password = 'smtp_pass';
- private $username_email = 'admin@site.com';
- private $newline = "\r\n";
- private $localdomain = 'site.com';
- private $charset = 'windows-1251';
- private $contentTransferEncoding = false;
- // Do not change anything below
- private $smtpConnect = false;
- private $to = false;
- private $subject = false;
- private $message = false;
- private $headers = false;
- private $logArray = array(); // Array response message for debug
- private $Error = '';
- public function __construct($to, $subject, $message, $to2 = false) {
- $this->to = (($to2 !== false)? $this->username_email : $to);
- $this->subject = &$subject;
- $this->message = &$message;
- // Connect to server
- if(!$this->Connect2Server()) {
- // Display error message
- echo '<pre>'.trim($this->Error).'</pre>'.$this->newline.'<!-- '.$this->newline;
- print_r($this->logArray);
- echo $this->newline.'-->'.$this->newline;
- return false;
- }
- return true;
- }
- private function Connect2Server() {
- $from = (($to2 == false)? $this->username_email : $to);
- // Connect to server
- $this->smtpConnect = fsockopen($this->smtpServer,$this->port,$errno,$error,$this->timeout);
- $this->logArray['CONNECT_RESPONSE'] = $this->readResponse();
- if (!is_resource($this->smtpConnect)) {
- return false;
- }
- $this->logArray['connection'] = "Connection accepted: {$smtpResponse}";
- // Hi, server!
- $this->sendCommand("HELO {$this->localdomain}");
- $this->logArray['HELO'] = $this->readResponse();
- // Let's know each other
- $this->sendCommand('AUTH LOGIN');
- $this->logArray['AUTH_REQUEST'] = $this->readResponse();
- // My name...
- $this->sendCommand(base64_encode($this->username));
- $this->logArray['REQUEST_USER'] = $this->readResponse();
- // My password..
- $this->sendCommand(base64_encode($this->password));
- $this->logArray['REQUEST_PASSWD'] = $this->readResponse();
- // If error in response auth...
- if (substr($this->logArray['REQUEST_PASSWD'],0,3)!='235') {
- $this->Error .= 'Authorization error! '.$this->logArray['REQUEST_PASSWD'].$this->newline;
- return false;
- }
- // "From" mail...
- $this->sendCommand("MAIL FROM: {$from}");
- $this->logArray['MAIL_FROM_RESPONSE'] = $this->readResponse();
- if (substr($this->logArray['MAIL_FROM_RESPONSE'],0,3)!='250') {
- $this->Error .= 'Mistake in sender\'s address! '.$this->logArray['MAIL_FROM_RESPONSE'].$this->newline;
- return false;
- }
- // "To" address
- $this->sendCommand("RCPT TO: {$this->to}");
- $this->logArray['RCPT_TO_RESPONCE'] = $this->readResponse();
- if(substr($this->logArray['RCPT_TO_RESPONCE'],0,3) != '250')
- {
- $this->Error .= 'Mistake in reciepent address! '.$this->logArray['RCPT_TO_RESPONCE'].$this->newline;
- }
- // Send data to server
- $this->sendCommand('DATA');
- $this->logArray['DATA_RESPONSE'] = $this->readResponse();
- // Send mail message
- if (!$this->sendMail()) return false;
- // Good bye server! =)
- $this->sendCommand('QUIT');
- $this->logArray['QUIT_RESPONSE'] = $this->readResponse();
- // Close smtp connect
- fclose($this->smtpConnect);
- return true;
- }
- // Function send mail
- private function sendMail() {
- $this->sendHeaders();
- $this->sendCommand($this->message);
- $this->sendCommand('.');
- $this->logArray['SEND_DATA_RESPONSE'] = $this->readResponse();
- if(substr($this->logArray['SEND_DATA_RESPONSE'],0,3)!='250') {
- $this->Error .= 'Mistake in sending data! '.$this->logArray['SEND_DATA_RESPONSE'].$this->newline;
- return false;
- }
- return true;
- }
- // Function read response
- private function readResponse() {
- $data="";
- while($str = fgets($this->smtpConnect,4096))
- {
- $data .= $str;
- if(substr($str,3,1) == " ") { break; }
- }
- return $data;
- }
- // function send command to server
- private function sendCommand($string) {
- fputs($this->smtpConnect,$string.$this->newline);
- return ;
- }
- // function send headers
- private function sendHeaders() {
- $from = (($to2 == false)? $this->username_email : $to);
- $this->sendCommand("Date: ".date("D, j M Y G:i:s")." +0700");
- $this->sendCommand("From: <{$from}>");
- $this->sendCommand("Reply-To: <{$from}>");
- $this->sendCommand("To: <{$this->to}>");
- $this->sendCommand("Subject: {$this->subject}");
- $this->sendCommand("MIME-Version: 1.0");
- $this->sendCommand("Content-Type: text/html; charset={$this->charset}");
- if ($this->contentTransferEncoding) $this->sendCommand("Content-Transfer-Encoding: {$this->contentTransferEncoding}");
- return ;
- }
- public function __destruct() {
- if (is_resource($this->smtpConnect)) fclose($this->smtpConnect);
- }
- }
- ?>
formprocess.php
<?php
/* Some required variables to configure this page */
// Variables not to be sent to you
$blocked = array('submit1');
// The email address the result of the form would be sent to.
$adm_email = 'your_email@your_host.com'
// The prefix to the mail
$mail_prefix = '<br /><hr /><br />';
// The post (signature) to the mail
$mail_post = null;
// The title for the message
$title = 'A message was sent to you!';
/* The actual code body for sending */
// Initiating the body var
$body = $mail_prefix;
// Initiating some numeric values that would be incremented in the following loop
$blocked_num = 0;
// Building the body for the mail
foreach($_POST as $field_name => $field_value)
// Building the body for the mail with the correct fields
if(!in_array($field_name, $blocked))
$body .= "<strong>{$field_name}</strong>: {$_POST[$field_value]}<br />\r\n";
// Ending the body var
$body .= $mail_post;
// Trimming the ends of body from any unneeded white spaces
$body = trim($body);
// Requiring the SMTP class
require_once 'smtp.class.php';
// Initiating the mail object
$mail = new mail();
// Sending the message
//if(new mail($_POST['email'], $title, $body, true))
// echo 'The mail was successfully sent. Thank you for your time!';
//else
// echo 'There was an error in the mailling service.';
echo $body;
?>
/* Some required variables to configure this page */
// Variables not to be sent to you
$blocked = array('submit1');
// The email address the result of the form would be sent to.
$adm_email = 'your_email@your_host.com'
// The prefix to the mail
$mail_prefix = '<br /><hr /><br />';
// The post (signature) to the mail
$mail_post = null;
// The title for the message
$title = 'A message was sent to you!';
/* The actual code body for sending */
// Initiating the body var
$body = $mail_prefix;
// Initiating some numeric values that would be incremented in the following loop
$blocked_num = 0;
// Building the body for the mail
foreach($_POST as $field_name => $field_value)
// Building the body for the mail with the correct fields
if(!in_array($field_name, $blocked))
$body .= "<strong>{$field_name}</strong>: {$_POST[$field_value]}<br />\r\n";
// Ending the body var
$body .= $mail_post;
// Trimming the ends of body from any unneeded white spaces
$body = trim($body);
// Requiring the SMTP class
require_once 'smtp.class.php';
// Initiating the mail object
$mail = new mail();
// Sending the message
//if(new mail($_POST['email'], $title, $body, true))
// echo 'The mail was successfully sent. Thank you for your time!';
//else
// echo 'There was an error in the mailling service.';
echo $body;
?>
- <?php
- /* Some required variables to configure this page */
- // Variables not to be sent to you
- $blocked = array('submit1');
- // The email address the result of the form would be sent to.
- $adm_email = 'your_email@your_host.com'
- // The prefix to the mail
- $mail_prefix = '<br /><hr /><br />';
- // The post (signature) to the mail
- $mail_post = null;
- // The title for the message
- $title = 'A message was sent to you!';
- /* The actual code body for sending */
- // Initiating the body var
- $body = $mail_prefix;
- // Initiating some numeric values that would be incremented in the following loop
- $blocked_num = 0;
- // Building the body for the mail
- foreach($_POST as $field_name => $field_value)
- // Building the body for the mail with the correct fields
- if(!in_array($field_name, $blocked))
- $body .= "<strong>{$field_name}</strong>: {$_POST[$field_value]}<br />\r\n";
- // Ending the body var
- $body .= $mail_post;
- // Trimming the ends of body from any unneeded white spaces
- $body = trim($body);
- // Requiring the SMTP class
- require_once 'smtp.class.php';
- // Initiating the mail object
- $mail = new mail();
- // Sending the message
- //if(new mail($_POST['email'], $title, $body, true))
- // echo 'The mail was successfully sent. Thank you for your time!';
- //else
- // echo 'There was an error in the mailling service.';
- echo $body;
- ?>
form.html
<form method="post" action="formprocess.php">
<input type="text" name="name1" size="10" />
<input type="text" name="name2" size="10" />
<input type="text" name="name3" size="10" />
<input type="text" name="name4" size="10" />
<input type="text" name="name5" size="10" />
<input type="text" name="name6" size="10" />
<input type="submit" name="submit" value="submit" />
</form>
<input type="text" name="name1" size="10" />
<input type="text" name="name2" size="10" />
<input type="text" name="name3" size="10" />
<input type="text" name="name4" size="10" />
<input type="text" name="name5" size="10" />
<input type="text" name="name6" size="10" />
<input type="submit" name="submit" value="submit" />
</form>
- <form method="post" action="formprocess.php">
- <input type="text" name="name1" size="10" />
- <input type="text" name="name2" size="10" />
- <input type="text" name="name3" size="10" />
- <input type="text" name="name4" size="10" />
- <input type="text" name="name5" size="10" />
- <input type="text" name="name6" size="10" />
- <input type="submit" name="submit" value="submit" />
- </form>
Learn PHP | I got 10 PHP tutorials! Check them out!
Dreamtale - Farewell
Just a note... I've giving up on web development and that stuff... Just lost all interest in it.
Dreamtale - Farewell
Just a note... I've giving up on web development and that stuff... Just lost all interest in it.
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 8 posts
- Users browsing this forum: No registered users and 180 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum


