Old 06-30-2006   #1 (permalink)
A$s On Fiyah
 
ecntrc's Avatar
 
Join Date: May 2005
Location: Ewa Beach, Hawaii
Posts: 601

Send a message via Yahoo to ecntrc
Need Help building A form

So Ive used like sites to do the submit part for me. I know how to do the fields and all that but its the submit that gets to me. I dont know how to do it correctly. Id rather have it be mailed to my client. I dont want any information to be available either to anyone like it getting put up on the web if u know what I mean. Can someone help me out please? This sounds so damn easy and its on the tip of my tounge as Im sitting here but for some stupid reason I just cant get it to work.. I dont have the code because I erased it. I got fustrated. Just the submit and reset. How do I do it? Anyone? I always greatly appreciate help. I hate working from a computer that your not familiar with or that isnt yours. just hate it.
__________________
google is my lover, whos yours?
ecntrc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 06-30-2006   #2 (permalink)
Eternal Being
 
Join Date: Feb 2006
Location: Finland
Posts: 239

HTML Code:
<form action="mailto:me@mydomain.com" method="post">
<input type="text" name="foo" />
<input type="text" name="bar" />
<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
</form>
This will open up users e-mail client and put your email address to the TO field and the form fields as the body. You can also add subject like this
HTML Code:
<form action="mailto:me@mymail.com?subject=Subject">
If you want something more you have to code it with something else than HTML.
__________________
Telos is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 06-30-2006   #3 (permalink)
Recursively call who?
 
GoldNetX's Avatar
 
Join Date: Nov 2003
Location: Pittsburgh, PA
Posts: 294

Send a message via AIM to GoldNetX
If you want to use PHP you could do the following:

A the top of the page:
Code:
<?php

if (isset($_POST['emailSubmit']))
      mail($_POST['emailTo'], $_POST['emailSubject'], $_POST['emailBody']);

?>
Then use this as your form:

Code:
<form method="POST" action="<?php echo $_SERVER['PHPSELF']; ?>
<input type="hidden" name="emailTo" value="whoToSendTo@Somewhere.com" />
<input type="text" name="emailSubject" />
<textarea name="emailBody"></textarea>
<input type="submit" name="emailSubmit" value="Send Email" />
</form>
Just replace => whoToSendTo@Somewhere.com, with whoever you want the email to go to.
__________________

www.gusmayo.com
- Maybe a story or two -


www.jaloobie.com
... your new home ...

www.webinkproductions.com
- professional web application design -
GoldNetX is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-03-2006   #4 (permalink)
A$s On Fiyah
 
ecntrc's Avatar
 
Join Date: May 2005
Location: Ewa Beach, Hawaii
Posts: 601

Send a message via Yahoo to ecntrc
Ok heres what i have

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
body {
background-image: url("g8pat04.gif");
	font: 12px/24px "Georgia", "Trebuchet MS", Arial, Helvetica, sans-serif;
	color: #000000;
}

#title {
	width: 330px;
	height: 26px;
	color: #000000;
	font: bold 15px/18px "Georgia", "Trebuchet MS", Arial, Helvetica, sans-serif;
	padding-top: 5px;
	background: transparent url("g8pat04.gif") no-repeat;
	text-transform: uppercase;
	letter-spacing: 3px;
	text-align: center;
}

form {
	width: 335px;
}

.col1 {
	text-align: right;
	width: 135px;
	height: 31px;
	margin: 0;
	float: left;
	margin-right: 2px;

}

.col2 {
	width: 195px;
	height: 31px;
	display: block;
	float: left;
	margin: 0;
	
}

.col2comment {
	width: 195px;
	height: 98px;
	margin: 0;
	display: block;
	float: left;
}

.col1comment {
	text-align: right;
	width: 135px;
	height: 98px;
	float: left;
	display: block;
	margin-right: 2px;
	
}

div.row {
	clear: both;
	width: 335px;
}

.submit {
	height: 29px;
	width: 330px;
	background: url(bg_submit.gif) no-repeat;
	padding-top: 5px;
	clear: both;
} 

.input {
	background-image: url("g8pat04.gif");
	font: 11px/14px "Lucida Grande", "Trebuchet MS", Arial, Helvetica, sans-serif;
	color: #000000;
	margin: 4px 0 5px 8px;
	padding: 1px;
	border: 1px solid #000000;
}

