Help - Search - Members - Calendar
Full Version: Arg
Invision Power Services > Community Forums > Community Web Design and Coding
JeremyM
Trying to make this php mail form work...



The Form
CODE
    <td background="images/con_mid.gif" width="463" height="389" align="justify" valign="top">
      <p class="content">
      Please fill in the following information:
      </p>
      <br />
      <form name="MyForm" method="POST" action="index.php?pg=contact&act=mail&step=send">
      <p class="contactm">
        Your Name
        <br />
        <input name="name" type="text" size="45" maxlength="35"  />
        <br />&nbsp;<br />
        Your Email
        <br />
        <input name="email" type="text" size="45" maxlength="35"  />
        <br />&nbsp;<br />
        Your Message
        <br />
        <textarea name="content" cols="52" rows="10"></textarea>        
        <br />&nbsp;<br />
        <input type="hidden" name="id" value="$id" />
        <img src="images/icon.gif" /> <a href="java script:document.MyForm.submit();" class="contactm">Submit</a>
      </p>
      </form>
      <p class="content">
      Emails sent to General, Advertising, Employment, and Legal will be read and replied to within 24 hours guaranteed.
      <br />&nbsp;<br />
      <img align="middle" src="images/line_content.gif" />
      </p>
    </td>



Sending It
CODE
    <td background="images/con_mid.gif" width="463" height="389" align="justify" valign="top">
      <br />
    <?php
    
        if ($id=0) {
            
            $mto="admin@muargle.com";
            
        } elseif ($id=1) {
            
            $mto="advertise@muargle.com";
            
        } elseif ($id=2) {
            
            $mto="employment@muargle.com";
            
        } elseif ($id=3) {
            
            $mto="legal@muargle.com";
            
        } elseif ($id=4) {
            
            $mto="jeremy@muargle.com";
            
        } elseif ($id=5) {
            
            $mto="danish@muargle.com";
            
        } elseif ($id=6) {
            
            $mto="steven@muargle.com";
            
        } elseif ($id=7) {            
        
            $mto="hal@muargle.com";
            
        }
    
    ?>  
    
    <?php

        if (empty($name)) {

            echo "<p class='content'>";
            echo "<font color='#FF0000'>";
            echo "Sorry but there was an error. It seems you have not filled in all of the information needed. Please either <a href='java script:history.go(-1)'><b>Go Back</b></a> to review your form, or send a new one.";
            echo "</font>";
            echo "<p class='content'>
                      Please fill in the following information:
                     </p>
                     <br />
                     <form name='MyForm' method='POST' action='index.php?pg=contact&act=mail&step=send'>
                      <p class='contactm'>
                        Your Name
                        <br />
                        <input name='name' type='text' size='45' maxlength='35'  />
                        <br />&nbsp;<br />
                        Your Email
                        <br />
                        <input name='email' type='text' size='45' maxlength='35'  />
                        <br />&nbsp;<br />
                        Your Message
                        <br />
                        <textarea name='content' cols='52' rows='10'></textarea>        
                        <br />&nbsp;<br />
                        <input type='hidden' name='id' value='$id' />
                        <img src='images/icon.gif' /> <a href='java script:document.MyForm.submit();' class='contactm'>Submit</a>
                      </p>
                      </form>";
            echo "</p>";
            
        } elseif (empty($email)) {

            echo "<p class='content'>";
            echo "<font color='#FF0000'>";
            echo "Sorry but there was an error. It seems you have not filled in all of the information needed. Please either <a href='java script:history.go(-1)'><b>Go Back</b></a> to review your form, or send a new one.";
            echo "</font>";
            echo "<p class='content'>
                      Please fill in the following information:
                     </p>
                     <br />
                     <form name='MyForm' method='POST' action='index.php?pg=contact&act=mail&step=send'>
                      <p class='contactm'>
                        Your Name
                        <br />
                        <input name='name' type='text' size='45' maxlength='35'  />
                        <br />&nbsp;<br />
                        Your Email
                        <br />
                        <input name='email' type='text' size='45' maxlength='35'  />
                        <br />&nbsp;<br />
                        Your Message
                        <br />
                        <textarea name='content' cols='52' rows='10'></textarea>        
                        <br />&nbsp;<br />
                        <input type='hidden' name='id' value='$id' />
                        <img src='images/icon.gif' /> <a href='java script:document.MyForm.submit();' class='contactm'>Submit</a>
                      </p>
                      </form>";
            echo "</p>";
            
        } elseif (empty($content)) {

            echo "<p class='content'>";
            echo "<font color='#FF0000'>";
            echo "Sorry but there was an error. It seems you have not filled in all of the information needed. Please either <a href='java script:history.go(-1)'><b>Go Back</b></a> to review your form, or send a new one.";
            echo "</font>";
            echo "<p class='content'>
                      Please fill in the following information:
                     </p>
                     <br />
                     <form name='MyForm' method='POST' action='index.php?pg=contact&act=mail&step=send'>
                      <p class='contactm'>
                        Your Name
                        <br />
                        <input name='name' type='text' size='45' maxlength='35'  />
                        <br />&nbsp;<br />
                        Your Email
                        <br />
                        <input name='email' type='text' size='45' maxlength='35'  />
                        <br />&nbsp;<br />
                        Your Message
                        <br />
                        <textarea name='content' cols='52' rows='10'></textarea>        
                        <br />&nbsp;<br />
                        <input type='hidden' name='id' value='$id' />
                        <img src='images/icon.gif' /> <a href='java script:document.MyForm.submit();' class='contactm'>Submit</a>
                      </p>
                      </form>";
            echo "</p>";
            
        } elseif (empty($id)) {

            echo "<p class='content'>";
            echo "<font color='#FF0000'>";
            echo "Sorry but there was an error. It seems you have not filled in all of the information needed. Please either <a href='java script:history.go(-1)'><b>Go Back</b></a> to review your form, or send a new one.";
            echo "</font>";
            echo "<p class='content'>
                      Please fill in the following information:
                     </p>
                     <br />
                     <form name='MyForm' method='POST' action='index.php?pg=contact&act=mail&step=send'>
                      <p class='contactm'>
                        Your Name
                        <br />
                        <input name='name' type='text' size='45' maxlength='35'  />
                        <br />&nbsp;<br />
                        Your Email
                        <br />
                        <input name='email' type='text' size='45' maxlength='35'  />
                        <br />&nbsp;<br />
                        Your Message
                        <br />
                        <textarea name='content' cols='52' rows='10'></textarea>        
                        <br />&nbsp;<br />
                        <input type='hidden' name='id' value='$id' />
                        <img src='images/icon.gif' /> <a href='java script:document.MyForm.submit();' class='contactm'>Submit</a>
                      </p>
                      </form>";
            echo "</p>";
            
        } else {

            echo "<p class='content'>";
            print ("Thanks! An email has been sent to our applications department with the information you submitted. You will recieve a call with more information on your application within 48 hours.");
            echo "</p>";
                
                $to = $mto;
                $subject = "Message from Muargle Media";
                $body = "
                <br />&nbsp;<br />
                <b>$name</b> has sent you an email. Here is their message:
                <br />&nbsp;<br />
                <br />&nbsp;<br />
                $content
                <br />&nbsp;<br />
                <br />&nbsp;<br />";
                $from = $email;

            mail($to,$subject,$body);
        }

    ?>
    <br />&nbsp;<br />
        <img align="middle" src="images/line_content.gif" />
    </td>



