PDA

View Full Version : php email? rep+



Thomas
12-11-2011, 08:08 PM
I have 1 field for the user to fill it then when they click Submit it sends that 1 piece of information to my email.

How can I do this?

triston220
12-11-2011, 08:25 PM
<?php
$to = "[email protected]"; // The email address to send the message to.
$body ="Message here " . $_POST['textboxname']; //The body of our message. Separate lines with "\n".
$body =wordwrap($body,70); // 70 Chars per line
$subject = "Hello"; //The subject of our message.
mail($to, $subject, $body); //Send the message
?>

Thomas
12-11-2011, 09:04 PM
<?php
$to = "example[@]@expample.com"[/@]; // The email address to send the message to.
$body ="Message here " . $_POST['textboxname']; //The body of our message. Separate lines with "\n".
$body =wordwrap($body,70); // 70 Chars per line
$subject = "Hello"; //The subject of our message.
mail($to, $subject, $body); //Send the message
?>
I need to email the information they put in the textbox to me.
this is my html form thingy:

<html>
<br /><br /><br /> <center> <form action="send.php" method="POST"> name: <input type="text" name="name" /><br /> <i>(Case sensitive)</i><br /> <input type="submit" value="Submit" /> </form> </center> </html>

and i need to sent the information given in that name field to my email.

triston220
12-11-2011, 09:46 PM
I need to email the information they put in the textbox to me.
this is my html form thingy:

<html>
<br /><br /><br /><center><form action="send.php" method="POST">name: <input type="text" name="name" /><br /><i>(Case sensitive)</i><br /><input type="submit" value="Submit" /></form></center></html>

and i need to sent the information given in that name field to my email.

What's the name of the textbox.

Thomas
12-11-2011, 09:48 PM
What's the name of the textbox.
It does say in that html code i posted...? or i am being stupid? :P

<html> <br /><br /><br /> <center> <form action="send.php" method="POST"> name: <input type="text" name="name" /><br /> <i>(Case sensitive)</i><br /> <input type="submit" value="Submit" /> </form> </center> </html>

triston220
12-11-2011, 10:18 PM
<?php
$to="[email protected]";//Theemailaddresstosendthemessageto.
$body=$_POST['name'];//Thebodyofourmessage.Separatelineswith"\n".
$body=wordwrap($body,70);//70Charsperline
$subject="Hello";//Thesubjectofourmessage.
mail($to,$subject,$body);//Sendthemessage
?>

Thomas
12-11-2011, 10:28 PM
<?php
$to="example[@]@expample.com"[/@];//Theemailaddresstosendthemessageto.
$body=$_POST['name'];//Thebodyofourmessage.Separatelineswith"\n".
$body=wordwrap($body,70);//70Charsperline
$subject="Hello";//Thesubjectofourmessage.
mail($to,$subject,$body);//Sendthemessage
?>
It sends (it think) but i do not get any email

try it: www.supersurvival.net/join

Thomas
13-11-2011, 08:14 AM
still not working, anyone?

Thomas
13-11-2011, 09:09 AM
<html>
<br /><br /><br />
<center> <form method="POST"> Minecraft name: <input type="text" name="name" /><br /> <i>(Case sensitive)</i><br /> <input type="submit" value="Submit" /> </form> </center>
<?php mail('t.*******[@]@*****.co.uk', 'SuperSurvival', $_POST["name"][/@];); ?>
</html>

Excuse my how bad i am at html and php :P

Zak
13-11-2011, 09:50 AM
Make a separate page for your php code (e.g. mail.php).

Then link to it with your form, example
<form action='mail.php' method='POST'>

Thomas
13-11-2011, 10:08 AM
Make a separate page for your php code (e.g. mail.php).

Then link to it with your form, example
<form action='mail.php' method='POST'>
I have done that but I still don't get the email :S

Zak
13-11-2011, 11:01 AM
The mail server is probably rejecting your email(s) as spam. Try putting additional information, such as a subject, message, headers etc

Thomas
13-11-2011, 11:11 AM
mail('t.sharratt[@]@yahoo.co.uk', 'SuperSurvival', $_POST["name"])[/@];

Don't see what is wrong with that :S

triston220
13-11-2011, 11:57 AM
mail('t.sharratt[@]@yahoo.co.uk', 'SuperSurvival', $_POST["name"])[/@];

Don't see what is wrong with that :S



$body = $_POST['name'];
mail('[email protected]', 'SuperSurvival', body);

