Jump to content

Recommended Posts

May somebody please tell me why this script is not working. All I am trying to do is create a simple email script.

 

<?php
if(isset($_POST['submit'])){
$ip = $_SERVER['REMOTE_ADDR'];
$name = $_POST['aname'];
$aemail = $_POST['aemail'];
$amessage = $_POST['amessage'];
$email = '//my email here';

if((!$name) || (!$aemail) || (!$amessage) || (!$asubject)){?>
<script>javascript:alert("<?php
       if(!$name){
      echo"No Name!"; }
	if(!$aemail){
      echo"No Email Address!";
       if(!$asubject){
      echo"<br />No Subject!<br /><br />";
  if(!$amessage){
      echo"No message!";?>")</script> <?php
  

} else {
     mail($email, $subject, $message, "From:$aemail" . phpversion());?>
<script>window.location="contactus?page=mainc";</script>
<style type="text/css">
<!--
.style6 {font-size: 12px}

-->
    </style>


<?php }
}
}
}

}

?>


 

 

thanks in advanced

Link to comment
https://forums.phpfreaks.com/topic/143563-solved-not-emailing/
Share on other sites

Well I deleted 2 } and I got an $end error so I added some back until the error went away.

here is my code now:


<?php
if(isset($_POST['submit'])){
$ip = $_SERVER['REMOTE_ADDR'];
$name = $_POST['aname'];
$aemail = $_POST['aemail'];
$amessage = $_POST['amessage'];
$email = '//my email here';


if((!$name) || (!$aemail) || (!$amessage) || (!$asubject)){?>
<script>javascript:alert("<?php 
       if(!$name){
      echo"No Name!"; }
	if(!$aemail){
      echo"No Email Address!";
       if(!$asubject){
      echo"<br />No Subject!<br /><br />";
  if(!$amessage){
      echo"No message!";?>")</script> <?
  

} else {
     mail($email, $subject, $message, "From:$aemail" . phpversion());?>
<script>window.location="contactus?page=mainc";</script>
<style type="text/css">
<!--
.style6 {font-size: 12px}

-->
    </style>


<?php }
} } }}

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/143563-solved-not-emailing/#findComment-753286
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.