HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
want to do form mailer, no previous php experience
Post new topic   Reply to topic    HTML Help Forum Index -> PHP
View previous topic :: View next topic  
Author Message
jimiwa



Joined: 19 Dec 2007
Posts: 4

PostPosted: Wed Dec 19, 2007 10:24 am     want to do form mailer, no previous php experience Reply with quote

I don't know if php is the best way to do this, but I want to do a form mailer that submits an email in legible format, preferrably the user would just click submit and the information would be sent without opening up the email in a window, and a popup window would say the information has been sent. However, I do not know anything about php or how to integrate it into html, I have only used javascript with html. I have previous programming experience in other languages, too, so I am capable of learning, but need to find clear directions that explain the code. Can someone point me in the right direction for this project?
camoman666



Joined: 24 Jun 2006
Posts: 362
Location: Fort Walton Beach, FL, USA

PostPosted: Thu Dec 20, 2007 3:59 pm     Reply with quote

If you want to learn how to do this yourself and incorperate it into your programming, search for the "mail()" function in PHP. If you want me to write a code that sends the email and a popup saying it sent, reply to this saying so.
jimiwa



Joined: 19 Dec 2007
Posts: 4

PostPosted: Fri Dec 21, 2007 2:32 pm     Reply with quote

Yes, please write the code, that would be
great. Thanks.
camoman666



Joined: 24 Jun 2006
Posts: 362
Location: Fort Walton Beach, FL, USA

PostPosted: Fri Dec 21, 2007 9:11 pm     Reply with quote

The form would be:
Code:
<form action="mail.php" method="post">
<input type="text" name="to">
<input type="text" name="subject">
<textarea name="body" style="height: 300px; width: 500px;">
<input type="submit" value="send">
</form>


And the PHP file "mail.php" would have:
Code:
<html>
 <head>
  <title>PHP Mail</title>
 </head>
 <body>
  <?
   mail($_POST["to"],$_POST["subject"],$_POST["body"],"from: YOUREMAILatWHATEVER.HUH");
  ?>
 </body>
</html>
jimiwa



Joined: 19 Dec 2007
Posts: 4

PostPosted: Sun Dec 23, 2007 8:42 am     didn't work Reply with quote

I tried this code and it didn't work. I noticed
you started with <? and on some
internet pages I saw code starting with <?php
so I tried it both ways but neither way worked. (I don't know much about php so I don't know if this makes a difference anyway) The only difference is that I used a space in the parameters next to a comma, which I didn't think would make a difference but I don't know. It doesn't look to me like this example is going to produce a popup window. Also, when I did run this example, the browser opens up the php file as a web page. Is there a way of getting around this so it doesn't leave the page I was on?
camoman666



Joined: 24 Jun 2006
Posts: 362
Location: Fort Walton Beach, FL, USA

PostPosted: Mon Dec 24, 2007 4:03 pm     Reply with quote

Yes there is a way to do this to make a popup and not to leave the page, but I think the server you're on does not support email with PHP.
jimiwa



Joined: 19 Dec 2007
Posts: 4

PostPosted: Wed Dec 26, 2007 3:04 pm     Reply with quote

I didn't know that I had to be running off of a server. I was testing it at home. I will soon have a server to test off of but not now. Could you tell me the code for how to add the popup without leaving the page, if it's not too much trouble?
camoman666



Joined: 24 Jun 2006
Posts: 362
Location: Fort Walton Beach, FL, USA

PostPosted: Thu Dec 27, 2007 9:41 am     Reply with quote

Code:
<script type="text/javascript">
<!--
open("page.html");
-->
</script>


This code, unlike the PHP, will work at home.
jose



Joined: 24 Feb 2008
Posts: 8

PostPosted: Sun Feb 24, 2008 5:53 pm     When I email my input text, i wanna be in the same page. Reply with quote

When I email my input text, i wanna be in the same page. I used that code, but still have the same problem. any idea? or where should i put the code.


type="text/javascript">
<!--
open("page.html");
-->
</script>
camoman666



Joined: 24 Jun 2006
Posts: 362
Location: Fort Walton Beach, FL, USA

PostPosted: Tue Feb 26, 2008 1:59 pm     Reply with quote

So when you use the "open()" function it changes the location of the parent window? I've never heard of that. I think I'm not understanding what you're saying. Would you mind re-wording your problem for me?
jose



Joined: 24 Feb 2008
Posts: 8

