Forms Help

Status
Not open for further replies.

bensbox

New Member
Messages
20
Reaction score
0
Points
0
hey
im learning how to do web developing.
i am using dreamweaver and used a simple pointless form which mailto my email
but i get this message when i try to submit

---
Method Not Allowed

The requested method POST is not allowed for the URL /FORMTEST.html.
------


what does this mean, and how can i create a working for on x10hosting?
please help!
Many thanks.B
Ben.
 

conker87

New Member
Messages
65
Reaction score
0
Points
0
Where are you submitting the form from? Your PC? Or the server? And if it's the server what's the url of the page on the server?

Are you using CGI or PHP or w/e to mail this form?
 

bensbox

New Member
Messages
20
Reaction score
0
Points
0
Ok, well could you help me a bit
im just basically learning forms.. i either wanna send the forms to email or to somewhere on the net, which i guess would be the server

what have i got to do to make it do this
and does this not work in a html page? i got to use a php page?
sorry.. im not too familular with all this, as i said, im using this to teach myself the web
thanks.
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
HTML:
<CENTER>
<FORM METHOD=POST ACTION="mailto:someone@snailmail.com" ENCTYPE="text/plain">
<INPUT TYPE="text" NAME="username"> : name <BR>
<INPUT TYPE="text" NAME="email"> : email <BR>
comments <BR>
<TEXTAREA NAME="COMMENTS" ROWS="10" WRAP="hard">
</TEXTAREA>
<INPUT NAME="redirect" TYPE="hidden" VALUE="index.html">
<INPUT NAME="NEXT_URL" TYPE="hidden" VALUE="index.html">
<BR>
<INPUT TYPE="submit" VALUE="Send">
<INPUT TYPE="reset" VALUE="Clear">
</FORM>
</CENTER>
<!-- END OF FORM -->

Does your form resemble that?
 

bensbox

New Member
Messages
20
Reaction score
0
Points
0
Well this is the code

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<p>FORM test</p>
<form id="form1" name="form1" method="post" action="">
<label></label>
<form action="mailto:ben_johnson1991@hotmail.co.uk" method="get" enctype="text/plain" name="INFOform" id="INFOform">
<p>
<label>First Name:
<input type="text" name="Name" id="Name" />
</label>
</p>
<p>
<label>Surname:
<input type="text" name="Surname" id="Surname" />
</label>
</p>
<p>
<label>Age
<input type="text" name="Age" id="Age" />
</label>
</p>
<p>&nbsp;</p>
<p>
<label for="Sub"></label>
<input type="submit" name="Sub" id="Sub" value="Submit" />
</p>
</form>
<p>&nbsp;</p>
</body>
</html>



this is the page url
http://www.bensbox.x10hosting.com/Page1.html

what do i do?
 

DefecTalisman

Community Advocate
Community Support
Messages
4,148
Reaction score
5
Points
38
First you have 2 forms in that code:
eg: <form action="">

I think it would be better for you to stick some php in there.

here is a working example of what you want, it is 2 files:

save me as anything.html
HTML:
<!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>Mail Form - DefecTalisman</title>
<style type="text/css">
<!--
.style1 {font-size: 9px}
-->
</style>
</head>
<body>
<p align="center">Basic Form and engine to work with it</p>
<form method="post" action="engine.php">
  <table width="640" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
<td>Your Name  :</td>
    <td><input type="text" size="50" maxlength="100" name="usr_name" /> 
      * </td>
  </tr>
  <tr>
    <td>Your e-mail Address : </td>
    <td><input type="text" size="50" maxlength="100" name="usr_mail" />
*</td>
  </tr>
  
  <tr>
    <td>Subject : </td>
    <td><input type="text" size="50" maxlength="100" name="subject" />
*</td>
  </tr>
  
    <tr>
      <td>Type Of Message :      </td>
      <td><select name="msg_type">
        <option value='' ="selected">Please Select A Catagory</option>
        <option value="support">Support</option>
        <option value="c_care">Customer Care</option>
      </select>
*</td>
    </tr>
    
  
    <tr>
    <td colspan="2"><div align="center">Comments *
      <br />
      <textarea rows="5" cols="50" name="comments" wrap="physical"></textarea>
    </div></td>
    </tr>
  
  <tr>
    <td colspan="2"><div align="center">
      <input type="submit" value="Preview" name="preview" />
      <input type="reset" value="Default" />
      <input type ="button" value="Back" name ="back" onclick="history.go(-1)" />
    </div></td>
    </tr>
</table>
</form>
</body>
</html>

save me as "engine.php"
PHP:
<?php
// Change to 1 to make it test itself
$test = 0;
/*
 * This section is to require inputs from the form
 */
 
$reqired_fields = array(
      'usr_name' => 'Your Name',
      'usr_mail' => 'Your e-mail Address',
      'subject' => 'Subject',
      'msg_type' => 'Type Of Message',
      'comments' => 'Comments'
      );
$null_fields = array();
foreach ($reqired_fields as $a => $z)
{
 if (isset($_POST["$a"]))
 {
  if ($_POST[$a] == FALSE) { array_push($null_fields,$z); }
 }
}
if ($null_fields == TRUE)
{
 echo 'These fields are missing :<br>';
 foreach ($null_fields as $t) { echo '-'.$t.',<br>'; }
 echo '<br>Please press back and fill them in.<br>';
 echo '<input type ="button" name ="back" value="Go Back" onclick="history.go(-1)">';
}
 

/*
 * This is where the form gets procesed if it is seen as ok by the checker
 */
if ($null_fields == FALSE)
{
 $to = 'XX e-mail-address here XX';
 $usr_name = $_POST['usr_name'];
 $usr_add = $_POST['usr_mail'];
 $type = $_POST['msg_type'];
 $sub = $_POST['subject'];
 $msg = $_POST['comments'];
 echo 'All seems fine.<br>';
 echo '<input type="submit" value="Send" name="submit" />';
}
?>
 
Last edited:

BlueJay

New Member
Messages
2
Reaction score
0
Points
0
Sorry I know I'm not involved in this discussion, but I can't help but ask. Why did he get the error message?

Or more specifically why would someone with the example code that DefecTalisman was put up get an error message?

Is it because post wasn't quoted?

I was testing this out to see what was happening and I made it as far as the 'All is fine' page but upon clicking send it did nothing. Did I do something wrong or was this designed to not to send anything so it wouldn't spam the email address listed in there? I had changed the email address.
 
Last edited:

bensbox

New Member
Messages
20
Reaction score
0
Points
0
I qish i knew what i was doing, i keep trying but nothing happens
is it just x10hosting? do they only allow certain methods? or etc?
Ben
 

DefecTalisman

Community Advocate
Community Support
Messages
4,148
Reaction score
5
Points
38
The reason it wont work is it is missing the code to send the mail.

All it will do at present is check the input fields to be true and then echo them back.
 

epoclaen

Member
Messages
79
Reaction score
0
Points
6
To be 100% clear, the error is in the first 5 lines of the <body> tag.

Code:
1: <body>
2: <p>FORM test</p>
3: <form id="form1" name="form1" method="post" action="">
4: <label></label>
5: <form action="mailto:ben_johnson1991@hotmail.co.uk" method="get" enctype="text/plain" name="INFOform" id="INFOform">
6: etc...

Forms cannot be nested and require a closing </form> tag. So line #3 opens a form statement but then the code opens a second form statement on line 5 without closing the first one. And by "nested" I mean that you can't simply add a second closing </form> tag to the end of the code because one <form>...</form> statement would be inside the other which isn't allowed.

Another issue in line #3 is that without anything in the "action" part of the opening <form> statement it doesn't know what to do when the form is submitted. The "action" part usually just tells the web page where to go when the user submits the form so a URL will do.

The MAILTO: statement is a specific type of URL that opens up a new mail window in your default email client and includes the data provided such as the To:, Subject: and Body: data. So no, it won't actually send the mail for the user. The convenience of it is that it will at least open a new email for them and give the To: address for the user without them having to copy/paste it in.

The URL can also take them to a PHP script that will process the form (as DefecTalisman said his example does in his last post) and yes, a PHP script can actually send the email for you. But this is a whole 'nother ball of wax that involves knowledge of PHP scripting and at least a good understanding of email headers. There are free PHP scripts out there that do most of this work for you but even then they need to be set up properly. You need to contact the admins to ask to be bumped up to the "Intermediate Free Hosting" plan too so that you can use the PHP mail() function.
 

BlueJay

