Jump to content

form help please


chandler

Recommended Posts

Hi I am using the code below for an email form..I need to change sender's info, at the moment it displays sender (unknown)  I would like it to display example@example.com... How can this be done.

 

Thanks you for your help.

 

 

   
     $to      = "example@example.com";
                    // subject
                    $subject = ' email form ' . $subject;
                    // the mail message
                    $msg     = "From : $name \r\ne-Mail : $email \r\nSubject : $subject \r\n" . "Message : \r\n$message";
                    mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n");

$replymessage = "Hello $name
message recieved

--------------------------------------------------
Your Message:
$message
--------------------------------------------------
Thank you. ";
$message = "name: $name \nQuery: $message";
mail("$replyemail",
     "$emessage",
     "From: $email\nReply-To:  $email");
mail("$email",
     "Message: $subject",
     "$replymessage",
     "From: $replyemail\nReply-To: $replyemail");
echo $success_sent_msg;

Link to comment
Share on other sites

hi, here's the complete code i had missed some out..I'm not sure but I don't think there is a $mail variable.

Thanks for the help.

 

 <?php
                 $error    = ''; // error message
                 $name     = ''; // sender's name
                 $email    = ''; // sender's email address
                 $message  = ''; // the message itself
               	 $spamcheck = ''; // Spam check
            if(isset($_POST['send']))
            {
                 $name     = $_POST['name'];
                 $email    = $_POST['email'];
                 $message  = $_POST['message'];
               	 $spamcheck = $_POST['spamcheck'];
                if(trim($name) == '')
                {
                    $error = '<div class="errormsg">Please enter your name.</div>';
                }
            	    else if(trim($email) == '')
                {
                    $error = '<div class="errormsg">Please enter your E-mail?</div>';
                }
                else if(!isEmail($email))
                {
                    $error = '<div class="errormsg">Incorrect Email format.!</div>';
                }
				else if(trim($message) == '')
                {
                    $error = '<div class="errormsg">Message please!</div>';
                }
          	else if(trim($spamcheck) == '')
            {
            	$error = '<div class="errormsg">Please enter: Spam Check!</div>';
            }
          	else if(trim($spamcheck) != '5')
            {
            	$error = '<div class="errormsg">Spam Check: Number incorrect! 2 + 3 = ???</div>';
            }
                if($error == '')
                {
                    if(get_magic_quotes_gpc())
                    {
                        $message = stripslashes($message);
                    }
                    // the email will be sent here
                    // make sure to change this to be your e-mail
                    $to      = "example@example.com";
                    // the email subject
                    $subject = 'email form' . $subject;
                    // the mail message ( add any additional information if you want )
                    $msg     = "From : $name \r\ne-Mail : $email \r\nSubject : $subject \r\n" . "Message : \r\n$message";
                    mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n");

$replymessage = "Hello $name
We have recieved your message

--------------------------------------------------
Your Message:
$message
--------------------------------------------------
Thank you. ";
$message = "name: $name \nQuery: $message";
mail("$replyemail",
     "$emessage",
     "From: $email\nReply-To:  $email");
mail("$email",
     "Message: $subject",
     "$replymessage",
     "From: $replyemail\nReply-To: $replyemail");
echo $success_sent_msg;
	   ?>
                  <!-- Message sent! (change the text below as you wish)-->
                  <div style="text-align:left;">                  
                       <p>Thank you <b><?=$name;?></b>, we will be in touch.</p>
                  </div>
                  <!--End Message Sent-->
            <?php
                }
            }
            if(!isset($_POST['send']) || $error != '')
            {
            ?>
            <!--Error Message-->
            <?=$error;?>

Link to comment
Share on other sites

Is the unknown sender coming from the last mail() functions:

 

...
$message = "name: $name \nQuery: $message";
mail("$replyemail",
     "$emessage",
     "From: $email\nReply-To:  $email");
mail("$email",
     "Message: $subject",
     "$replymessage",
     "From: $replyemail\nReply-To: $replyemail");
echo $success_sent_msg;

 

 

I don't see where $replyemail is being set.

Link to comment
Share on other sites

Is the unknown sender coming from the last mail() functions:

 

...
$message = "name: $name \nQuery: $message";
mail("$replyemail",
     "$emessage",
     "From: $email\nReply-To:  $email");
mail("$email",
     "Message: $subject",
     "$replymessage",
     "From: $replyemail\nReply-To: $replyemail");
echo $success_sent_msg;

 

 

I don't see where $replyemail is being set.

 

Good Point There Cyber,

 

Chandler, add a line, above the mail() function to assign your chosen email address to $replyemail

$replyemail = "example@example.com"
mail(....

Link to comment
Share on other sites

You'll need to add the code inside the if() portion which gets activated after the form is submitted. For example, you could insert it here:

 

<?php
...
$msg     = "From : $name \r\ne-Mail : $email \r\nSubject : $subject \r\n" . "Message : \r\n$message";
mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n");


/*   REFRESH CODE HERE  */


$replymessage = "Hello $name
We have recieved your message
...
?>

 

 

Just keep in mind that header() must be called before an output is displayed.

Link to comment
Share on other sites

thanks Cyber,  that did fix it, I guess this php stuff is addictive I keep wanting to do more to the script.

 

I have added some java script for a countdown timer , so here is the problem hope you can help.

 

after the form is submitted it reads like so:

 

"You'll be redirected in

10 - countdown clock

secs. If not, click here.

 

Thank you, we will be in touch."

 

I would like it to be displayed all on one line like so:

"You'll be redirected in (10 - countdown clock secs). If not, click here.

 

Thanks again for all your help

 

header( "refresh:10;url=visit.php" );
echo 'You\'ll be redirected in ';
?>

<script type="text/javascript"> 
seconds = 10;

function decreaseTime(){
  document.frm.submit.value=seconds;
  seconds--;
  if(seconds<0){
    document.frm.submit.value='Submit';
    document.frm.submit.disabled=false;
    return true;
  }
  setTimeout('decreaseTime()',1000);
}

window.onload = function() {
  document.frm.submit.value=seconds;
  setTimeout('decreaseTime()',1000);
}
</script>

<form name="frm" action=""> 
  <input type="submit" name="submit" disabled />
</form>

<?php
echo 'secs. If not, click <a href="visit.php">here</a>.';

 

Link to comment
Share on other sites

how about adding a hidden field to your form, naming it "refresh" and giving it a value of "1".  Then at the top of the page :

$refresh = $_POST['refresh']
if ($refresh == 1){header( "refresh:5;url=wherever.php" );
echo 'You\'ll be redirected in about 5 secs. If not, click <a href="wherever.php">here</a>.';
$refresh = 0;
}

would that do the trick?

Link to comment
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.