PostPosted: Thu Mar 20, 2008 8:50 pm     Reply with quote

camoman666 wrote:
So when you use the "open()" function it changes the location of the parent window? I've never heard of that. I think I'm not understanding what you're saying. Would you mind re-wording your problem for me?


Im building my website in html. I have many fields in a form that I want to send to my email, using PHP. the PHP file is this:

<html>
<head>
<title>PHP Mail</title>
</head>
<body>
<?
mail($_POST["to"],$_POST["subject"],$_POST["body"], "From: myusernameatnoreplay.com");
?>
</body>
</html>

this form just sent me body content(body field). How can I add all fields from the form to send to my mail too?
Other question.... When I do click on my form, my browser change the location to my PHP FILE. How can I tell the browser to open other page or other URL I want in the same Window?
camoman666



Joined: 24 Jun 2006
Posts: 362
Location: Fort Walton Beach, FL, USA

PostPosted: Fri Mar 21, 2008 3:04 am     Reply with quote

Let me see what your form looks like. After I see what that looks like I'll be able to give you what you need.
jose



Joined: 24 Feb 2008
Posts: 8

PostPosted: Fri Mar 21, 2008 10:25 am     Reply with quote

this is my form in HTML file:

<form name="send-form" method="post" enctype="multipart/form-data" action="sendmail.php" >
<input type = "hidden" name = "subject" value = "Personal Info form">
<input type = "hidden" name = "to" value = "mymailathotmail.com">

<label for="FirstName" style="float:left; width:140px;">First Name:*</label><input type="text" name="FirstName" id="FirstName" value="" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>

<label for="LastName" style="float:left; width:140px;">Last Name:*</label><input type="text" name="LastName" id="LastName" value="" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>
<label for="Address" style="float:left; width:140px;">Address:*</label><input type="text" name="Address" id="Address" value="" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>
<label for="City" style="float:left; width:140px;">City:*</label><input type="text" name="City" id="City" value="" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>
<label style="float:left;width:140px;"
style="clear:left;height:20px;"> </div>
<label for="ZIPCode" style="float:left; width:140px;">ZIP Code:*</label><input type="text" name="ZIPCode" id="ZIPCode" value="" maxlength="5" onKeyPress="return numbersonly(this, event)" style="width:200px;"><div style="clear:left;height:20px;"> </div>
<label for="HomePhone" style="float:left; width:140px;">Home Phone:*</label><input type="text" name="HomePhone" id="HomePhone" value="" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>

<input type="submit" name="NextStep" value="Next Step>>" id="NextStep" />

I added all the fields from my form and sent to my email addres now. my PHP FILE is so far:

<html>
<head>
<title>PHP Mail</title>
</head>
<body>
<?

$message = "First Name: ".$_POST["FirstName"]."\n";
$message .= "Last Name: ".$_POST["LastName"]."\n";
$message .= "Address: ".$_POST["Address"]."\n";
$message .= "City: ".$_POST["City"]."\n";
$message .= "State: ".$_POST["State"]."\n";
$message .= "ZIP Code: ".$_POST["ZIPCode"]."\n";
$message .= "Home Phone: ".$_POST["HomePhone"]."\n";
$message .= "Cell Phone: ".$_POST["Cell Phone"]."\n";

$headers = "from: someoneusernameatdomain.com";
mail($to, $subject, $message, $headers);

?>
</body>
</html>


So it is workin now that. I got all info in my email. but my other question is
When I do click on "submit" button in my HTML form, my browser change the location to my PHP FILE (blank page. and the URL looks like this:
http://www.domain.com/sendmail.php

How can I tell the browser to open other page or other URL I want in the same Window? for example
http://www.domain.com/index.htm in the same place my form was.
Thank you
camoman666



Joined: 24 Jun 2006
Posts: 362
Location: Fort Walton Beach, FL, USA

PostPosted: Fri Mar 21, 2008 2:50 pm     Reply with quote

Add
Code:
<script type="Text/JavaScript">
<!--
window.location = "PAGE YOU WANT WINDOW TO GO TO";
-->
</script>
<noscript>
<a href="PAGE YOU WANT WINDOW TO GO TO">Redirect Manually</a>
</noscript>

to the bottom of your PHP file.
jose



Joined: 24 Feb 2008
Posts: 8

PostPosted: Fri Mar 21, 2008 10:52 pm     Reply with quote

Thank you. It worked great!
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> PHP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial