My PHP form will not send email or give me an error
- demonmaestro
- Gold Member


- Joined: Jun 21, 2006
- Posts: 485
- Loc: Conroe, Texas
- Status: Offline
another quick question. i am sure its easy.
what i am trying to do is if the domain is correct from the $_GET['d'] then i want it to display the email form. it does display the form but it will not send the email or give me an error. Also eventually the final if d=whatever will have multiple domains.
for instance $domain = $_GET['d'];
this is what i currently have
what i am trying to do is if the domain is correct from the $_GET['d'] then i want it to display the email form. it does display the form but it will not send the email or give me an error. Also eventually the final if d=whatever will have multiple domains.
for instance $domain = $_GET['d'];
Code: [ Select ]
if($domain== "mydomain"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
else if($domain== "mydomain2"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
else if($domain== "mydomain3"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
else if($domain== "mydomain2"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
else if($domain== "mydomain3"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
- if($domain== "mydomain"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
- else if($domain== "mydomain2"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
- else if($domain== "mydomain3"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
this is what i currently have
PHP Code: [ Select ]
<? $domain = $_GET['d'];
function sendmail($domain){
function spamcheck($field)
{
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
return TRUE;
}
else
{
return FALSE;
}
}
if (isset($_REQUEST['email']))
{$mailcheck = spamcheck($_REQUEST['email']);
if ($mailcheck==FALSE)
{
echo "<div align='center'>There was an error in sending your email. Please try again.<br><a href='".$domain."'>Click here to go back.</a></div";
}
else
{
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$mailedby = "-fNoReply@LilNetwork.com" ;
$name = $_REQUEST['name'];
$domain = $_REQUEST['domain'];
$offer = $_REQUEST['offer'];
$body = "From ".$name.",\n"
."Subject: ".$domain."\n"
."Domain: ".$Domain."\n"
."Offer: ".$offer."\n"
."Message:".$message."\n\n"
."This message has been sent via LilNetwork.com";
mail("admin@lilnetwork.com", "Domain Sales VIA Lilnetwork website",
$body, "From: $email",$mailedby );
echo "<div align='center'>Thank you for using our mail form.<br><a href='".$domain."'>Click here to go back.</a></div>";
}
}
else
{
echo "<form action='' enctype='multipart/form-data' style='margin:0px; padding:0px '>
<table width='248' border='1'>
<tr>
<td width='238'>Name:
<input type='text' name='name' id='name'></td>
</tr>
<tr>
<td>Email:
<input name='email' type='text' id='email'></td>
</tr>
<tr>
<td>Domain:
<input name='domain' type='text' disabled id='domain' value='".$domain."' readonly='readonly'></td>
</tr>
<tr>
<td>Offer:
<input name='offer' type='text' id='offer' value='$'></td>
</tr>
<tr>
<td>Message:
<textarea name='message' id='message' cols='45' rows='5'></textarea></td>
</tr>
<tr>
<td><input type='reset' name='Reset' id='button' value='Reset'>
<input type='submit' name='button2' id='button2' value='Submit'></td>
</tr>
</table>
</form>
";}
};
if($domain== "mydomain"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
else if($domain== "mydomain2"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
else if($domain== "mydomain3"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
else {echo"We are sorry but we cannot find what you are looking for.";} ?>
function sendmail($domain){
function spamcheck($field)
{
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
return TRUE;
}
else
{
return FALSE;
}
}
if (isset($_REQUEST['email']))
{$mailcheck = spamcheck($_REQUEST['email']);
if ($mailcheck==FALSE)
{
echo "<div align='center'>There was an error in sending your email. Please try again.<br><a href='".$domain."'>Click here to go back.</a></div";
}
else
{
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$mailedby = "-fNoReply@LilNetwork.com" ;
$name = $_REQUEST['name'];
$domain = $_REQUEST['domain'];
$offer = $_REQUEST['offer'];
$body = "From ".$name.",\n"
."Subject: ".$domain."\n"
."Domain: ".$Domain."\n"
."Offer: ".$offer."\n"
."Message:".$message."\n\n"
."This message has been sent via LilNetwork.com";
mail("admin@lilnetwork.com", "Domain Sales VIA Lilnetwork website",
$body, "From: $email",$mailedby );
echo "<div align='center'>Thank you for using our mail form.<br><a href='".$domain."'>Click here to go back.</a></div>";
}
}
else
{
echo "<form action='' enctype='multipart/form-data' style='margin:0px; padding:0px '>
<table width='248' border='1'>
<tr>
<td width='238'>Name:
<input type='text' name='name' id='name'></td>
</tr>
<tr>
<td>Email:
<input name='email' type='text' id='email'></td>
</tr>
<tr>
<td>Domain:
<input name='domain' type='text' disabled id='domain' value='".$domain."' readonly='readonly'></td>
</tr>
<tr>
<td>Offer:
<input name='offer' type='text' id='offer' value='$'></td>
</tr>
<tr>
<td>Message:
<textarea name='message' id='message' cols='45' rows='5'></textarea></td>
</tr>
<tr>
<td><input type='reset' name='Reset' id='button' value='Reset'>
<input type='submit' name='button2' id='button2' value='Submit'></td>
</tr>
</table>
</form>
";}
};
if($domain== "mydomain"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
else if($domain== "mydomain2"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
else if($domain== "mydomain3"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
else {echo"We are sorry but we cannot find what you are looking for.";} ?>
- <? $domain = $_GET['d'];
- function sendmail($domain){
- function spamcheck($field)
- {
- $field=filter_var($field, FILTER_SANITIZE_EMAIL);
- if(filter_var($field, FILTER_VALIDATE_EMAIL))
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- if (isset($_REQUEST['email']))
- {$mailcheck = spamcheck($_REQUEST['email']);
- if ($mailcheck==FALSE)
- {
- echo "<div align='center'>There was an error in sending your email. Please try again.<br><a href='".$domain."'>Click here to go back.</a></div";
- }
- else
- {
- $email = $_REQUEST['email'] ;
- $message = $_REQUEST['message'] ;
- $mailedby = "-fNoReply@LilNetwork.com" ;
- $name = $_REQUEST['name'];
- $domain = $_REQUEST['domain'];
- $offer = $_REQUEST['offer'];
- $body = "From ".$name.",\n"
- ."Subject: ".$domain."\n"
- ."Domain: ".$Domain."\n"
- ."Offer: ".$offer."\n"
- ."Message:".$message."\n\n"
- ."This message has been sent via LilNetwork.com";
- mail("admin@lilnetwork.com", "Domain Sales VIA Lilnetwork website",
- $body, "From: $email",$mailedby );
- echo "<div align='center'>Thank you for using our mail form.<br><a href='".$domain."'>Click here to go back.</a></div>";
- }
- }
- else
- {
- echo "<form action='' enctype='multipart/form-data' style='margin:0px; padding:0px '>
- <table width='248' border='1'>
- <tr>
- <td width='238'>Name:
- <input type='text' name='name' id='name'></td>
- </tr>
- <tr>
- <td>Email:
- <input name='email' type='text' id='email'></td>
- </tr>
- <tr>
- <td>Domain:
- <input name='domain' type='text' disabled id='domain' value='".$domain."' readonly='readonly'></td>
- </tr>
- <tr>
- <td>Offer:
- <input name='offer' type='text' id='offer' value='$'></td>
- </tr>
- <tr>
- <td>Message:
- <textarea name='message' id='message' cols='45' rows='5'></textarea></td>
- </tr>
- <tr>
- <td><input type='reset' name='Reset' id='button' value='Reset'>
- <input type='submit' name='button2' id='button2' value='Submit'></td>
- </tr>
- </table>
- </form>
- ";}
- };
- if($domain== "mydomain"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
- else if($domain== "mydomain2"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
- else if($domain== "mydomain3"){echo "<h2>$domain.com Is for sale.</h2><br>";sendmail($domain);}
- else {echo"We are sorry but we cannot find what you are looking for.";} ?>
Thanks, Josh --DemonMaestro
www.LilNetwork.com
Fun Website www.ShoutsCloud.com
www.LilNetwork.com
Fun Website www.ShoutsCloud.com
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
August 28th, 2012, 12:35 am
- Bigwebmaster
- Site Admin


- Joined: Dec 20, 2002
- Posts: 8926
- Loc: Seattle, WA & Phoenix, AZ
- Status: Offline
I am not sure if this is the cause of the problem, but on your form your are not specifying a method or an action. I would recommend you put your method as POST here. So:
Secondly I notice you are using $_REQUEST vs $_GET or $_POST. I would recommend not using $_REQUEST and just get the varibles via the method you plan to use. Overall this tends to make scripts more secure as a $_REQUEST combines COOKIE, GET, AND POST with COOKIE data always taking precedence.
Finally it looks like you have your spamcheck function inside of your sendmail function. I would separate that out of the sendmail function as it might cause scope issues. A variable declared in the outer function will not be visible in the inner function unless you make the variable global inside that inner function. I don't think you are doing that here, but it can make things confusing.
Hopefully that gives you a place to start, maybe one of these issues will resolve your problem, let us know your new updated code and if the problem still exists.
HTML Code: [ Select ]
<form action='nameofscript.php' enctype='multipart/form-data' style='margin:0px; padding:0px' method="post">
Secondly I notice you are using $_REQUEST vs $_GET or $_POST. I would recommend not using $_REQUEST and just get the varibles via the method you plan to use. Overall this tends to make scripts more secure as a $_REQUEST combines COOKIE, GET, AND POST with COOKIE data always taking precedence.
Finally it looks like you have your spamcheck function inside of your sendmail function. I would separate that out of the sendmail function as it might cause scope issues. A variable declared in the outer function will not be visible in the inner function unless you make the variable global inside that inner function. I don't think you are doing that here, but it can make things confusing.
Hopefully that gives you a place to start, maybe one of these issues will resolve your problem, let us know your new updated code and if the problem still exists.
Ozzu Hosting - Want your website on a fast server like Ozzu?
- demonmaestro
- Gold Member


- Joined: Jun 21, 2006
- Posts: 485
- Loc: Conroe, Texas
- Status: Offline
well its fixed now
<? function spamcheck($field){
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
if(filter_var($field, FILTER_VALIDATE_EMAIL)){
return TRUE;
}else{
return FALSE;
}
}/*End spamcheck*/
function sendmail($domain){
if (isset($_POST['email'])){
$mailcheck = spamcheck($_POST['email']);
if ($mailcheck==FALSE){
echo "<div align='center'>There was an error in sending your email. Please try again.<br><a href='contactus.php'>Click here to go back.</a></div";
}else {
$email = $_POST['email'] ;
$message = $_POST['message'] ;
$mailedby = "-fNoReply@LilNetwork.com" ;
$name = $_POST['name'];
$domain = $_POST['domain'];
$offer = $_POST['offer'];
$body = "From ".$name.",\n"
."Domain: ".$domain."\n"
."Offer: ".$offer."\n"
."Message:".$message."\n\n"
."This message has been sent via LilNetwork.com";
mail("admin@lilnetwork.com", "Domain Sales VIA Lilnetwork website", $body, "From: $email",$mailedby );
echo "<div align='center'>Thank you for using our mail form.<br><a href='".$domain."'>Click here to go back.</a></div>";
}
}else{
echo "<form method='POST' enctype='multipart/form-data' style='margin:0px; padding:0px '>
<table width='248' border='1'>
<tr>
<td width='238'>Name:<input type='text' name='name' id='name'></td>
</tr>
<tr>
<td>Email: <input name='email' type='text' id='email'></td>
</tr>
<tr>
<td>Domain: <input name='domain' type='text' id='domain' value='".$domain."' readonly='readonly'></td>
</tr>
<tr>
<td>Offer: <input name='offer' type='text' id='offer' value='$'></td>
</tr>
<tr>
<td>Message: <textarea name='message' id='message' cols='45' rows='5'></textarea></td>
</tr>
<tr>
<td><input type='reset' name='Reset' id='button' value='Reset'> <input type='submit' name='button2' id='button2' value='Submit'></td>
</tr>
</table>
</form>";
} /*End mailcheck*/
}/*end sendmail*/
$domain = $_GET['domain'];
if($domain== "testdomain"){
echo "<h2>$domain.com Is for sale.</h2><br>";
sendmail($domain);
}else{
echo "Coming Soon!";
}
?>
PHP Code: [ Select ]
<? function spamcheck($field){
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
if(filter_var($field, FILTER_VALIDATE_EMAIL)){
return TRUE;
}else{
return FALSE;
}
}/*End spamcheck*/
function sendmail($domain){
if (isset($_POST['email'])){
$mailcheck = spamcheck($_POST['email']);
if ($mailcheck==FALSE){
echo "<div align='center'>There was an error in sending your email. Please try again.<br><a href='contactus.php'>Click here to go back.</a></div";
}else {
$email = $_POST['email'] ;
$message = $_POST['message'] ;
$mailedby = "-fNoReply@LilNetwork.com" ;
$name = $_POST['name'];
$domain = $_POST['domain'];
$offer = $_POST['offer'];
$body = "From ".$name.",\n"
."Domain: ".$domain."\n"
."Offer: ".$offer."\n"
."Message:".$message."\n\n"
."This message has been sent via LilNetwork.com";
mail("admin@lilnetwork.com", "Domain Sales VIA Lilnetwork website", $body, "From: $email",$mailedby );
echo "<div align='center'>Thank you for using our mail form.<br><a href='".$domain."'>Click here to go back.</a></div>";
}
}else{
echo "<form method='POST' enctype='multipart/form-data' style='margin:0px; padding:0px '>
<table width='248' border='1'>
<tr>
<td width='238'>Name:<input type='text' name='name' id='name'></td>
</tr>
<tr>
<td>Email: <input name='email' type='text' id='email'></td>
</tr>
<tr>
<td>Domain: <input name='domain' type='text' id='domain' value='".$domain."' readonly='readonly'></td>
</tr>
<tr>
<td>Offer: <input name='offer' type='text' id='offer' value='$'></td>
</tr>
<tr>
<td>Message: <textarea name='message' id='message' cols='45' rows='5'></textarea></td>
</tr>
<tr>
<td><input type='reset' name='Reset' id='button' value='Reset'> <input type='submit' name='button2' id='button2' value='Submit'></td>
</tr>
</table>
</form>";
} /*End mailcheck*/
}/*end sendmail*/
$domain = $_GET['domain'];
if($domain== "testdomain"){
echo "<h2>$domain.com Is for sale.</h2><br>";
sendmail($domain);
}else{
echo "Coming Soon!";
}
?>
- <? function spamcheck($field){
- $field=filter_var($field, FILTER_SANITIZE_EMAIL);
- if(filter_var($field, FILTER_VALIDATE_EMAIL)){
- return TRUE;
- }else{
- return FALSE;
- }
- }/*End spamcheck*/
- function sendmail($domain){
- if (isset($_POST['email'])){
- $mailcheck = spamcheck($_POST['email']);
- if ($mailcheck==FALSE){
- echo "<div align='center'>There was an error in sending your email. Please try again.<br><a href='contactus.php'>Click here to go back.</a></div";
- }else {
- $email = $_POST['email'] ;
- $message = $_POST['message'] ;
- $mailedby = "-fNoReply@LilNetwork.com" ;
- $name = $_POST['name'];
- $domain = $_POST['domain'];
- $offer = $_POST['offer'];
- $body = "From ".$name.",\n"
- ."Domain: ".$domain."\n"
- ."Offer: ".$offer."\n"
- ."Message:".$message."\n\n"
- ."This message has been sent via LilNetwork.com";
- mail("admin@lilnetwork.com", "Domain Sales VIA Lilnetwork website", $body, "From: $email",$mailedby );
- echo "<div align='center'>Thank you for using our mail form.<br><a href='".$domain."'>Click here to go back.</a></div>";
- }
- }else{
- echo "<form method='POST' enctype='multipart/form-data' style='margin:0px; padding:0px '>
- <table width='248' border='1'>
- <tr>
- <td width='238'>Name:<input type='text' name='name' id='name'></td>
- </tr>
- <tr>
- <td>Email: <input name='email' type='text' id='email'></td>
- </tr>
- <tr>
- <td>Domain: <input name='domain' type='text' id='domain' value='".$domain."' readonly='readonly'></td>
- </tr>
- <tr>
- <td>Offer: <input name='offer' type='text' id='offer' value='$'></td>
- </tr>
- <tr>
- <td>Message: <textarea name='message' id='message' cols='45' rows='5'></textarea></td>
- </tr>
- <tr>
- <td><input type='reset' name='Reset' id='button' value='Reset'> <input type='submit' name='button2' id='button2' value='Submit'></td>
- </tr>
- </table>
- </form>";
- } /*End mailcheck*/
- }/*end sendmail*/
- $domain = $_GET['domain'];
- if($domain== "testdomain"){
- echo "<h2>$domain.com Is for sale.</h2><br>";
- sendmail($domain);
- }else{
- echo "Coming Soon!";
- }
- ?>
Thanks, Josh --DemonMaestro
www.LilNetwork.com
Fun Website www.ShoutsCloud.com
www.LilNetwork.com
Fun Website www.ShoutsCloud.com
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: 3 posts
- Users browsing this forum: No registered users and 205 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
