Simple Text Box

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AliJ
Forum Commoner
Posts: 32
Joined: Sun Dec 06, 2009 8:03 pm

Simple Text Box

Post 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.
Elven6
Forum Newbie
Posts: 5
Joined: Fri Dec 18, 2009 12:58 pm

Re: Simple Text Box

Post 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
AliJ
Forum Commoner
Posts: 32
Joined: Sun Dec 06, 2009 8:03 pm

Re: Simple Text Box

Post 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.
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: Simple Text Box

Post by daedalus__ »

use html form elements then use php to parse the data input to the form.
AliJ
Forum Commoner
Posts: 32
Joined: Sun Dec 06, 2009 8:03 pm

Re: Simple Text Box

Post 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?
AliJ
Forum Commoner
Posts: 32
Joined: Sun Dec 06, 2009 8:03 pm

Re: Simple Text Box

Post by AliJ »

Anyone able to give a little example? I really would appreciate some help.
Thank you.
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: Simple Text Box

Post 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
Post Reply