New Member
Messages
2
Reaction score
0
Points
0
Thank you epoclaen.

This helped me a great. I had already found out about the php mail() function and even a few free scripts. I hadn't been able to get it to work though. Now I know that it's just that I'm not on the correct plan.
 

epoclaen

Member
Messages
79
Reaction score
0
Points
6
Sadly, I haven't been able to get any of the "PHP mail()" scripts that I found to work for me either.
Most work when sending mail to my hotmail account but not to my Comcast account. Make sure you check your junkmail for any account that you're trying to use the PHP mail() script to send the form data to because some of the simpler PHP mail() scripts will create the headers in such a way that they look to be "processed" emails that bulk emailers often send out.

I do have a backup solution for myself that involves using a free service from http://www.Bravenet.com. They offer an "Email Form generator" service when you sign up for a free account with them. It generates an entire form for you and offers a redirect page and everything. I've been using it for over 6 years now and although I have to give them a valid email address that I check every so often (they sometimes send you a "do you want to keep the account active?" emails when your bravenet site gets no visitors for years on end) so that the account isn't closed without your knowing about it.

Here's a sample of the code they use and how to cater it to your needs:
HTML:
 <form action="http://pub14.bravenet.com/emailfwd/senddata.php" method="post">
  <!-- Where {a number for your account} is something Bravenet generates for you. -->
  <input type="hidden" name="usernum" value="{a number for your account}" />
  <!-- I'm not sure what this value is for.  It's been a while! -->
   <input type="hidden" name="cpv" value="2" />
  <!-- The subject line of the email -->
    <INPUT type="hidden" name="subject" value="Website Feedback" />
  <!-- A webpage to send them to after hitting the Submit button. -->
   <input type="hidden" name="thankyou" value="http://www.yourwebsite.com/thanks.html">
  <!-- Any additional email addresses that you want to send the form to separated by commas.  One copy goes to the email address that you gave when you sign up for the Bravenet account. -->
   <input type="hidden" name="carboncopy" value="AnotherEmail@.Address.com, YetAnotherEmail@Address.net">
<!-- End New Bravenet.com Service Code -->
<p><strong>Your Name:</strong><br>
<input TYPE="TEXT" NAME="Sender_Name" SIZE="30" VALUE="">
</p>
<p><strong>Your Feedback or Question:</strong><br>
<textarea rows="5" name="Feedback" cols="60">Enter your question or give me feedback here.</textarea>
</p>
<input type="submit" value="Submit">
<input type="reset" name="reset" value=" Clear ">
</form>
It's the easiest and most reliable solution I've found after 2 days of searching for my own PHP mail() script. Note that you'll have to change the {a number for your account} and either remove the <input type="hidden" name="carboncopy" value="AnotherEmail@.Address.com, YetAnotherEmail@Address.com"> line or change the email addresses in it before the form will work.
 

DefecTalisman

Community Advocate
Community Support
Messages
4,148
Reaction score
5
Points
38
Does that form work even if you don't have a Bravenet account?

I am sure if you asked me nicley I could post the rest of the code to mail the form that I posted earlier.
 

epoclaen

Member
Messages
79
Reaction score
0
Points
6
Does that form work even if you don't have a Bravenet account?

No, as I mentioned in the post you need to sign up for a free account with them to get the number they use in the form for your account. It's kinda a poor authorization code attempt. You need your own specific account anyway or the To: field of the email will use the email address of whoever's account is tied to the number. This main email address isn't found in the form so there's no real changing it that I'm aware of.

Another shortcoming of it is that the message body takes the format of:
Code:
field_name={field data}
and I don't believe there's a way to alter this either although I did see that they added different types of forms in their Form Tools section that might format them for more public email responses than back when I first started using the PHP utility way back when computers still had single core chips.

If you have code that mails as most online forms do then for me, I'd love to see what you have that's working - specifically with the x10hosting server! But this is bensbox's thread though and I only wanted to offer him something relatively basic that might work for him. If you'd be willing to share then it might be best to do so in my http://forums.x10hosting.com/free-hosting/40042-php-mail-again.html thread, unless you think bensbox would benefit from it too.

Thanks!
 
Last edited:

DefecTalisman

Community Advocate
Community Support
Messages
4,148
Reaction score
5
Points
38
Here is a basic script that I use to send mail via the query string.