Thomas
13-11-2011, 12:18 PM
$body = $_POST['name'];
mail('t.sharratt[@]@yahoo.co.uk', 'SuperSurvival', body)[/@];
this error:

Notice Use of undefined constant body - assumed 'body' in/opt/lampp/htdocs/join/send.phpon line 12

Jonster
13-11-2011, 02:23 PM
this error:

Notice Use of undefined constant body - assumed 'body' in/opt/lampp/htdocs/join/send.phpon line 12

Change it to: $body

Thomas
13-11-2011, 02:32 PM
Change it to: $body
No errors but i still don't get the email

triston220
13-11-2011, 02:52 PM
Change it to: $body

Yup, sorry.

\/Have you checked your spam box?

Thomas
13-11-2011, 03:11 PM
Yup, sorry.

\/Have you checked your spam box?
yeah :S

is it possible to send the information onto a different page.

e.g:
First person submits a name
then another person does the same
then another
then another

on the page it makes a list like:
name1
name2
name3
name4

or would that be more complicated since i'd also need a to remove the name after I have read it.

David
13-11-2011, 05:45 PM
yeah :S

is it possible to send the information onto a different page.

e.g:
First person submits a name
then another person does the same
then another
then another

on the page it makes a list like:
name1
name2
name3
name4

or would that be more complicated since i'd also need a to remove the name after I have read it.

change your form to


<form action="write.php" method="POST">

then make a new php file called write.php with this in it


<?php

$file = "./name.txt";
$write = $_POST['name'] . "\n";

file_put_contents($file, $write, FILE_APPEND);

?>

should create a file called name.txt with whatever people input, keep previous entries and set a new line

Thomas
13-11-2011, 05:56 PM
change your form to


<form action="write.php" method="POST">

then make a new php file called write.php with this in it


<?php

$file = "./name.txt";
$write = $_POST['name'] . "\n";

file_put_contents($file, $write, FILE_APPEND);

?>

should create a file called name.txt with whatever people input, keep previous entries and set a new line
is it possible to display that on a .html file?

Zak
13-11-2011, 05:58 PM
The mail() function doesn't support SMTP authentication, so most mail servers will reject mail from sources they don't recognize.

In regards to my earlier post. This could be the error? Seen as though some of the provided solutions would work.

The php mail function itself is just a pain.

-----------------------------------------------

At the post above, it is possible to display it in the same document. Make sure it's saved as a .php file, put the php code in between the <head> </head> tags. Then put your form in the <body> </body> tags.

That's what i do anyway, although I've just started learning PHP. Done like a login, register, members area and admin panel in a day. Super easy to learn, especially when I usually have to do Java.

David
13-11-2011, 05:59 PM
is it possible to display that on a .html file?

yeah just change it to whatever.html


$file = "./filename.html";

Thomas
13-11-2011, 06:09 PM
yeah just change it to whatever.html


$file = "./filename.html";
This might be getting too hard but is there anyway you can put a check box next to each name and you can tick it and click delete and it removes it from the html file. Thats the last think i'd need doing :)

also:
Warning file_put_contents(./admin.html) [function.file-put-contents]: failed to open stream: Permission denied in (http://www.supersurvival.net/join/function.file-put-contents) /opt/lampp/htdocs/join/write.php on line 6

Zak
14-11-2011, 12:24 AM
This might be getting too hard but is there anyway you can put a check box next to each name and you can tick it and click delete and it removes it from the html file. Thats the last think i'd need doing :)


That so confused me on what you're trying to do :P

If I wanted the names storing I would use an SQL database upon clicking submit or send or w.e it stores the name. Then have an additional button maybe in the admin panel to delete records from that table. Or you could just delete records manually in phpmyadmin.

That's more than likely not what you wanted to do but hey ho. I think this is getting way too overcomplicated for a simple mail function :P

-Tyquan
14-11-2011, 01:32 AM
I don't get it ! I have the same problem !

---------- Post added 13-11-2011 at 08:39 PM ----------

www.habbtunez.com/jobs/ It doesnt send !



<?php
$to = "jobs[@]@habbtunez.com"[/@]; // The email address to send the message to.
$body ="Message here " . $_POST['textboxname']; //The body of our message. Separate lines with "\n".
$body =wordwrap($body,70); // 70 Chars per line
$subject = "Job Application"; //The subject of our message.
mail($to, $subject, $body); //Send the message
?>

Want to hide these adverts? Register an account for free!