Page 1 of 3 123 LastLast
Results 1 to 10 of 28

Thread: Can't get a simple email form to work...

  1. #1
    Join Date
    Jun 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Can't get a simple email form to work...

    I'm having problem with my email PHP form ! I've been trying for a week now and nothing I've tried will send mail to my email!! What is it that I'm doing wrong?

    I'm using Godaddy.com on a windows server. It works with both PHP and ASP, but ASP is preferred for a windows server. But all I've been getting is error or confirmation messages, but no email in my in-box! Is it me, or is it Godaddy.com?!?

    Heres a sample of my form:
    Code:
    		<div id="container">
    		<form id="form_4" name="sendmail" class="mail" 
    		 onsubmit="return validate_form_4(this)" 
    		 action="sendemail.php" method="post" target="_self">
    
    		<fieldset>
    		<legend>&nbsp;Personal&nbsp;Information&nbsp;</LEGEND>
    
    		<ul id="formFields">
    		<li><label class="desc" for="field17">Name:</label>
    		<span><input id="Fname" name="first_name" maxlength="200" class="field text" 
    		 size="14" class="memorize" value="" onkeypress="return handleEnter(this, event)" 
    		 onFocus="clearText(this)" />
    		<label class="tam">First</label></span>
    		<span><input id="Lname" name="last_name" maxlength="200" class="field text" 
    		 size="14" class="memorize" value="" onkeypress="return handleEnter(this, event)" 
    		 onFocus="clearText(this)" />
    		<label class="tam">Last</label></span>
    		<div id="hintanchor_1">
    		<a href="#" class="hintanchor" 
    		 onMouseover="showhint('Please type your (<b>REAL</b>) name.', this, event, '200px')">
    		<img src="images/about.gif" border="0" width="20" height="20" alt="" /></a>
    		</div>
    		</li>
    		<li>
    		<label class="desc" for="field8">Email:</label>
    		<div>
    		<input id="Email" name="email" maxlength="200" class="field text medium" 
    		 type="text" maxlength="255" class="memorize" value="" 
    		 onkeypress="return handleEnter(this, event)" onFocus="clearText(this)" />
    		</div>
    		<div id="hintanchor_2">
    		<a href="#" class="hintanchor" 
    		 onMouseover="showhint('Please input your (<b>REAL</b>) email address.', this, event, '150px')">
    		<img src="images/about.gif" border="0" width="20" height="20" alt="" /></a>
    		</div>
    		</li>
    		<li>
    		<label class="desc" for="field123">Attention:</label>
    		<div>
    		<select "id="Attnfield" name="Attn"> 
    		<option value=" General " selected="selected">General Message</option>
    		<option value=" Support ">Support</option>
    		<option value=" Sales/Billing ">Sales/Billing</option>
    		<option value=" Technical ">Technical</option>
    		</select>
    		</div>
    		</li>
    		<li>
    		<label class="desc" for="field124">Comments:
    		&nbsp;&nbsp;&nbsp;
    		<i><font size="-2" color="#919090">(No More than <u>1,000</u> Characters 
    		 please.)</font></i></label>
    		<div>
    		<textarea id="Comments" name="text_box" rows="10" cols="50" 
    		 class="field textarea medium" 
    		 style="width: 370px; font-family: Arial; font-size: 13px; z-index: 14"
    		 onKeyDown="textCounter(this,'progressbar1',1000)" 
    		 onKeyUp="textCounter(this,'progressbar1',1000)" 
    		 onFocus="textCounter(this,'progressbar1',1000)"></textarea>
    		<div id="progressbar1" class="progress"></div>
    		<script>textCounter(document.getElementById("maxcharfield"),"progressbar1",1000)</script>
    		</div>
    		</li>
    		</ul>
    		<div class="buttons">
    		<center>
    		<font size="1">
    		<input id="submit" name="submit" class="button" type="submit" value="Send Message" />
    		<img src="images/spacer.gif" width="20" height="2" alt="" />
    		<input id="reset" name="reset" class="button" type="reset" value="Reset Form">
    		</font>
    		</center>
    		</div>
    		</fieldset>
    		</form>
    		</div>
    As you can see, it's just a simple HTML email form. Now the php code pages.

    Ver. 1:
    Code:
    <?php
    
    $to = 'mymail@gmail.com'; 
    $name = $_POST['first_name']; 
    $name = $_POST['last_name'];
    $email = $_POST['email']; 
    $subject = $_POST['attn']; 
    $message = $_POST['text_box']; 
    
    else { 
    $from = 'From: '.$name.' <'.$email.'>'; 
    } 
    
    $subject = stripcslashes($subject); 
    $body = stripcslashes($message); 
    
    if(mail($to, $subject, $body, $from)){ 
    
    echo "Mail ($subject), was successfully sent."; 
    } 
    
    else { 
    echo "The email ($subject) could not be sent."; 
    } 
    if(mail(mail(mymail@gmail.com, $name, $subject, $message)) {   header("Location: thanks.htm"); //Sends to New Page 
       echo "<p>TEXT</p>"; // Prints out some text 
    } 
    else { 
      echo "<p>An Error Occured, Please Resend<p>"; }
    
    ?>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    <head>
    <title>I.D. Tagem...Thanks!</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <!-- meta http-equiv="refresh" content="0;url=thanks.htm" -->
    
    </head>
    <body bgcolor="#ffffff" text="#000000">
    
    <div>
    <center>
    <b>Thank you <?php print stripslashes($_REQUEST['name']); ?></b>
    <br>Your message has been sent
    <p><a href="<?php print $continue; ?>">Click here to continue</a></p>
    </center>
    </div>
    
    </body>
    </html>
    Ver. 2:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Sendemail Script</title>
    </head>
    <body>
    
    <?php
    if(!$email == "" && (!strstr($email,"@") || !strstr($email,".")))
    {
    echo "<h2>Use Back - Enter valid e-mail</h2>\n";
    $badinput = "<h2>Feedback was NOT submitted</h2>\n";
    echo $badinput;
    }
    if(empty($first_name) || empty($email) || empty($text_box )) {
    echo "<h2>Use Back - fill in all fields</h2>\n";
    }
    
    $todayis = date("l, F j, Y, g:i a") ;
    
    $attn = $attn ;
    $subject = $attn;
    
    $text_box = stripcslashes($text_box);
    
    $message = " $todayis [EST] \n
    Attention: $attn \n
    Message: $text_box \n
    From: $first_name ($email)\n
    Additional Info : IP = $ip \n
    Browser Info: $httpagent \n
    Referral : $httpref \n
    ";
    
    $from = "From: $email\r\n";
    
    mail("mymail@gmail.com", $subject, $message, $from);
    
    ?>
    
    <p align="center">
    Date: <?php echo $todayis ?>
    <br />
    Thank You : <?php echo $first_name ?> ( <?php echo $email ?> )
    <br />
    
    Attention: <?php echo $attn ?>
    <br />
    Message:<br />
    <?php $text_boxout = str_replace("\r", "<br/>", $text_box);
    echo $text_boxout; ?>
    <br />
    <?php echo $ip ?>
    
    <br /><br />
    <a href="thanks.htm"> Next Page </a>
    </p>
    
    </body>
    </html>
    Can anyone see a problem with that code that would prevent it from sending?!? Minus the name thing (ie. can't find an example for both "first" and "last" names in a PHP form field), so if anyone knows how to correct that, please feel free to post the code!

    If Godaddy.com doesn't allow PHP email forms for some odd reason, you think I would get better results with ASP? And if so, what would the code look like? I've been working with PHP forms for a month now, ASP is still new to me.


    Thanks for your time and help, Rob.
    Last edited by Graphicsgod; 06-01-2007 at 07:20 PM.

  2. #2
    Join Date
    May 2007
    Location
    Sweden
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    Hi, Rob!

    Try this code, and see if it send yet or gets any error(s);

    PHP Code:
    <?php

    // Are we going to send user to another location? True/False
    $send_to_newPage false;

    $to 'mymail@gmail.com'
    $name $_POST['first_name'] . " " $_POST['last_name'];
    $email $_POST['email']; 
    $subject $_POST['attn']; 
    $message $_POST['text_box']; 

    $from "From: " $name " <" $email ">";  

    $subject stripslashes($subject); 
    $body stripslashes($message); 


        if( 
    $send_to_newPage )
        {

            if( 
    mail($to$name$subject$body) )
            {
            
    header("Location: thanks.htm"); //Sends to New Page 
            

            else
            {
            echo 
    "<p>An Error Occured, Please Resend<p>";
            }

        }
        else
        {

            if( 
    mail($to$subject$body$from) )
            {
            echo 
    "Mail (" $subject "), was successfully sent."
            } 
            else
            {
            echo 
    "The email (" $subject ") could not be sent."
            }

        }

    $name stripslashes($name);

    ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
    <title>I.D. Tagem...Thanks!</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <!-- meta http-equiv="refresh" content="0;url=thanks.htm" -->

    </head>
    <body bgcolor="#ffffff" text="#000000">

    <div>
    <center>
    <b>Thank you <?php echo $name?></b>
    <br>Your message has been sent
    <p><a href="<?php print $continue?>">Click here to continue</a></p>
    </center>
    </div>

    </body>
    </html>
    Best regards,
    mbrodin

  3. #3
    Join Date
    Jun 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I get this message:

    Code:
    The email () could not be sent.
    With nothing in the brackets . Know why it's doing that?

    It's weird that a simple email script wont go through. Especially since my login script works fine! Albeit it's using ASP files... I just can't get it to change data in the Microsoft database file .

    http://www.idtagem.com/doctorsite/scripts/Login_test/

    You think scripting this in ASP would yield better results?

    Rob

  4. #4
    Join Date
    Jun 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Oh and thanks for showing how to do first and last names!

    Rob

  5. #5
    Join Date
    Feb 2007
    Location
    Sun City, AZ
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Form Mail Script

    There is also a PHP Form Mail Script at http://www.stadtaus.com/ that you may want to look at. It's a real simple but very powerful script Ralf has for free. I use it myself and it is very easy to customize.

    Best Regards,
    Jeff Hansen - (TeamJH)

  6. #6
    Join Date
    May 2007
    Location
    Sweden
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    Quote Originally Posted by Graphicsgod View Post
    I get this message:

    Code:
    &#239;&#187;&#191;The email () could not be sent.
    With nothing in the brackets . Know why it's doing that?

    It's weird that a simple email script wont go through. Especially since my login script works fine! Albeit it's using ASP files... I just can't get it to change data in the Microsoft database file .

    http://www.idtagem.com/doctorsite/scripts/Login_test/

    You think scripting this in ASP would yield better results?

    Rob
    I saw now that you must change $_POST['attn'] to $_POST['Attn'].
    It's big different between UpperCase and LowerCase characters in this methods. It can be that made the Error message
    Code:
    &#239;&#187;&#191;The email () could not be sent.

    Oh and thanks for showing how to do first and last names!
    You welcome!

    Best regards,
    mbrodin

  7. #7
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Quote Originally Posted by Rob
    You think scripting this in ASP would yield better results?
    ASP is no different in how it acts with the server then PHP is. They may be able to perform different functions, but the outcome of similar functions should be the same.
    - Mike

  8. #8
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Also the fact that ASP is an MS only format, so many servers that run on linux wont be able to handle it.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  9. #9
    Join Date
    Jun 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok now the "Attention" field works. Can't believe I missed that, lol. But it still gives me the same error message .

    Code:
    The email ( General ) could not be sent.

    Quote Originally Posted by boxxertrumps View Post
    Also the fact that ASP is an MS only format, so many servers that run on Linux wont be able to handle it.
    Right, my server is windows based, as stated above. Linux is, from my understanding, better with PHP files. And windows servers are better with ASP. At least thats what I've been told from the books that I've read. Or did I misinterpret that?

    Rob

  10. #10
    Join Date
    Jun 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mburt View Post
    ASP is no different in how it acts with the server then PHP is. They may be able to perform different functions, but the outcome of similar functions should be the same.
    True, true... Just trying to figure out why nothing gets sent .

    Rob

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •