Page 1 of 1

Simple Text Box

Posted: Fri Dec 18, 2009 3:47 pm
by AliJ
Hey,
I made a simple PHP email sending program and I just need to add a text box for the 'Message', 'Subject', 'From', and 'To'.
In the code I am using they are already set, so every time I want to use it I need to change them.I'm confused how to do this simple thing for some reason..... :?:

Here is the code:

Code: Select all

<?php
$to = "email@example.com";
$subject = "Subject;
$message = "Message";
$from = "your@email.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
Any Help is appreciated.
Thank you,

Ali J.

Re: Simple Text Box

Posted: Fri Dec 18, 2009 4:19 pm
by Elven6
You want to display text boxes that link to the variables you mentioned? Sorry, I don't completely understand your question. If you simply want a text box to appear where one can write text you can use simple HTML as shown below.

Code: Select all

<form method="post" action="">
<textarea name="comments" cols="40" rows="5">
Enter your comments here...
</textarea><br>
<input type="submit" value="Submit" />
</form>
http://www.quackit.com/html/codes/html_ ... x_code.cfm

As a example

Re: Simple Text Box

Posted: Fri Dec 18, 2009 4:25 pm
by AliJ
Yes, I want to display text boxes that link to the variables I mentioned.Do you know how?
Well thanks in advance.
Please Reply.

Re: Simple Text Box

Posted: Fri Dec 18, 2009 4:32 pm
by daedalus__
use html form elements then use php to parse the data input to the form.

Re: Simple Text Box

Posted: Fri Dec 18, 2009 4:37 pm
by AliJ
Could you give a little example with my code? I'm not very good a PHP, and quite new. Like a white page with the text boxes
there?

Re: Simple Text Box

Posted: Fri Dec 18, 2009 4:51 pm
by AliJ
Anyone able to give a little example? I really would appreciate some help.
Thank you.

Re: Simple Text Box

Posted: Fri Dec 18, 2009 4:53 pm
by daedalus__
no. i don't answer questions with code 80% of the time. the other thing is that forms are html not php.

the php you posted will work fine. use the post superglobal to retrieve the values of the forms.

http://php.net/manual/en/language.varia ... ternal.php

http://www.w3.org/TR/html401/interact/forms.html
http://www.w3schools.com/html/html_forms.asp