*save me as * "mail_qs.php"
PHP:
<?php
$test = 0;

if (!getenv('QUERY_STRING')) { echo "What you trying to do?"; }
else { 	$qs = getenv('QUERY_STRING');
		set_details($qs); }


function set_details($qs)
{
	if (strpos($qs,'=') == FALSE )
	{
		echo 'Sorry, incorect string.';
	}
	else
	{
		global $details, $to, $from, $reply, $sub, $msg;
		$set_array = explode('+',$qs);
		
		foreach ($set_array as $a)
		{
			if (strpos($a,'=') == FALSE )
			{
				echo 'Sorry, incorect string.';
				return;
			}
			else
			{
				$b = explode('=',$a);
				$details["$b[0]"] = $b[1];
			}
			unset($a, $b);
		}
		
		if (! $details['to'])
		{ echo 'No \'to\', can\'t send'; return; }
		else
		{ $to = $details['to']; }

		if (! $details['sub']) 
		{ $sub = 'na'; }
		else 
		{ $sub = $details['sub']; }
		
		if (! $details['msg']) 
		{ echo 'no \'msg\', can\'t send.'; return; }
		else 
		{ $msg = $details['msg']; }

		if (! $details['from']) 
		{ $from = 'yourmail@mail.com'; }
		else 
		{ $from = $details['from'] && $reply = $details['from']; }

	}
}

if (! $test) {

	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

	$headers .= 'To: you <' . $to . '>' . "\r\n";
	$headers .= 'From: AutoWeb <' . $from . '>' . "\r\n";
	$headers .= 'Reply-To: Webmaster <' . $reply . '>' . "\r\n";
	$headers .= 'X-Mailer: PHP/' . phpversion();

	if (strpos($sub,"%20") == TRUE)
	{ $sub = str_replace("%20"," ",$sub); }
	
	if (strpos($msg,"%20") == TRUE)
	{ $msg = str_replace("%20"," ",$msg); }
	
	if (mail($to, $sub, $msg, $headers)) {
	  echo("<p>HEADER: $headers</p><p>TO: $to</p><p>SUB: $sub</p><p>MESSAGE: $msg</p><p>Message successfully sent!</p>");
	 } else {
	  echo("<p>HEADER: $headers</p><p>TO: $to</p><p>SUB: $sub</p><p>MESSAGE: $msg</p><p>Message delivery failed...</p>");
	 }
}	
?>

now if it was saved to your "public_html/scripts/" folder it would be used as follows:

http://www.my_domain.com/scripts/mail_qs.php?to=someone@mail.com+msg=This is the body of the message

Code:
http://www.my_domain.com/scripts/mail_qs.php?to=someone@mail.com+msg=This is the body of the message
 
Last edited:

epoclaen

Member
Messages
79
Reaction score
0
Points
6
Well I gave this a shot (thanks for the post DefecTalisman) and managed to get it to receive at my hotmail and yahoo accounts as I had with other PHP mail scripts but yet again, the comcast.net account refuses to accept the email. Here's the error message I'm getting in my x10hosting mailbox:
SMTP error from remote mail server after MAIL FROM:<epoclaen@cossacks.x10hosting> SIZE=1542:
host mx1.comcast.net [76.96.62.116]: 550 5.1.0 Invalid sender domain
I stuck in literal strings for the $to, $from, $msg and $reply variables rather than letting the $_GET variables process it all. The only thing I found was that the $from address had to be my epoclaen@cossacks.x10hosting address for hotmail and yahoo to work.

At this point I'd just love to know if Comcast is the only provider that I can expect problems from. Has anyone else had an issue with sending PHP emails to them? How about with sending PHP emails to other email addresses? If it's just Comcast having some sort of stick up their tails then I'll just refuse to allow users to register with a comcast address and be done with it. Otherwise I'd just like to be sure that the emails are going through without having to check my x10hosting account daily.
 

DefecTalisman

Community Advocate
Community Support
Messages
4,148
Reaction score
5
Points
38
I am sending to hotmail and yahoo mail with no problems. Also numerous POP3 accounts.
 

agaitu

Banned
Messages
127
Reaction score
0
Points
0
can any one help me i want to insert a gmail composer in my web
any guide lines please
 
Status
Not open for further replies.
Top