.textarea {
	border: 1px solid #000000;
	background-image: url("g8pat04.gif");
	font: 11px/14px "Lucida Grande", "Trebuchet MS", Arial, Helvetica, sans-serif;
	color: #000000;
	margin: 4px 0 5px 8px;
}

</style>
</head>

<body>
<form action="#" method="post">
 <?php

if (isset($_POST['emailSubmit']))
      mail($_POST['emailTo'], $_POST['emailSubject'], $_POST['emailBody']);

?>
</p>
<form method="POST" action="<?php echo $_SERVER['PHPSELF']; ?>
<input type="hidden" name="emailTo" value="mst0ke@yahoo.com" />

  <p>&nbsp;</p>
<div id="title">CLASS SIGN UP </div>
<div class="row">
  <label class="col1">Full Name:&nbsp;&nbsp;</label>
<span class="col2"><input name="name" class="input" type="text" id="name" size="20" tabindex="1"  /></span>

</div>
<div class="row">
  <label class="col1">Address:&nbsp;&nbsp;</label>
  <span class="col2">
  <input name="address" class="input" type="text" id="address" size="25" tabindex="2" />
</span>
</div>
<div class="row"><label class="col1">City:&nbsp;&nbsp;</label>
<span class="col2"><input name="city" class="input" type="text" id="city" value="" size="2" tabindex="3" /></span>
</div>
<div class="row"><label class="col1">State:&nbsp;&nbsp;</label>
<span class="col2"><input name="state" class="input" type="text" id="state" value="" size="9" tabindex="4" /></span>
</div>
<div class="row"><label class="col1">Age:&nbsp;&nbsp;</label>
<span class="col2"><input name="age" class="input" type="text" id="age" value="" size="3" tabindex="5" /></span>
</div>
<div class="row"></div>

<div class="row"><label class="col1comment">Comment:&nbsp;&nbsp;</label>
<span class="col2comment"><textarea cols="20" class="textarea" rows="4" name="comment" id="comment" tabindex="6" ></textarea></span>
</div>
<div align="center" class="submit">
  <input type="submit" name="emailSubmit2" value="Submit" />
  </form>
</div>
</body>
</html>
the url you can view to see it http://www.tarachanel.com/CWClassForm.html

What my problem is now, when I hit submit it says the method is not allowed? not sure whats wrong?
__________________
google is my lover, whos yours?
ecntrc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-03-2006   #5 (permalink)
A$s On Fiyah
 
ecntrc's Avatar
 
Join Date: May 2005
Location: Ewa Beach, Hawaii
Posts: 601

Send a message via Yahoo to ecntrc
I totally forgot to say thank you. Very much ;0)
__________________
google is my lover, whos yours?
ecntrc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-03-2006   #6 (permalink)
Eternal Being
 
Join Date: Feb 2006
Location: Finland
Posts: 239

You have two forms there, why? then one with action="#" and the one with action php_self. The one with php_self action misses the closing " from the action parameter. Also remember that you can't execute PHP code in a .html file (unless you have defined php to run also html files which I doubt). You need to have php installed in your web server and then the file needs to be .php.
__________________
Telos is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-03-2006   #7 (permalink)
Recursively call who?
 
GoldNetX's Avatar
 
Join Date: Nov 2003
Location: Pittsburgh, PA
Posts: 294

Send a message via AIM to GoldNetX
Yeah, as Telos said, start by making sure the file is saved as .php and PHP is installed on the server. Next remove the the line:

Code:
Line 100: <form action="#" method="post">
also the submit input should have the name emailSubmit, as in:

Code:
Line 139: <input type="submit" name="emailSubmit" value="Submit" />
Now the way the php code section works is, when the user submits the form the server is going to grab the data in the fields and store that data temporarly on the server. So once it does you can then access the data on the server using the php variable $_POST. This variable is like an array where the keys are the name attributes of the form items.

So to access the data from the form you have, you would use:

$_POST['emailTo']
$_POST['name']
$_POST['address']
$_POST['city']
$_POST['state']
$_POST['age']
$_POST['comment']

So here is an example of how you could use these references to construct and email:

Code:
<?php

if ($_POST['emailSubmit']){
     $body = "The following information was just submitted by a user: \n\n Full Name: " . $_POST['name'] . "\n Address: " . $_POST['address'] . "\n City: " . $_POST['city'] . "\n State: " . $_POST['state'] . "\n Age: " . $_POST['age'] . "\n Comment: " . $_POST['comment'];
     mail($_POST['emailTo'], "Replace this with what you want the subject to be", $body);
}

