It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

problem with contact script

Moderator: Malcolm

problem with contact script

Postby Phate on Mon Apr 11, 2005 4:45 am

It seems to work fine, when I use my email address... but then when someone else uses their email address... they get an error " server could not send message"

Any ideas?


Code: Select all
<? function show_form($email="",
                $message="",$subject="") {  ?>

<h2>Send us an E-mail</h2>

<form action="contact.php" method="post">

Your E-mail address:<br>
<input type=text name=email size=30
        value="<?echo $email?>"><br>

The Subject:<br>
<input type=text name=subject size=30
        value="<?echo $subject?>"><br>

Your Message:<br>
<textarea rows=5 cols=30 name=message><?echo $message?></textarea>
<br>
<input type=submit value="Send E-mail">
</form>

<? } 


if (!isset($email) or !isset($message)) {
     show_form();
}
else {
  if (empty($email) or empty($message)) {
      echo "<H1>There is a Problem:</H1>";
      if (empty($email)) {
         echo "I need your email address in
      order to write back.  Please fill
      it in below.  Thank you.";
      }
      if (empty($message)) {
          echo "You did not write anything. 
               Please write something.  Thank You."; 
      }
      show_form($email,$message,$subject);
  }
  else {
     if (empty($subject)) {
             $subject="your email"; 
     }


     $sent = mail( "thefuryband@gmail.com",
      $subject,$message, "From: $email" );

     if ($sent) {
        echo "<H1>Your Message Has Been Sent.</H1>"; 
        echo "Thank you, <b>$email</b>.  <p>I'll
                  will read your email regarding '
                  <b>$subject</b> and reply soon."; 
     }
     else {
        echo "<H1>There is a Problem:</H1>
              <p>The server was unable to send your
                   mail.";
        }
  }
}
?>
Web-Developing since '03
Image
User avatar
Phate
500+ Club
 
Posts: 826
Joined: Sun Nov 21, 2004 4:12 am
Location: 127.0.0.1

Postby webmaster on Mon Apr 11, 2005 6:53 am

What if you replace:
Code: Select all
$sent = mail( "thefuryband@gmail.com",$subject,$message, "From: $email" );


With:
Code: Select all
$sent = mail($email,$subject,$message, "From: $email" );


?
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby Phate on Mon Apr 11, 2005 9:35 pm

then where do i put where the email is sent to?
Web-Developing since '03
Image
User avatar
Phate
500+ Club
 
Posts: 826
Joined: Sun Nov 21, 2004 4:12 am
Location: 127.0.0.1

Postby Malcolm on Mon Apr 11, 2005 11:56 pm

Mail function:
mail -- Send mail
Description
bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )
Image
User avatar
Malcolm
100+ Club
 
Posts: 198
Joined: Thu Oct 07, 2004 9:53 pm
Location: Ontario, Canada

Postby Phate on Tue Apr 12, 2005 12:51 am

im not sure waht that means... I need to clarify $email as thefuryband@gmail.com right?

but then how will i know who sent it?

right now, you can look at the script in use at http://thefury.zbrooks.com/contact.php
Web-Developing since '03
Image
User avatar
Phate
500+ Club
 
Posts: 826
Joined: Sun Nov 21, 2004 4:12 am
Location: 127.0.0.1

Postby Malcolm on Tue Apr 12, 2005 1:59 am

Code: Select all
mail( {To Address}, {Title}, {Message Body}, {SMTP Mail Headers}, {Additional Params});


Anyways, looking at the code and your error why not just replace your mail() call with this:
Code: Select all
$message = "This message was sent from ".$email.":\n\n".$message;
$sent = mail("thefuryband@gmail.com", $subject,$message);
Image
User avatar
Malcolm
100+ Club
 
Posts: 198
Joined: Thu Oct 07, 2004 9:53 pm
Location: Ontario, Canada

Postby Phate on Tue Apr 12, 2005 3:44 am

thanks a lot malcolm!!
Web-Developing since '03
Image
User avatar
Phate
500+ Club
 
Posts: 826
Joined: Sun Nov 21, 2004 4:12 am
Location: 127.0.0.1


Who is online

Users browsing this forum: No registered users and 0 guests