HTML Form to email?

verticalnfinity

New Member
Messages
11
Reaction score
0
Points
0
Hi! I've been trying to get my HTML form to send the data to my email but all has failed.

I tried CGI email but they just don't work. Here are my settings for the CGI email. I hope they are right. (Attachments)

I also need the right steps cause the user guide just confuses me even more.

It would be great if you could help me as I really need this and I would like to learn. Thanks! :)
 

Attachments

  • index.html
    740 bytes · Views: 55
  • outing.txt
    159 bytes · Views: 58

marshian

New Member
Messages
526
Reaction score
9
Points
0
I've never heard of any 'script' like your outing.txt ...
Try to make a file "outing.php" (and also put it as the action of the form)
PHP:
<?php
$text  = "Name: {$_POST["required-name"]}\n";
$text .= "Email: {$_POST["email"]}\n";
$text .= "Phone number: {$_POST["phone"]}\n";
$text .= "Attending: {$_POST["attendance"]}\n";
$text .= "Comments: {$_POST["comment"]}";

mail("vt@8473973495.com", "Outing Attendance", $text);
?>

Not the best php script i've made, but it should at least do something (unlike that txt file...)
 

verticalnfinity

New Member
Messages
11
Reaction score
0
Points
0
OMG! It worked! But is there any way to like make the php page have some words or a redirection page? :D

That would work great. Thanks a lot! :)

Edit: Oh wait. I can use HTML! :) That'll work great! :D (I think) :)
 
Last edited:

dbqclassof2012

New Member
Messages
15
Reaction score
0
Points
0
Yes there is a way for the that to happen all you have to do is put your outgoing.php file in html tags like this
HTML:
<html>
<head>
<title>Congratulations your email has been sent!</title>
<meta http-equiv="refresh" content="5;url=Where you want it to redirect them here">
</head>
<body>
 <?php 
$text  = "Name: {$_POST["required-name"]}\n"; 
$text .= "Email: {$_POST["email"]}\n"; 
$text .= "Phone number: {$_POST["phone"]}\n"; 
$text .= "Attending: {$_POST["attendance"]}\n"; 
$text .= "Comments: {$_POST["comment"]}"; 

mail("vt@8473973495.com", "Outing Attendance", $text); 
?>  
<!-- Now Put what you want in your page here -->
Congratulations Your Email Has Been Sent!

</body>
</html>
The Number 5 in
Code:
<meta http-equiv="refresh" content="5;url=Where you want it to redirect them here">
Is how many seconds till the page will be automatically redirect

I believe this is how it works i have the same type of thing for my website.

Hope I helped!;)
 

verticalnfinity

New Member
Messages
11
Reaction score
0
Points
0
Is there anyway to make a required field? Help appreciated :)
Edit:
Yes there is a way for the that to happen all you have to do is put your outgoing.php file in html tags like this
HTML:
<html>
<head>
<title>Congratulations your email has been sent!</title>
<meta http-equiv="refresh" content="5;url=Where you want it to redirect them here">
</head>
<body>
 <?php 
$text  = "Name: {$_POST["required-name"]}\n"; 
$text .= "Email: {$_POST["email"]}\n"; 
$text .= "Phone number: {$_POST["phone"]}\n"; 
$text .= "Attending: {$_POST["attendance"]}\n"; 
$text .= "Comments: {$_POST["comment"]}"; 

mail("vt@8473973495.com", "Outing Attendance", $text); 
?>  
<!-- Now Put what you want in your page here -->
Congratulations Your Email Has Been Sent!

</body>
</html>
The Number 5 in
Code:
<meta http-equiv="refresh" content="5;url=Where you want it to redirect them here">
Is how many seconds till the page will be automatically redirect

I believe this is how it works i have the same type of thing for my website.

Hope I helped!;)

Thanks alot that helped. now I need to do a required field for the form. Any ideas?
 
Last edited:

dbqclassof2012

New Member
Messages
15
Reaction score
0
Points
0
I am not sure how to do this but just Google "how to make a form required" and just keep looking around.

Sorry i am not able to help with this.:mad:
 

scopey

New Member
Messages
62
Reaction score
0
Points
0
So a user HAS to enter something?

Just check it to see if it's empty with php.

if($_POST['field'] == ""){
echo "You fail. Enter a value in fieldname"
}
 

mujtaba91

New Member
Messages
50
Reaction score
0
Points
0
Well its better to validate a form using javascript since it is not executed on server,saves time and looks impressive..
Here is the scipt:


<script type="text/javascript">




<!--

function validate_form ( )
{
valid = true;

if ( document.myform.required_field.value == "" )
{
alert ( "Please enter your name!" );
document.myform.name.style.border='1px solid red';
valid = false;
}



return valid;
}

//-->

</script>


And the HTML:

<form action="outing.php" method="post" onsubmit="return validate_form ( );" name="myform" >
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
*wheeeeee, let's post responses that are actually incorrect! =D*

Ok, clearly, a client-side validation is useless, as the user is able to go around that very easely. Just use the server-side validation. (In the PHP code.) (Usually the 2 are combined.)
The META-redirect should work, but is not the recommended way to do things...

Required field:
PHP:
<?php
//Checks required-name
if($_POST["required-name"] == "") {
?>
HTML CODE FOR FAILED VALIDATION GOES HERE.
<?php
//Or: to use a redirect, remove the 3 above lines and use a header("Location: url");
exit;
}
$text  = "Name: {$_POST["required-name"]}\n";
$text .= "Email: {$_POST["email"]}\n";
$text .= "Phone number: {$_POST["phone"]}\n";
$text .= "Attending: {$_POST["attendance"]}\n";
$text .= "Comments: {$_POST["comment"]}";

mail("vt@8473973495.com", "Outing Attendance", $text);
?>

If you want to redirect:
PHP:
<?php
$text  = "Name: {$_POST["required-name"]}\n";
$text .= "Email: {$_POST["email"]}\n";
$text .= "Phone number: {$_POST["phone"]}\n";
$text .= "Attending: {$_POST["attendance"]}\n";
$text .= "Comments: {$_POST["comment"]}";

@mail("vt@8473973495.com", "Outing Attendance", $text);
header("Location: http://www.google.com");
exit;
?>

To use html:
PHP:
<?php
$text  = "Name: {$_POST["required-name"]}\n";
$text .= "Email: {$_POST["email"]}\n";
$text .= "Phone number: {$_POST["phone"]}\n";
$text .= "Attending: {$_POST["attendance"]}\n";
$text .= "Comments: {$_POST["comment"]}";

mail("vt@8473973495.com", "Outing Attendance", $text);
?>

PUT HTML HERE.


- Marshian
 
Top