| View previous topic :: View next topic |
| Author |
Message |
jimiwa
Joined: 19 Dec 2007 Posts: 4
|
Posted: Wed Dec 19, 2007 10:24 am want to do form mailer, no previous php experience |
|
|
|
| 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
|
Posted: Thu Dec 20, 2007 3:59 pm |
|
|
|
| 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
|
Posted: Fri Dec 21, 2007 2:32 pm |
|
|
|
Yes, please write the code, that would be
great. Thanks. |
|
camoman666

Joined: 24 Jun 2006 Posts: 362 Location: Fort Walton Beach, FL, USA
|
Posted: Fri Dec 21, 2007 9:11 pm |
|
|
|
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
|
Posted: Sun Dec 23, 2007 8:42 am didn't work |
|
|
|
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
|
Posted: Mon Dec 24, 2007 4:03 pm |
|
|
|
| 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
|
Posted: Wed Dec 26, 2007 3:04 pm |
|
|
|
| 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
|
Posted: Thu Dec 27, 2007 9:41 am |
|
|
|
| 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
|
Posted: Sun Feb 24, 2008 5:53 pm When I email my input text, i wanna be in the same page. |
|
|
|
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
|
Posted: Tue Feb 26, 2008 1:59 pm |
|
|
|
| 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
|
Posted: Thu Mar 20, 2008 8:50 pm |
|
|
|
| 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
|
Posted: Fri Mar 21, 2008 3:04 am |
|
|
|
| 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
|
Posted: Fri Mar 21, 2008 10:25 am |
|
|
|
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
|
Posted: Fri Mar 21, 2008 2:50 pm |
|
|
|
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
|
Posted: Fri Mar 21, 2008 10:52 pm |
|
|
|
| Thank you. It worked great! |
|
|