Jump to content
xisto Community
Sign in to follow this  
iGuest

help making a form

Recommended Posts

ok im trying to make a form for my website but its not really working.
This is my script so far.

<form action="mailto:gregtreich@gmail.com" method="post">                    <p>                      <input name="textfield" type="text">                       Your Name Here</p>                    <p>                      <input name="textfield" type="text">                       Your E-mail Here</p>                    <p>                      <input name="textfield" type="text">                       Subject</p>                    <p>                      <textarea name="textarea"></textarea>                       Comments Or Questions</p>                    <p>                      <input type="submit" name="Submit" value="Submit">                      <input type="reset" name="Reset" value="Reset"></p>                </form>
if someone could help me thanks[/code]

Share this post


Link to post
Share on other sites

i would recommend using either a cgi or php mail script to process the form. i can send you a very good, well commented one written in perl if you would like. its free for non-commercial use

Share this post


Link to post
Share on other sites

[i made i copletely new script for you and i didn't test it :D, so if you have problems tell me so i can fix it]

 

Ok, this is my script so you can do whatever with it. :D

 

What it does:

 

It first checks that you filled in all the fields and that your emails match so you can answer.

 

Once you fill in all the fields and hit send, it tells you it was sent, your name, your email, to who it was sent, what was the subject, and what the mesage was. Or if there was a problem it gives you an error.

!!You have to leave the file names the same!!

 

Your gonna have to change the folowing in the file(s):

 

In sendform.php you have to set the variable $to to your email (it's replaced by a load of slashes)

 

--------------------form.php--------------------

 

<html><body><form name="contact" method="post" action="sendform.php"><table align="center" cellpadding="4" cellspacing="0"> <tr>  <td>Your Name:</td>  <td><input type="text" name="name"></td> </tr><tr>  <td>Email:</td>  <td><input type="text" name="email"></td> </tr> <tr>  <td>Confirm Email:</td>  <td><input type="text" name="conf_email"></td> </tr> <tr>  <td>Subject:</td>  <td><input type="text" name="sub"></td> </tr><tr>  <td>Message:</td>  <td><textarea name="msg" cols="20" rows="6"></textarea></td> </tr> <tr>  <td colspan="2" align="right"><input type="submit" name="submit" value="Submit"></td> </tr></table></form></body></html>

--------------------sendform.php--------------------

 

<?phpif($name == "") {    echo "Please fill out your name.<br>";}elseif($email == "") {       echo "Please fill out your email address.<br>";}elseif($email == $conf_email) {       echo "Your emails do not match.<br>";}elseif($sub == "") {       echo "Please fill out a subject.<br>";}elseif($msg == "") {       echo "Please fill out a message.<br>";}else {$to = "///////////////////////////////////////////////////////////////////////////////";$subject = "$sub<$name, $email>";         @extract($_POST);         mail($to,$subject,$msg,"From: $name <$email>");{echo "<center><h1>Email Sent</h1></center><br>Your name is: <b>$name</b><br>Your email is: <b>$email</b><br>An e-mail was sent to: <b>$to</b><br>With the subject: <b>$subject</b><br>And the mesage was: <b>$msg</b>";} else {echo "<center><h1>Error!</h1></center><br>There was a problem sending the mail. Check your code and make sure that the e-mail address $to is valid";}?>

Ok, to use it in your site just use php include, you know what that is right? 8)

 

ENJOY!

Share this post


Link to post
Share on other sites

Ok i got it all inplace but when i try it out i get this

"; } elseif($email == "") { echo "Please fill out your email address."; } elseif($email == $conf_email) { echo "Your emails do not match."; } elseif($sub == "") { echo "Please fill out a subject."; } elseif($msg == "") { echo "Please fill out a message."; } else { $to = "gregtreich@gmail.com"; $subject = "$sub<$name, $email>"; @extract($_POST); mail($to,$subject,$msg,"From: $name <$email>"); { echo "Email SentYour name is: $nameYour email is: $emailAn e-mail was sent to: $toWith the subject: $subjectAnd the mesage was: $msg"; } else { echo "Error!There was a problem sending the mail. Check your code and make sure that the e-mail address $to is valid"; } ?>

i changed the line with the ////'s to
$to = "gregtreich@gmail.com";
please help.
Thanks

Share this post


Link to post
Share on other sites

well i made a form script if your interested :D its in 2 seperate pages...

 

It has been tested :D

 

My from is made with 2 seperate pages...just the way i code

 

 

First make a form...

 

(this subjectis in a dropdown list...as if you couldnt tell :D)

 

name this page contact.php

<form action="contact2.php" method=POST>First name:<br> <input type="text" name="firstname" size="30" maxlength="30" /><br /> Last name:<br> <input type="text" name="lastname" size="30" maxlength="30" /><br />E-mail address:<br> <input type="text" name="email" size="30" maxlength="30" /><br />Subject:<br><!-- add as many <option value="" name="">NAME</options> as you want --><select name="subject">	<option vlaue="Complaint" name="complaint" selected="selected">Complaint</option>	<option value="Question" name="question">Question</option>	<option value="Suggestion" name="suggestion">Suggestion</option></select><br />What is it?:<br><textarea COLS="40" ROWS="5" name="comment"></textarea> <p><input name="submit" type="submit" value="Submit"><input name="reset" type="reset" value="Reset"></form>

now make another page and name it contact2.php and add this to it

 

<?php//get the posted information$first = $_POST['firstname'];$last = $_POST['lastname'];$email = $_POST['email'];$subject = $_POST['subject'];$comment = $_POST['comment'];//get rid of the extra spaces$first = trim($first);$last = trim($last);$email = trim($email);$subject = trim($subject);$comment = trim($comment);//get rid of the access /'s that php automatically adds$first = stripslashes($first);$last = stripslashes($last);$email = stripslashes($email);$subject = stripslashes($subject);$comment = stripslashes($comment);//make the form again so you dont have to post it every time$form = "<form action="contact2.php" method="POST">First name:<br> <input type="text" name="firstname" size="30" maxlength="30" /><br /> Last name:<br> <input type="text" name="lastname" size="30" maxlength="30" /><br />E-mail address:<br> <input type="text" name="email" size="30" maxlength="30" /><br />Subject:<br>//if you added any extra <option value= name=>NAME</options> add them here also<select name="subject">	<option vlaue="Complaint" name="complaint" selected="selected">Complaint</option>	<option value="Question" name="question">Question</option>	<option value="Suggestion" name="suggestion">Suggestion</option></select><br />What is it?:<br><textarea COLS="40" ROWS="5" name="comment"></textarea> <p><input name="submit" type="submit" value="Submit"><input name="reset" type="reset" value="Reset"></form>";//if any of them are empty display a message and the form againif(empty($first)) {echo "Please Type in your first name";echo "$form";}elseif(empty($last)) {echo "Please Type in your last name";echo "$form";}elseif(empty($email)) {echo "Please Type in your email";echo "$form";}elseif(empty($comment)) {echo "Please Type in your problem or question";echo "$form";}else{//if all are filled in then mail the information and display a messagemail("[color=red]YOUR EMAIL[/color]", "contact - $subject", "Name: $firstname $lastnamenEmail: $emailnSubject: $subjectnComments: $comment", "From: $email");echo "Thank you!  We will get back to you shortly.";}?>

I tried to comment it well...but if you still need help just post.

Share this post


Link to post
Share on other sites

I propably frogot to put the extract for post on top...

try this: (i'm sorry i didn't test it)

<?php         @extract($_POST);if($name == "") {    echo "Please fill out your name.<br>";}elseif($email == "") {       echo "Please fill out your email address.<br>";}elseif($email == $conf_email) {       echo "Your emails do not match.<br>";}elseif($sub == "") {       echo "Please fill out a subject.<br>";}elseif($msg == "") {       echo "Please fill out a message.<br>";}else {$to = "gregtreich@gmail.com";$subject = "$sub<$name, $email>";         @extract($_POST);         mail($to,$subject,$msg,"From: $name <$email>");{echo "<center><h1>Email Sent</h1></center><br>Your name is: <b>$name</b><br>Your email is: <b>$email</b><br>An e-mail was sent to: <b>$to</b><br>With the subject: <b>$subject</b><br>And the mesage was: <b>$msg</b>";} else {echo "<center><h1>Error!</h1></center><br>There was a problem sending the mail. Check your code and make sure that the e-mail address $to is valid";}?>

:D

Share this post


Link to post
Share on other sites

If you want a simpler way just you phpgenerator which is in Cpanel's script library or there is dynaform, both work well and are user friendly.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.