| | |
Sending a form via sendmail
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Dec 2007
Posts: 1
Reputation:
Solved Threads: 0
I am new to this PHP thing. I have programmed in VS 2003 and VB and C# for web site. I am working for this new company and all their forms are sent via send mail.
My problem is that i am trying to send multiple variables to send mail and i just dont know what to do as this is my first time using it.
Here is the code i am working on:
<form id="form1" name="form1" method="post" action="sendmail2.php">
<table width="57%" border="0" cellspacing="6" cellpadding="0">
<tr>
<td class="blackfont"><strong>*First Name</strong></td>
</tr>
<tr>
<td class="blackfont"><input name="name_req" type="text" class="style1" id="name_req" size="35" tabindex="1" /></td>
</tr>
<tr>
<td class="blackfont"><strong>*Last Name</strong></td>
</tr>
<tr>
<td class="blackfont"><input name="lastname_req" type="text" id="lastname_req" size="35" tabindex="2" /></td>
</tr>
<tr>
<td class="blackfont"><strong>*Mailing Address</strong></td>
</tr>
<tr>
<td class="blackfont"><input name="address_req" type="text" id="address_req" size="35" tabindex="3" /></td>
</tr>
<tr>
<td class="blackfont"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="39%"><strong>*City</strong></td>
<td width="27%"><strong>State</strong></td>
<td width="34%"><strong>Zip</strong></td>
</tr>
</table></td>
</tr>
<tr>
<td class="blackfont"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="39%"><input type="text" name="City_req" tabindex="4" /></td>
<td width="27%"><input name="State" type="text" size="10" tabindex="5" /></td>
<td width="34%"><input type="text" name="Zip" tabindex="6" /></td>
</tr>
</table></td>
</tr>
<tr>
<td class="blackfont"><strong>Phone #</strong></td>
</tr>
<tr>
<td class="blackfont"><input name="Phone_Number" type="text" size="35" tabindex="7" /></td>
</tr>
<tr>
<td class="blackfont"><strong>*Email address</strong></td>
</tr>
<tr>
<td class="blackfont"><input name="Email_Address_req" type="text" size="35" tabindex="8"/></td>
</tr>
<tr>
<td class="blackfont"><strong>*Size of parking space interested in (select one):</strong></td>
</tr>
<tr>
<td class="blackfont"><strong>
<label>
<select name="parkingspace_size" id="parkingspace_size" tabindex="9">
<option value="lO x 30 uncovered">l0 x 30 uncovered</option>
<option value="12 X 40 covered">12 X 40 covered</option>
<option value="12 X 50 covered">12 X 50 covered</option>
</select>
</label>
</strong></td>
</tr>
<tr>
<td class="blackfont"><strong>*Size of Mini-storage interested in(select one):</strong></td>
</tr>
<tr>
<td><select name="ministorage_size" id="ministorage_size" tabindex="10">
<option value="5 X 10">5 X 10</option>
<option value="10 X 10">10 X 10</option>
</select></td>
</tr>
<tr>
<td class="blackfont"><strong>Comments</strong></td>
</tr>
<tr>
<td><label>
<textarea name="Comments" cols="35" rows="5" tabindex="11"></textarea>
</label></td>
</tr>
<tr>
<td><label>
<input type="submit" name="Submit" value="Submit" tabindex="12" />
</label></td>
</tr>
</table>
</form>
and the corresponding php code to this form
<?
$name_req = $_REQUEST['name_req'] ;
$lastname_req = $_REQUEST['lastname_req'] ;
$address_req = $_REQUEST['address_req'] ;
$City_req = $_REQUEST['City_req'] ;
$State = $_REQUEST['State'] ;
$Zip = $_REQUEST['Zip'] ;
$Phone = $_REQUEST['Phone'] ;
$Email_Address = $_REQUEST['Email_Address'] ;
$parkingspace_size = $_REQUEST['parkingspace_size'] ;
$ministorage_size = $_REQUEST['ministorage_size'] ;
$comments = $_REQUEST['comments'] ;
'$message = $name_req + $lastname_req + $address_req + $City_req,$State + $Zip + $Phone + $parkingspace_size + $ministorage_size + $comments'
mail( "e.williams.bis@gmail.com", "Questions About you Spaces Available.",
$message = $name_req + $lastname_req + $address_req + $City_req,$State + $Zip + $Phone + $parkingspace_size + $ministorage_size + $comments,
"From: $Email_Address" );
print "Your Questions have been sent to the White Tanks Storage Team";
?>
If any of you can help me out i would appreciate it.
My problem is that i am trying to send multiple variables to send mail and i just dont know what to do as this is my first time using it.
Here is the code i am working on:
<form id="form1" name="form1" method="post" action="sendmail2.php">
<table width="57%" border="0" cellspacing="6" cellpadding="0">
<tr>
<td class="blackfont"><strong>*First Name</strong></td>
</tr>
<tr>
<td class="blackfont"><input name="name_req" type="text" class="style1" id="name_req" size="35" tabindex="1" /></td>
</tr>
<tr>
<td class="blackfont"><strong>*Last Name</strong></td>
</tr>
<tr>
<td class="blackfont"><input name="lastname_req" type="text" id="lastname_req" size="35" tabindex="2" /></td>
</tr>
<tr>
<td class="blackfont"><strong>*Mailing Address</strong></td>
</tr>
<tr>
<td class="blackfont"><input name="address_req" type="text" id="address_req" size="35" tabindex="3" /></td>
</tr>
<tr>
<td class="blackfont"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="39%"><strong>*City</strong></td>
<td width="27%"><strong>State</strong></td>
<td width="34%"><strong>Zip</strong></td>
</tr>
</table></td>
</tr>
<tr>
<td class="blackfont"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="39%"><input type="text" name="City_req" tabindex="4" /></td>
<td width="27%"><input name="State" type="text" size="10" tabindex="5" /></td>
<td width="34%"><input type="text" name="Zip" tabindex="6" /></td>
</tr>
</table></td>
</tr>
<tr>
<td class="blackfont"><strong>Phone #</strong></td>
</tr>
<tr>
<td class="blackfont"><input name="Phone_Number" type="text" size="35" tabindex="7" /></td>
</tr>
<tr>
<td class="blackfont"><strong>*Email address</strong></td>
</tr>
<tr>
<td class="blackfont"><input name="Email_Address_req" type="text" size="35" tabindex="8"/></td>
</tr>
<tr>
<td class="blackfont"><strong>*Size of parking space interested in (select one):</strong></td>
</tr>
<tr>
<td class="blackfont"><strong>
<label>
<select name="parkingspace_size" id="parkingspace_size" tabindex="9">
<option value="lO x 30 uncovered">l0 x 30 uncovered</option>
<option value="12 X 40 covered">12 X 40 covered</option>
<option value="12 X 50 covered">12 X 50 covered</option>
</select>
</label>
</strong></td>
</tr>
<tr>
<td class="blackfont"><strong>*Size of Mini-storage interested in(select one):</strong></td>
</tr>
<tr>
<td><select name="ministorage_size" id="ministorage_size" tabindex="10">
<option value="5 X 10">5 X 10</option>
<option value="10 X 10">10 X 10</option>
</select></td>
</tr>
<tr>
<td class="blackfont"><strong>Comments</strong></td>
</tr>
<tr>
<td><label>
<textarea name="Comments" cols="35" rows="5" tabindex="11"></textarea>
</label></td>
</tr>
<tr>
<td><label>
<input type="submit" name="Submit" value="Submit" tabindex="12" />
</label></td>
</tr>
</table>
</form>
and the corresponding php code to this form
<?
$name_req = $_REQUEST['name_req'] ;
$lastname_req = $_REQUEST['lastname_req'] ;
$address_req = $_REQUEST['address_req'] ;
$City_req = $_REQUEST['City_req'] ;
$State = $_REQUEST['State'] ;
$Zip = $_REQUEST['Zip'] ;
$Phone = $_REQUEST['Phone'] ;
$Email_Address = $_REQUEST['Email_Address'] ;
$parkingspace_size = $_REQUEST['parkingspace_size'] ;
$ministorage_size = $_REQUEST['ministorage_size'] ;
$comments = $_REQUEST['comments'] ;
'$message = $name_req + $lastname_req + $address_req + $City_req,$State + $Zip + $Phone + $parkingspace_size + $ministorage_size + $comments'
mail( "e.williams.bis@gmail.com", "Questions About you Spaces Available.",
$message = $name_req + $lastname_req + $address_req + $City_req,$State + $Zip + $Phone + $parkingspace_size + $ministorage_size + $comments,
"From: $Email_Address" );
print "Your Questions have been sent to the White Tanks Storage Team";
?>
If any of you can help me out i would appreciate it.
Are you wanting to put all of the variables into one string called $message? If so:
php Syntax (Toggle Plain Text)
$message = "$name_req $lastname_req $address_req $City_req,$State $Zip $Phone $parkingspace_size $ministorage_size $comments"; mail( "e.williams.bis@gmail.com", "Questions About you Spaces Available.", $message,"From: $Email_Address" );
![]() |
Similar Threads
- PHP Sendmail Tutorial (PHP)
- PHP Contact Form Help (PHP)
- php sending mail via smtp external site (PHP)
- Sending HTML email via PHP mail function (PHP)
- Problem setting up mail server (PHP)
- modify script (Perl)
- Form isn't working. (HTML and CSS)
- Sending attachements over php (PHP)
Other Threads in the PHP Forum
- Previous Thread: How to properly use tables in db?
- Next Thread: check box form
Views: 1739 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email encode error file files folder form forms function functions google href htaccess html image images include insert integration ip java javascript joomla ldap limit link login loop mail menu methods mlm mod_rewrite multiple multipletables mysql oop open parse paypal pdf php problem provider query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube





