12 Replies - 2329 Views - Last Post: 02 September 2011 - 07:49 PM Rate Topic: -----

#1 swim_fan08  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 238
  • Joined: 19-February 09

Php Email Form

Posted 29 August 2011 - 11:59 AM

I am currently using mezoka (the allow php 5) to upload my site and currently they dont allow the php mail(). I've tried to post a question on their forum wanting to know if there is another way that I can add a contact form, but its been 24 hours and nothing. So, while I wait, I was wondering if someone could possible help me with my php contact form? When I ran it on my local host I got a few undefined errors, I think those had to do with my variable names not matching, which I corrected. What I want my contact form to do is, when I have it on my website, I want the user to be able to put in their email address and from their email address send my an email at my yahoo email account (starr@yahoo.com).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact</title>
<link href="style.css" rel="stylesheet" type="text/css" />

</head>
<body>

<div id="templatemo_wrapper"> 

	<div id="templatemo_header">

 
        
        <ul id="social_box">
                    <li><a href="http://www.facebook.com/"><img src="images/facebook.png" alt="facebook" /></a></li>
            <li><a href="http://www.twitter.com/"><img src="images/twitter.png" alt="twitter" /></a></li>              
        </ul>
        
      	<div id="site_title">
            <h1><a href="index.htm"><img src="images/logo2.png" alt="logo" /><span></span></a></h1>
        </div> <!-- end of site_title -->
        
      
    </div> <!-- end of templatemo_header -->
    
<div id="templatemo_menu">
    	<div class="home"><a href="index.htm"></a></div>
        <ul>
          <li><a href="index.htm"><span>Home</span></a></li>
            <li><a href="test.htm"><span>Test</span></a></li>
            <li><a href="examples.htm"><span>Examples</span></a></li>
            <li><a href="question.htm"><span>Questions</span></a></li>
	    <li><a href="contact.htm"><span>Contact</span></a></li>
            <li><a href="comments.htm">Have A Comment?<span>Comments</span></a></li>
        </ul>    	
    </div> 

<!-- end of templatemo_menu -->
    
    <div id="templatemo_content_wrapper">
    	<div id="templatemo_content_top"></div>
        <div id="templatemo_content">
        
            <h2>Contact</h2>


        
            <div class="cleaner_h50"></div>
            
            	<div id="contact_form">
            
                    <h4>Quick Contact</h4>
                    
                    <form method="post" name="contact" action="email.php">
                        
                        <div class="col_w340 float_l">
                        
                            <label for="namer">Name:</label> <input name="name" type="text" class="input_field" id="author" maxlength="40" />
                          	<div class="cleaner_h10"></div>
                            
                            <label for="email">Email:</label> <input name="email" type="text" class="input_field" id="email" maxlength="40" />
                          	<div class="cleaner_h10"></div>
                            
                            
                        </div>
                        
                        <div class="col_w340 float_r">
                        
                            <label for="text">Message:</label> <textarea id="text" name="text" rows="0" cols="0" class="required"></textarea>
                            <div class="cleaner_h10"></div>
                            
                            <input type="submit" class="submit_btn float_l" name="submit" id="submit" value="Send" />
                            <input type="reset" class="submit_btn float_r" name="reset" id="reset" value="Reset" />
                            
                        </div>
                        
                   </form>

            </div> 

            <div class="cleaner"></div>
            
        </div>
        <div id="templatemo_content_bottom"></div>
	</div>
    
    <div id="templatemo_sp_box">
    
    	<div class="col_w340 float_l">
         
			</div>
        </div>
        
        <div class="col_w340 float_r">
        
			</div>
        </div>
    
    </div>
    
    <div id="templatemo_footer">

      
        Copyright  2011 <a href="www.twitter.com/">Starr</a><br/> 
        <a href="http://www.iwebsitetemplate.com" target="_parent">Website Templates</a> 
        by <a href="http://www.templatemo.com" target="_parent">Free CSS Templates</a>
    
    </div> <!-- end of templatemo_footer -->
    
</div> <!-- end of templatemo_wrapper -->    

</body>
</html>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Contact</title>
</head>

<body>
<?php
$to = "starr@yahoo.com";
$body = $_POST["message"];
$headers = "From: user@domain.com\n";
mail($to,$body,$headers);
echo "Mail sent to $to";

?>


</body>

</html>


Is This A Good Question/Topic? 0
  • +

Replies To: Php Email Form

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6064
  • View blog
  • Posts: 23,520
  • Joined: 23-August 08

Re: Php Email Form

Posted 29 August 2011 - 12:04 PM

Google PHPmailer for a possible replacement for PHP's built-in mail function.
Was This Post Helpful? 0
  • +
  • -

#3 swim_fan08  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 238
  • Joined: 19-February 09

Re: Php Email Form

Posted 29 August 2011 - 12:24 PM

View PostJackOfAllTrades, on 29 August 2011 - 01:04 PM, said:

Google PHPmailer for a possible replacement for PHP's built-in mail function.


Are PHPmailers easy or difficult to install? I've never really used a PHPmailer before.
Was This Post Helpful? 0
  • +
  • -

#4 swim_fan08  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 238
  • Joined: 19-February 09

Re: Php Email Form

Posted 30 August 2011 - 04:55 PM

I do not have a Gmail account, is there a way to test my php email contact form to make sure that it does what I want it to do? (I made some changes to my php).


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Contact</title>
</head>

<body>
<?php
		$to = "starr@yahoo.com";   
		$from    = " <no-reply@sitename.info >";
		$headers = "MIME-Version: 1.0\r\n";
		$headers.= "Content-type: text/html; charset=iso-8859-1\r\n";
		$headers.= "From: $from\r\n";
		$mail_body = "Hello World";

		if (mail($to,"Mail", $mail_body,$headers))
		{	echo " Thank you! - Your feedback has been sent! ";	}
		else
		{	echo " Thank you! - We could not send email. Please try later! ";	}


?>


</body>

</html>

This post has been edited by swim_fan08: 30 August 2011 - 07:56 PM

Was This Post Helpful? 0
  • +
  • -

#5 no2pencil  Icon User is online

  • Admiral Fancy Pants
  • member icon

Reputation: 5327
  • View blog
  • Posts: 27,246
  • Joined: 10-May 07

Re: Php Email Form

Posted 30 August 2011 - 05:24 PM

View Postswim_fan08, on 30 August 2011 - 07:55 PM, said:

I do not have a Gmail account, is there a way to test my php email contact form to make sure that it does what I want it to do?

Only way I know of is to create a gmail account, or use one that you have access to.
Was This Post Helpful? 0
  • +
  • -

#6 swim_fan08  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 238
  • Joined: 19-February 09

Re: Php Email Form

Posted 30 August 2011 - 07:01 PM

View Postno2pencil, on 30 August 2011 - 06:24 PM, said:

View Postswim_fan08, on 30 August 2011 - 07:55 PM, said:

I do not have a Gmail account, is there a way to test my php email contact form to make sure that it does what I want it to do?

Only way I know of is to create a gmail account, or use one that you have access to.


I used my yahoo account, but I got my error message that I have in php. So, I am not too sure if its my account or what.
Was This Post Helpful? 0
  • +
  • -

#7 no2pencil  Icon User is online

  • Admiral Fancy Pants
  • member icon

Reputation: 5327
  • View blog
  • Posts: 27,246
  • Joined: 10-May 07

Re: Php Email Form

Posted 30 August 2011 - 07:14 PM

All the more reason to try it with Gmail.
Was This Post Helpful? 0
  • +
  • -

#8 swim_fan08  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 238
  • Joined: 19-February 09

Re: Php Email Form

Posted 30 August 2011 - 07:18 PM

View Postno2pencil, on 30 August 2011 - 08:14 PM, said:

All the more reason to try it with Gmail.


Just got done trying it with Gmail and still got the error message. Not too sure, if I called everything right or if its just where I have the website hosted (its mezoka and they allow php 5, but not the phpmail () ).
Was This Post Helpful? 0
  • +
  • -

#9 no2pencil  Icon User is online

  • Admiral Fancy Pants
  • member icon

Reputation: 5327
  • View blog
  • Posts: 27,246
  • Joined: 10-May 07

Re: Php Email Form

Posted 30 August 2011 - 07:21 PM

If they don't allow php mail, it's possible that port 25 is blocked & they don't allow any traffic at all.
Was This Post Helpful? 0
  • +
  • -

#10 swim_fan08  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 238
  • Joined: 19-February 09

Re: Php Email Form

Posted 30 August 2011 - 07:36 PM

View Postno2pencil, on 30 August 2011 - 08:21 PM, said:

If they don't allow php mail, it's possible that port 25 is blocked & they don't allow any traffic at all.


I was reading that they do allow SMPT.

Meant SMTP.
Was This Post Helpful? 0
  • +
  • -

#11 swim_fan08  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 238
  • Joined: 19-February 09

Re: Php Email Form

Posted 02 September 2011 - 05:54 PM

I finally got my contact form working (I just found a new host that will allow me to easily do php scripts and not have to do too much coding that could potentially do harm or make thing worse). So, anyway, its working, but I want to add a few minor things to it. First, when I send a test email, in my inbox I get (unknown sender) I would like to change that to the persons name (preferably first and last name. Currently I have it set up with name thinking people will put in both.) Another thing that I want to achieve, is that also when I send a test email to my inbox, I want to be able to hit reply in my inbox and the users email shows up and I can reply to them without having to put the email in myself on my side. Finally, I would like to add a captcha code to avoid spam emails. Thanks!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact</title>
<link href="style.css" rel="stylesheet" type="text/css" />

</head>
<body>

<div id="templatemo_wrapper"> 

	<div id="templatemo_header">

 
        
        <ul id="social_box">
                    <li><a href="http://www.facebook.com/"><img src="images/facebook.png" alt="facebook" /></a></li>
            <li><a href="http://www.twitter.com/><img src="images/twitter.png" alt="twitter" /></a></li>              
        </ul>
        
      	<div id="site_title">
            <h1><a href="index.htm"><img src="images/logo2.png" alt="logo" /><span></span></a></h1>
        </div> <!-- end of site_title -->
        
      
    </div> <!-- end of templatemo_header -->
    
<div id="templatemo_menu">
    	<div class="home"><a href="index.htm"></a></div>
        <ul>
          <li><a href="index.htm"><span>Home</span></a></li>
            <li><a href="test.htm"><span>Test</span></a></li>
            <li><a href="example.htm"><span>Examples</span></a></li>
            <li><a href="gallery.htm"><span>Gallery</span></a></li>
	    <li><a href="contact.htm"><span>Contact</span></a></li>
            <li><a href="comments.htm">Have A Comment?<span>Comments</span></a></li>
        </ul>    	
    </div> 

<!-- end of templatemo_menu -->
    
    <div id="templatemo_content_wrapper">
    	<div id="templatemo_content_top"></div>
        <div id="templatemo_content">
        
            <h2>Contact</h2>



<p><b>E-mail: starr@gmail.com </b></p>

<p><b><a href="http://www.twitter.com/">Twitter</a></b></p>
        
            <div class="cleaner_h50"></div>
            
            	<div id="contact_form">
            
                    <h4>Quick Contact</h4>
                    
                    <form method="post" name="contact" action="email.php">
                        
                        <div class="col_w340 float_l">
                        
                            <label for="namer">Name:</label> <input name="name" type="text" class="input_field" id="author" maxlength="40" />
                          	<div class="cleaner_h10"></div>

 <label for="subject">Subject:</label> <input name="subject" type="text" class="input_field" id="subject" maxlength="40" />
                          	<div class="cleaner_h10"></div>

                            
                            <label for="email">Email:</label> <input name="email" type="text" class="input_field" id="email" maxlength="40" />
                          	<div class="cleaner_h10"></div>
                            
                            
                        </div>
                        
                        <div class="col_w340 float_r">
                        
                            <label for="text">Message:</label> <textarea id="text" name="text" rows="0" cols="0" class="required"></textarea>
                            <div class="cleaner_h10"></div>
                            
                            <input type="submit" class="submit_btn float_l" name="submit" id="submit" value="Send" />
                            <input type="reset" class="submit_btn float_r" name="reset" id="reset" value="Reset" />
                            
                        </div>
                        
                   </form>

            </div> 

            <div class="cleaner"></div>
            
        </div>
        <div id="templatemo_content_bottom"></div>
	</div>
    
    <div id="templatemo_sp_box">
    
    	<div class="col_w340 float_l">
         
			</div>
        </div>
        
        <div class="col_w340 float_r">
        
			</div>
        </div>
    
    </div>
    
    <div id="templatemo_footer">

      
        Copyright  2011 <a href="www.twitter.com/">Starr</a><br/> 
        <a href="http://www.iwebsitetemplate.com" target="_parent">Website Templates</a> 
        by <a href="http://www.templatemo.com" target="_parent">Free CSS Templates</a>
    
    </div> <!-- end of templatemo_footer -->
    
</div> <!-- end of templatemo_wrapper -->    

</body>
</html>






<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Contact</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php


$first_name=$_POST['name'];
$email_address=$_POST['email'];
$subject=$_POST['subject'];
$message=$_POST['text'];

mail("starr@gmail.com","Subject: $subject",
$message, "From: $email");

echo "Thank you for using our mail form.<br/>";
echo "Your email has been sent.";

?>

</body>
</html>


This post has been edited by swim_fan08: 02 September 2011 - 06:07 PM

Was This Post Helpful? 0
  • +
  • -

#12 swim_fan08  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 238
  • Joined: 19-February 09

Re: Php Email Form

Posted 02 September 2011 - 07:42 PM

Here is a live version of what I would like my contact form to do: Example

This post has been edited by swim_fan08: 02 September 2011 - 07:43 PM

Was This Post Helpful? 0
  • +
  • -

#13 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10576
  • View blog
  • Posts: 39,152
  • Joined: 27-December 08

Re: Php Email Form

Posted 02 September 2011 - 07:49 PM

1) You can use the From header in your mail() function: "From: Name <email@domain.ext>\r\n".
2) You can use the <a href="mailto:email@domain.ext"> syntax to specify an email link.
3) You can use the imagestring() function to draw the text on to the captcha image. Then it just comes down to comparing the user's input to the generated text you wrote to the image. Note that you should store this text in a variable.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1