There's no errors, it just won't send the mail out...
Digi
You sure sendmail is installed and/or your php.ini file is properly configured to handle mail? I didn't review that form, but if you are running a dev server on windows, windows does not come with a standard stmp mail client.
JeremyM
I'm 100% that everything with the server is fine and that it's my crap coding tongue.gif
JeremyM
Ehh...bump!
Klass
out of curisoity how do you know your server sends mail?
JeremyM
The owner of the company told me...
Κeith
Just write a mail.php page and have it do nothing but send an e-mail.

CODE
<?php
mail('your@email.host', 'testing', 'testing');
?>


If that works then you'll need to narrow it down from there. Start with post vars.
JeremyM
Like I said before, I can send emails, but my php coding won't allow me...
Digi
So, you have checked that mail was properly sent with a script similar to the above? Why is answering (or doing) simple things so hard for people?

(retorts expected response)

You haven't said that you have actually did the tests people have suggested, but simply said that "the owner of the company said it was true". This isn't evidence enough to prove that your script is in the wrong.

I can say that MetalFrog is a transvestite and people might think I am telling the truth. Doesn't make it correct though.... or does it ph34r.gif
Κeith
dry.gif It does.











n't.
Digi
laugh.gif
JeremyM
Yes of course I did the script...and it sent, can someone review my coding please?
JeremyM
Can anyone please review this code?
Κeith
You still haven't answered our questions. >_< What else is there for us to review?
JeremyM
Can you please mention what questions you asked?
Klass
yes we can mention them "Scroll Up" too see them.
JeremyM
The only thing you asked for was if the sendmail is installed and if the php.ini file was configured proberly. This is easily found out by doing that 3 lined php code, which I did and said worked. Did you guys not see that?
Digi
There is nothing that I see wrong with the script. Again, make sure that php mail (not the same as sendmail) is proerly configured.
Kyanar
Nothing you can see wrong... UNLESS... you DO have Register Globals turned on, right?

(If so, eww, why?)

Since if you don't, that will all fail because $id will be undefined!
Digi
sleep.gif good catch
JeremyM
QUOTE(Kyanar @ Aug 2 2006, 02:17 AM) *
Nothing you can see wrong... UNLESS... you DO have Register Globals turned on, right?

(If so, eww, why?)

Since if you don't, that will all fail because $id will be undefined!


How would I be able to turn on/off?
Kyanar
QUOTE(JeremyM @ Aug 3 2006, 05:44 AM) *
How would I be able to turn on/off?
It depends on your server config. You would need to contact your webhost to find out the appropriate method for your server. Alternatively, and this is DEFINITELY what I would recommend, replace all instances of variables in your code like $id with "$_REQUEST['variable-name']" replacing variable-name with the name of the field in the HTML form.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.