newbie question re submission form
Moderator: General Moderators
newbie question re submission form
I am experienced with html but never used php so I took some coding off a php site. I am making a website for a cat shelter and they have a very long adoption application form. Where I have the site accepts PHP4 and 5. I have the form made correctly but the php part doesn't seem to work. Above the form in the <body> I have
<form method="post" action="sendmail.php">
and below the form
<input type="submit">
</form>
The php file I have says this -
<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
mail( "cbrndage@nc.rr.com", "Feedback Form Results",
$message, "From: $email" );
header( "Location: http://www.example.com/thankyou.html" );
?>
I have them both uploaded into the same directory online. Any help would be most appreciated by me - and by the cats!!
Thank you - Christina
<form method="post" action="sendmail.php">
and below the form
<input type="submit">
</form>
The php file I have says this -
<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
mail( "cbrndage@nc.rr.com", "Feedback Form Results",
$message, "From: $email" );
header( "Location: http://www.example.com/thankyou.html" );
?>
I have them both uploaded into the same directory online. Any help would be most appreciated by me - and by the cats!!
Thank you - Christina
Re: newbie question re submission form
Try this:
$name is the variable, it ='s $_POST (not request b/c your form method is post). The ['name'] is the name of the field you are trying to retrieve.
Just keep going with that^ until you get all the fields that you want.
Then make a $to variable:
In the $message, put quotations around the whole message and then just called the variables from before by putting their name.
Then
then when you put it all together it comes out like this:
If you want to see what people filled out in your form you are going to have to do the variable for that field then also call that variable in the message.
Code: Select all
$name=$_POST['name'];Code: Select all
$name=$_POST['name'];
$email=$_POST['email'];
$breed=$_POST['breed'];
$blah=$_POST['message'];
Then make a $to variable:
Code: Select all
$to = "blah@email.com";
$message = "Somebody filled out your form their name was $name, their breed was $breed, and their message was $blah";
Then
Code: Select all
mail($to, "feedback from results", $message, "From $email");Code: Select all
$name=$_POST['name'];
$email=$_POST['email'];
$breed=$_POST['breed'];
$blah=$_POST['message'];
$to = "blah@email.com";
$message = "Somebody filled out your form their name was $name, their breed was $breed, and their message was $blah";
mail($to, "feedback from results", $message, "From $email");Re: newbie question re submission form
Thanks so much - I am going to work on that. What happens when I click on submit, is a 404 error that sendmail.php can't be found.
Re: newbie question re submission form
Do you have sendmail.php in the same folder as the .html file?
Re: newbie question re submission form
Yes, I do - in the main directory.
Re: newbie question re submission form
You sure you have the file name typed right? Because your code is right, so something else is messing up.
Re: newbie question re submission form
I've gone over and over it. It's spelled right. I can't figure out why it can't find the page. I can email 1&1 which hosts the site. Maddening!
Re: newbie question re submission form
Now I'm getting this -
The page cannot be displayed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.
Please try the following:
* Contact the Web site administrator if you believe that this request should be allowed.
* Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.
HTTP Error 405 - The HTTP verb used to access this page is not allowed.
Internet Information Services (IIS)
The page cannot be displayed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.
Please try the following:
* Contact the Web site administrator if you believe that this request should be allowed.
* Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.
HTTP Error 405 - The HTTP verb used to access this page is not allowed.
Internet Information Services (IIS)
Re: newbie question re submission form
What hosting company are you using? It sounds like your hosting on a windows machine, the machine has to be running IIS 7 and has to have PHP enabled (I do not believe this is default). This is just what it is sounding like.
Re: newbie question re submission form
When I click on submit from my C files rather than online, I get this even though I filled out the first few inquiries with replies
<?
function checkOK($field)
{
if (eregi("\r",$field) || eregi("\n",$field)){
die("Invalid Input!");
}
}
$name of cat=$_POST['name of cat'];
$date=$_POST['date'];
$name=$_POST['name'];
$street=$_POST['street'];
$city=$_POST['city'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$name=$_POST['name'];
$name=$_POST['name'];
$name=$_POST['name'];
$name=$_POST['name'];
$name=$_POST['name'];
checkOK($name);
$email=$_POST['email'];
checkOK($email);
$to="cbrundage@nc.rr.com";
$message="$name just filled in your application form. They said:\n$comments\n\nTheir e-mail address was: $email";
if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
echo "Thanks for your comments.";
} else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}
?>
<?
function checkOK($field)
{
if (eregi("\r",$field) || eregi("\n",$field)){
die("Invalid Input!");
}
}
$name of cat=$_POST['name of cat'];
$date=$_POST['date'];
$name=$_POST['name'];
$street=$_POST['street'];
$city=$_POST['city'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$name=$_POST['name'];
$name=$_POST['name'];
$name=$_POST['name'];
$name=$_POST['name'];
$name=$_POST['name'];
checkOK($name);
$email=$_POST['email'];
checkOK($email);
$to="cbrundage@nc.rr.com";
$message="$name just filled in your application form. They said:\n$comments\n\nTheir e-mail address was: $email";
if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
echo "Thanks for your comments.";
} else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}
?>
Re: newbie question re submission form
I'm using 1&1 and it says they allow php4 and php5. I'm using Windows XP.
Re: newbie question re submission form
ok first give your form a name and an ID <form name="blah" id="belch"> whatever. This was found a fix for the http verb thing when I was looking it up :/
Next the: checkOK($name); put that under all the new variables you posted just change $name to the name of the variable so $date, $name, etc.
Finally take out the 2 variables you used to have in the form, the email and name. You now have those variables in your php form twice.
P.S. Final? Who ever is going to get that email is only going to see Name and Email, you need to add all the other variables to the message.
Next the: checkOK($name); put that under all the new variables you posted just change $name to the name of the variable so $date, $name, etc.
Finally take out the 2 variables you used to have in the form, the email and name. You now have those variables in your php form twice.
P.S. Final? Who ever is going to get that email is only going to see Name and Email, you need to add all the other variables to the message.
Re: newbie question re submission form
I was starting to rename all the variables but wanted to try if it worked first. There are 76 of them to do!
This is what I have at the beginning now -
<FORM METHOD="post" name="application" id="adoption" ACTION="sendmail.php">
and the php -
<?
function checkOK($field)
{
if (eregi("\r",$field) || eregi("\n",$field)){
die("Invalid Input!");
}
}
$name of cat=$_POST['name of cat'];
$date=$_POST['date'];
$name=$_POST['name'];
$street=$_POST['street'];
$city=$_POST['city'];
$phone=$_POST['phone'];
$to="cbrundage@nc.rr.com";
$message="$name just filled in your application form. They said:\n$comments\n\nTheir e-mail address was: $email";
if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
echo "Thanks for your comments.";
} else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}
?>
This is what I have at the beginning now -
<FORM METHOD="post" name="application" id="adoption" ACTION="sendmail.php">
and the php -
<?
function checkOK($field)
{
if (eregi("\r",$field) || eregi("\n",$field)){
die("Invalid Input!");
}
}
$name of cat=$_POST['name of cat'];
$date=$_POST['date'];
$name=$_POST['name'];
$street=$_POST['street'];
$city=$_POST['city'];
$phone=$_POST['phone'];
$to="cbrundage@nc.rr.com";
$message="$name just filled in your application form. They said:\n$comments\n\nTheir e-mail address was: $email";
if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
echo "Thanks for your comments.";
} else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}
?>
Re: newbie question re submission form
76 for an adoption? wow...let me know if this works. Since your on a windows server it is going to be extremely picky about what is or isn't going to allow. If there is any way to switch their server to Linux I highly recommend it (unless they are using aspx.net or asp.net or any other language that requires IIS). PHP does best on a linux server though.
Re: newbie question re submission form
Thanks - I'll see about that. Yes, 76 - it was about half that and then I could put it free on one of those sites that let you do that. Then they decided they wanted a lot more information. But none of those sites allow a form free with over 50 input areas which is why I'm trying to make one myself. I talked to the cat people about it but that's how many they want - they are very thorough!