?>
Then just replace the part about the subject with what you want the subject of your email to be and you should be set.
__________________

www.gusmayo.com
- Maybe a story or two -


www.jaloobie.com
... your new home ...

www.webinkproductions.com
- professional web application design -
GoldNetX is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-04-2006   #8 (permalink)
A$s On Fiyah
 
ecntrc's Avatar
 
Join Date: May 2005
Location: Ewa Beach, Hawaii
Posts: 601

Send a message via Yahoo to ecntrc
thanks.. is there some way to make it not php? i dont know php, just i took the submit from gold and it had php, the server does has php.. thanks for your help
__________________
google is my lover, whos yours?
ecntrc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-04-2006   #9 (permalink)
Recursively call who?
 
GoldNetX's Avatar
 
Join Date: Nov 2003
Location: Pittsburgh, PA
Posts: 294

Send a message via AIM to GoldNetX
I am pretty sure you have to use some language, PHP/ASP/some scripting language, to send an email. I think you can also use CGI with scripts, but I am not profficient in CGI. But as for just HTML, I do not believe that HTML can send out emails itself from a form. HTML has no system for remembering form data if I am not mistaken.
__________________

www.gusmayo.com
- Maybe a story or two -


www.jaloobie.com
... your new home ...

www.webinkproductions.com
- professional web application design -
GoldNetX is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-05-2006   #10 (permalink)
A$s On Fiyah
 
ecntrc's Avatar
 
Join Date: May 2005
Location: Ewa Beach, Hawaii
Posts: 601

Send a message via Yahoo to ecntrc
Quote:
Originally Posted by GoldNetX
Now the way the php code section works is, when the user submits the form the server is going to grab the data in the fields and store that data temporarly on the server. So once it does you can then access the data on the server using the php variable $_POST. This variable is like an array where the keys are the name attributes of the form items.

So to access the data from the form you have, you would use:

$_POST['emailTo']
$_POST['name']
$_POST['address']
$_POST['city']
$_POST['state']
$_POST['age']
$_POST['comment']

So here is an example of how you could use these references to construct and email:

Code:
<?php

if ($_POST['emailSubmit']){
     $body = "The following information was just submitted by a user: \n\n Full Name: " . $_POST['name'] . "\n Address: " . $_POST['address'] . "\n City: " . $_POST['city'] . "\n State: " . $_POST['state'] . "\n Age: " . $_POST['age'] . "\n Comment: " . $_POST['comment'];
     mail($_POST['emailTo'], "Replace this with what you want the subject to be", $body);
}

?>
Then just replace the part about the subject with what you want the subject of your email to be and you should be set.
Would this go in the body of my page? like any specific order? can i test my sserver if i run php? which im sure i do but id like to just check. youve saved my day and your helping me learn thanks ;0) i greatly appreciate it
__________________
google is my lover, whos yours?
ecntrc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-05-2006   #11 (permalink)
Eternal Being
 
Join Date: Feb 2006
Location: Finland
Posts: 239

You can check if your website is php powered by writing this to test.php file and trying to run it.
PHP Code:
<?php echo "testing...1...2...3..."?>
if you can see the text inside " " and not the code itself then you are ok.

Another way to check for php which gives you a bit of extra info also is to write this inside that file
PHP Code:
phpinfo(); 
Note that some hosts have disabled the use of phpinfo function but if you need for example the php version or something like that then this is very useful.

The code you showed comes to the beginning of the file. As you can see it checks if the form has been submitted (variable $_POST['emailSubmit'] exists) and if yes then sends the mail. It actually doesn't matter where you put it but it's usefull to put it before your form and then do if else statement where you display a thank you text inside this if like this
Code:
if ($_POST['emailSubmit']){
     $body = "The following information was just submitted by a user: \n\n Full Name: " . $_POST['name'] . "\n Address: " . $_POST['address'] . "\n City: " . $_POST['city'] . "\n State: " . $_POST['state'] . "\n Age: " . $_POST['age'] . "\n Comment: " . $_POST['comment'];
     mail($_POST['emailTo'], "Replace this with what you want the subject to be", $body);

// Thank you text
echo "thank you for sending the mail";

else {

// Show the form just like before
}
__________________
Telos is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-05-2006   #12 (permalink)
Recursively call who?
 
GoldNetX's Avatar
 
Join Date: Nov 2003
Location: Pittsburgh, PA
Posts: 294

Send a message via AIM to GoldNetX
Yeah there are two ways of going about it, as Telos showed. You could just copy and paste the php code at the top of your page (just for ease of reading).

Code:
<?php

if ($_POST['emailSubmit']){
     $body = "The following information was just submitted by a user: \n\n Full Name: " . $_POST['name'] . "\n Address: " . $_POST['address'] . "\n City: " . $_POST['city'] . "\n State: " . $_POST['state'] . "\n Age: " . $_POST['age'] . "\n Comment: " . $_POST['comment'];
     mail($_POST['emailTo'], "Replace this with what you want the subject to be", $body);
}

?>

<!DOCTYPE ... rest of your code ...
Or you could do it so that the page will show the form, but once it is submitted it will send the email and display a thank you message instead of the form. This code piece would do it:

Code:
<?php

if ($_POST['emailSubmit']){
     $body = "The following information was just submitted by a user: \n\n Full Name: " . $_POST['name'] . "\n Address: " . $_POST['address'] . "\n City: " . $_POST['city'] . "\n State: " . $_POST['state'] . "\n Age: " . $_POST['age'] . "\n Comment: " . $_POST['comment'];
     mail($_POST['emailTo'], "Replace this with what you want the subject to be", $body);

echo "Thank you, and email has been sent out with your information.";

}else{ // Allow the HTML form to be displayed

?>

<form method="POST" action="<?php echo $_SERVER['PHPSELF']; ?>" >
<input type="hidden" name="emailTo" value="mst0ke@yahoo.com" />

  <p>&nbsp;</p>
<div id="title">CLASS SIGN UP </div>
<div class="row">
  <label class="col1">Full Name:&nbsp;&nbsp;</label>
<span class="col2"><input name="name" class="input" type="text" id="name" size="20" tabindex="1"  /></span>

</div>
<div class="row">
  <label class="col1">Address:&nbsp;&nbsp;</label>
  <span class="col2">
  <input name="address" class="input" type="text" id="address" size="25" tabindex="2" />
</span>
</div>
<div class="row"><label class="col1">City:&nbsp;&nbsp;</label>
<span class="col2"><input name="city" class="input" type="text" id="city" value="" size="2" tabindex="3" /></span>
</div>
<div class="row"><label class="col1">State:&nbsp;&nbsp;</label>
<span class="col2"><input name="state" class="input" type="text" id="state" value="" size="9" tabindex="4" /></span>
</div>
<div class="row"><label class="col1">Age:&nbsp;&nbsp;</label>
<span class="col2"><input name="age" class="input" type="text" id="age" value="" size="3" tabindex="5" /></span>
</div>
<div class="row"></div>

<div class="row"><label class="col1comment">Comment:&nbsp;&nbsp;</label>
<span class="col2comment"><textarea cols="20" class="textarea" rows="4" name="comment" id="comment" tabindex="6" ></textarea></span>
</div>
<div align="center" class="submit">
  <input type="submit" name="emailSubmit" value="Submit" />
  </form>
</div>

<?php } ?>
__________________

www.gusmayo.com
- Maybe a story or two -


www.jaloobie.com
... your new home ...

www.webinkproductions.com
- professional web application design -
GoldNetX is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-05-2006   #13 (permalink)
"Enter Random Text Here"
 
sancho's Avatar
 
Join Date: Jun 2005
Location: Handsacre, UK
Posts: 37

Send a message via MSN to sancho Send a message via Skype™ to sancho
Try saving the file with a .php extension. If you dont the server wont know its php and wont process it.

Sancho
__________________

Portfolio: www.simonmclaughlin.co.uk
Cheap UK hosting: www.qubithosting.com
sancho is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-07-2006   #14 (permalink)
A$s On Fiyah
 
ecntrc's Avatar
 
Join Date: May 2005
Location: Ewa Beach, Hawaii
Posts: 601

Send a message via Yahoo to ecntrc
I got an email in my inbox well 2, looks like someone tried testing it out but i dont know who did. because i got it in my email box. did someone over here test it?
__________________
google is my lover, whos yours?
ecntrc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 07-08-2006   #15 (permalink)
A$s On Fiyah
 
ecntrc's Avatar
 
Join Date: May 2005
Location: Ewa Beach, Hawaii
Posts: 601

Send a message via Yahoo to ecntrc
ok i put two in two together. lol. thanks. took me awhile. sorry. i just have to add a list now. thanks again guys..
__________________
google is my lover, whos yours?
ecntrc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump