theshangsta
29 Aug 2009, 10:35 AM
Hello there, newb to the forums here
I wouldnt consider myself a newbie in general but i still have a whole lot to learn. Im familiar with PHP scripting but i definitely wouldnt call myself an expert quite yet.
I have a website that i've hosted some forms/contracts on that use php to return the data to me in email form. I've tried to use the same PHP script that I use for my contact us page as a template for the php for all my forms/agreements-just editing them a bit.
The problem that i've run into is when a user clicks submit, I want it to obviously return to me all of the input data the user has typed in all of the text fields, as well as a couple radio button values.
My problem is that when i recieve the email, it will only send me one field value at a time...for example I only recieve the user's name in my email when I should be collecting their name, address, credit card, etc......This was never a problem for my contact page because the only input field is the body of the message anyway.
also, when the data is returned to me I need a better way of organizing it; right now if it sends me back someones name for example, it will simply say in the first and only line of my email message: John Smith.
I would like it to say Name: John Smith, in other words Iwould like to receive the data in the closest form possible to the way i distributed it. if I ask for an email on my form i want it to come back as Email: email@email.com
here's the code:
<?php
$name = trim($_POST['name']);
$location = trim($_POST['location']);
$city = trim($_POST['city']);
$zip = trim($_POST['zip']);
$home = trim($_POST['home']);
$cell = trim($_POST['cell']);
$office = trim($_POST['office']);
$primaryfax = trim($_POST['primaryfax']);
$local = trim($_POST['local']);
$localfax = trim($_POST['localfax']);
$from = trim($_POST['from']);
$problem = trim($_POST['problem']);
$previousproblem = trim($_POST['previousproblem']);
$company = trim($_POST['company']);
$service = trim($_POST['service']);
function checkEmail($from)
{
if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $from))
{
return FALSE;
}
list($Username, $Domain) = split("@",$from);
if(getmxrr($Domain, $MXHost))
{
return TRUE;
}
else
{
if(fsockopen($Domain, 25, $errno, $errstr, 30))
{
return TRUE;
}
else
{
return FALSE;
}
}
}
if( isset( $_POST['submit'] ) || !empty( $_POST['submit'] ) )
{
$errors = '';
if(checkEmail($from) == FALSE)
{
if( empty($from) )
{
$errors .= "<br/><strong>Please enter a valid Email address</strong><br/><br/>";
} else {
$errors .= "<strong>Your E-mail address entered is not valid, please go back and try again.<br/><br/></strong>";
}
}
if ( empty($name) ) { $errors .= "<strong>Please enter your full name.<br/><br/></strong>"; }
if ( empty($location) ) { $errors .= "<strong>Please enter a valid service call location.<br/><br/></strong>"; }
echo $errors;
if ( empty($errors) )
{
$sendTo = "me@ my site .com";
$subject = SCAF;
$headers = "From: " . $from;
$message = $name;$location;
mail($sendTo, $subject, $message, $headers);
header("location: http://www. mysite. com/thanks.html");
}
}
?>
the "$service" field represents 4 radio buttons which i ultimately want a user to choose between, and i want the data to come back to me as the value of whichever was selected. how would i accomplish this?
here's also the html code of the form if it would help: (it's incomplete btw)
<form name=contactform action=scaf.php method=post>
<table>
<tr><br>
<tr><td colspan="3" style="font-weight: bold; text-align: center; text-decoration: underline; ">Service Call Authorization</td></tr>
<td align=left>Name:</td>
<td width="15"> </td>
<td><input size=35 maxlength=35 type=text name=name
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Service Location:(street address)</td>
<td width="40"> </td>
<td><input size=35 maxlength=35 type=text name=location
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>City & State:</td>
<td> </td>
<td><input size=30 maxlength=30 type=text name=city
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Zip code:</td>
<td> </td>
<td><input size=10 maxlength=10 type=text name=zip
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Primary Residence:</td>
<td> </td>
<td><input size=35 maxlength=35 type=text name=residence
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr><td><B><U>Contact Information</U></B></td></tr>
<tr>
<td align=left>Home Phone:</td>
<td> </td>
<td><input size=15 maxlength=15 type=text name=home
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Cell Phone:</td>
<td> </td>
<td><input size=15 maxlength=15 type=text name=cell
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Office Phone:</td>
<td> </td>
<td><input size=15 maxlength=15 type=text name=office
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Primary Fax:</td>
<td> </td>
<td><input size=15 maxlength=15 type=text name=primaryfax
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Local Phone:</td>
<td> </td>
<td><input size=15 maxlength=15 type=text name=local
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Local Fax:</td>
<td> </td>
<td><input size=15 maxlength=15 type=text name=localfax
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Email:</td>
<td> </td>
<td><input size=35 maxlength=35 type=text name=from
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Describe the problem:</td>
<td> </td>
<td><input size=35 maxlength=35 type=text name=problem
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Have you encountered any other problems in the past year?:</td>
<td> </td>
<td><input size=35 maxlength=35 type=text name=previousproblems
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Has another person or company worked on your pool/spa in the past year? If so, who?:</td>
<td> </td>
<td><input size=35 maxlength=35 type=text name=company
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr><td colspan="3" style="text-align: center; ">Some repairs require an initial diagnostic visit. What would you like us to do?</td></tr>
<tr><td><Input type = 'Radio' Name ='Service' value= 'Diagnostic'>Diagnostic Call Only.</td></tr>
<td><Input type = 'Radio' Name ='service' value= 'repair550'>Diagnostic & repair under $550.</td></tr>
<td><Input type = 'Radio' Name ='service' value= 'repair800'>Diagnostic & repair up to $800.</td></tr>
<td><Input type = 'Radio' Name ='service' value= 'fixit'>Do whatever it takes to fix it.</td></tr>
<tr><td><a href="scafterms.html">Click Here to see the complete terms and conditions of our Service Call Authorization Form.</a>
<tr>
<td> </td>
<td> </td>
<td><input type=submit value=" Submit " name=submit style="font-size: 10pt; font-family: Tahoma"></td></tr>
</table>
</div>
</form>
I'm posting this on all the web help forums that I know as I'm in a bind for time and need to get this done ASAP or i will lose time, customers, money....So I would reallly really appreciate any and all help that you may have, tips, tricks, general advice or helpful criticism, I just need to get this damn form working and done!:wall:
Thank you all very much for your time and hopefully for your help. I'll be here. thanks again!
I wouldnt consider myself a newbie in general but i still have a whole lot to learn. Im familiar with PHP scripting but i definitely wouldnt call myself an expert quite yet.
I have a website that i've hosted some forms/contracts on that use php to return the data to me in email form. I've tried to use the same PHP script that I use for my contact us page as a template for the php for all my forms/agreements-just editing them a bit.
The problem that i've run into is when a user clicks submit, I want it to obviously return to me all of the input data the user has typed in all of the text fields, as well as a couple radio button values.
My problem is that when i recieve the email, it will only send me one field value at a time...for example I only recieve the user's name in my email when I should be collecting their name, address, credit card, etc......This was never a problem for my contact page because the only input field is the body of the message anyway.
also, when the data is returned to me I need a better way of organizing it; right now if it sends me back someones name for example, it will simply say in the first and only line of my email message: John Smith.
I would like it to say Name: John Smith, in other words Iwould like to receive the data in the closest form possible to the way i distributed it. if I ask for an email on my form i want it to come back as Email: email@email.com
here's the code:
<?php
$name = trim($_POST['name']);
$location = trim($_POST['location']);
$city = trim($_POST['city']);
$zip = trim($_POST['zip']);
$home = trim($_POST['home']);
$cell = trim($_POST['cell']);
$office = trim($_POST['office']);
$primaryfax = trim($_POST['primaryfax']);
$local = trim($_POST['local']);
$localfax = trim($_POST['localfax']);
$from = trim($_POST['from']);
$problem = trim($_POST['problem']);
$previousproblem = trim($_POST['previousproblem']);
$company = trim($_POST['company']);
$service = trim($_POST['service']);
function checkEmail($from)
{
if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $from))
{
return FALSE;
}
list($Username, $Domain) = split("@",$from);
if(getmxrr($Domain, $MXHost))
{
return TRUE;
}
else
{
if(fsockopen($Domain, 25, $errno, $errstr, 30))
{
return TRUE;
}
else
{
return FALSE;
}
}
}
if( isset( $_POST['submit'] ) || !empty( $_POST['submit'] ) )
{
$errors = '';
if(checkEmail($from) == FALSE)
{
if( empty($from) )
{
$errors .= "<br/><strong>Please enter a valid Email address</strong><br/><br/>";
} else {
$errors .= "<strong>Your E-mail address entered is not valid, please go back and try again.<br/><br/></strong>";
}
}
if ( empty($name) ) { $errors .= "<strong>Please enter your full name.<br/><br/></strong>"; }
if ( empty($location) ) { $errors .= "<strong>Please enter a valid service call location.<br/><br/></strong>"; }
echo $errors;
if ( empty($errors) )
{
$sendTo = "me@ my site .com";
$subject = SCAF;
$headers = "From: " . $from;
$message = $name;$location;
mail($sendTo, $subject, $message, $headers);
header("location: http://www. mysite. com/thanks.html");
}
}
?>
the "$service" field represents 4 radio buttons which i ultimately want a user to choose between, and i want the data to come back to me as the value of whichever was selected. how would i accomplish this?
here's also the html code of the form if it would help: (it's incomplete btw)
<form name=contactform action=scaf.php method=post>
<table>
<tr><br>
<tr><td colspan="3" style="font-weight: bold; text-align: center; text-decoration: underline; ">Service Call Authorization</td></tr>
<td align=left>Name:</td>
<td width="15"> </td>
<td><input size=35 maxlength=35 type=text name=name
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Service Location:(street address)</td>
<td width="40"> </td>
<td><input size=35 maxlength=35 type=text name=location
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>City & State:</td>
<td> </td>
<td><input size=30 maxlength=30 type=text name=city
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Zip code:</td>
<td> </td>
<td><input size=10 maxlength=10 type=text name=zip
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Primary Residence:</td>
<td> </td>
<td><input size=35 maxlength=35 type=text name=residence
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr><td><B><U>Contact Information</U></B></td></tr>
<tr>
<td align=left>Home Phone:</td>
<td> </td>
<td><input size=15 maxlength=15 type=text name=home
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Cell Phone:</td>
<td> </td>
<td><input size=15 maxlength=15 type=text name=cell
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Office Phone:</td>
<td> </td>
<td><input size=15 maxlength=15 type=text name=office
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Primary Fax:</td>
<td> </td>
<td><input size=15 maxlength=15 type=text name=primaryfax
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Local Phone:</td>
<td> </td>
<td><input size=15 maxlength=15 type=text name=local
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Local Fax:</td>
<td> </td>
<td><input size=15 maxlength=15 type=text name=localfax
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Email:</td>
<td> </td>
<td><input size=35 maxlength=35 type=text name=from
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Describe the problem:</td>
<td> </td>
<td><input size=35 maxlength=35 type=text name=problem
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Have you encountered any other problems in the past year?:</td>
<td> </td>
<td><input size=35 maxlength=35 type=text name=previousproblems
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr>
<td align=left>Has another person or company worked on your pool/spa in the past year? If so, who?:</td>
<td> </td>
<td><input size=35 maxlength=35 type=text name=company
style="font-family: Courier New; font-size: 10pt"></td></tr>
<tr><td colspan="3" style="text-align: center; ">Some repairs require an initial diagnostic visit. What would you like us to do?</td></tr>
<tr><td><Input type = 'Radio' Name ='Service' value= 'Diagnostic'>Diagnostic Call Only.</td></tr>
<td><Input type = 'Radio' Name ='service' value= 'repair550'>Diagnostic & repair under $550.</td></tr>
<td><Input type = 'Radio' Name ='service' value= 'repair800'>Diagnostic & repair up to $800.</td></tr>
<td><Input type = 'Radio' Name ='service' value= 'fixit'>Do whatever it takes to fix it.</td></tr>
<tr><td><a href="scafterms.html">Click Here to see the complete terms and conditions of our Service Call Authorization Form.</a>
<tr>
<td> </td>
<td> </td>
<td><input type=submit value=" Submit " name=submit style="font-size: 10pt; font-family: Tahoma"></td></tr>
</table>
</div>
</form>
I'm posting this on all the web help forums that I know as I'm in a bind for time and need to get this done ASAP or i will lose time, customers, money....So I would reallly really appreciate any and all help that you may have, tips, tricks, general advice or helpful criticism, I just need to get this damn form working and done!:wall:
Thank you all very much for your time and hopefully for your help. I'll be here. thanks again!