Jump to content

Sending Forms


The Praetorian

Recommended Posts

URL = http://www.freewebs.com/the_praetorian/form.htmlI'm not actually having a problem with a code, but I was wondering if someone could help me. I couldn't find out how to do this on the w3schools website.I'm wanting to work it so that when a person hits "Submit", the form will be sent from the website to my email. At the moment all it does is open Outlook Express. I know I probably need to have a domain email first, but I was still hoping someone could point me in the right direction for this code.Thanks.

Link to comment
Share on other sites

This has to be the most FAQ on these forums, if you do a search then you'll see it has been asked often before.Basically you have to send the mail using a server language like asp or php etc. If you search the net then you could find a free on, like at matt's script archive (which uses perl i think).

Link to comment
Share on other sites

That's what I suggest you :

<body><form name="form1" method="post" action="../email.php"> <table border="0"><tr> <td width="125">À :</td><td width="336"><select name="personne"> <option value="Youremail">Thename</option></select></td></tr><tr> <td> Subjet : </td><td><input name="sujet" type="text" id="sujet2" size="55"></td></tr><tr> <td> Message : </td><td><textarea name="message" cols="50" rows="5"></textarea></td> </tr><tr> <td> </td><td><input type="submit" name="Submit" value="Envoyer"><input type="reset" name="Submit2" value="Rétablir"></td></tr></table><p>  </p></form></body>

that's what going in index.html Thename = the name that you want peaple to see and to be abble to click on.Your email = well I hope you know what's a mail. exemple : ertq123@hotmail.comPHP CODE now :

<body><?php$From = "from who it's coming";$to = $_POST['personne'];$object = stripslashes($_POST['sujet']);$msg = stripslashes($_POST['message']);mail ($to, $object, $msg, "From: $from");print("<br/>Merci d'avoir envoyé le mail suivant à $to");?></body>

so that's what's going in email.php

Link to comment
Share on other sites

Okay, most of that code doesn't make much sense to me. Which parts do I need, and which parts do I fill my own values in? And yea, I didn't know about the forms function for FreeWebs, but it's too late now since I already purchased a domain. heh. Unfortunately, I'm still somewhat of a beginner, at least as far as php is concerned, and all the tutorials I've read (including w3school's) have just made my head hurt.By the way, I've done several searches for forms and emails, and combinations of the two and nothing at all helpful has come up.

Link to comment
Share on other sites

it's too late now since I already purchased a domain. heh. Unfortunately, I'm still somewhat of a beginner, at least as far as php is concerned

What language does your site use? Is it php?Once we know that you can move forward :)
Link to comment
Share on other sites

Well, the site uses a whole mess of different things. I don't really understand alot of the features it has, since it's probably not built for beginners like free webs is. It does use php, though, among other things. I actually found the right code, but I can't seem to get it working the way I want it to work. Here, I posted another question in the php forum.http://w3schools.invisionzone.com/index.php?showtopic=4884I put the code I'm currently using there. I got the code from w3schools and I adjusted it, but after adjusting it it stopped working correctly.

Link to comment
Share on other sites

try this.

$name=$_POST['Name'];$email=$_POST['email'];$age=$_POST['Age'];$gender=$_POST['gender'];mail("me@me.com","subject","$name $age $gender","From:$email");

Link to comment
Share on other sites

Awesome, I'll give that a try. One question though. Will this work if I want to add more form areas? That's what I'm really looking for, is how to keep adding form areas but still be able to have the added areas sent to me, so I can add to the form if I need to.----- EDIT -------Okay, adding the code you gave me returned this error when I tried to visit the page url.Parse error: syntax error, unexpected T_VARIABLE in /home/author/public_html/appmail.php on line 10Do you think it's a problem that I have the page saved as .php?

Link to comment
Share on other sites

Did you try the one from the w3schools example?If you can get this to work then we'll try and expand on it.

<html><body><?phpif (isset($_REQUEST['email']))  {  $email = $_REQUEST['email'];   $subject = $_REQUEST['subject'];  $message = $_REQUEST['message'];  mail( "someone@someplace.com", "Subject: $subject",  $message, "From: $email" );  echo "Thank you for using our mail form";  }else  {  echo "<form method='post' action='mailform.php'>  Email: <input name='email' type='text' /><br />  Subject: <input name='subject' type='text' /><br />  Message:<br />  <textarea name='message' rows='15' cols='40'>  </textarea><br />  <input type='submit' />  </form>";  }?></body></html>

Link to comment
Share on other sites

Ok try this then.

<html><body><?phpif (isset($_REQUEST['email'])) { $name = $_REQUEST['name'];  $age = $_REQUEST['age']; $gender = $_REQUEST['gender']; $email = $_REQUEST['email'];  $subject = $_REQUEST['subject']; $message = $_REQUEST['message'];  mail( "someone@someplace.com", "Subject: $subject","$name $age $gender $message", "From: $email" ); echo "Thank you for using our mail form"; }else { echo "<form method='post' action='mailform.php'>  <input type='text' name='name' size='20'><br /><input type='text' name='age' size='10'><br />Male: <input class='blocktext' type='radio' name='gender' value='Male'><br />Female:<input class='blocktext' type='radio' name='gender' value='Female'>Email: <input name='email' type='text' /><br />Subject: <input name='subject' type='text' /><br />Message:<br /><textarea name='message' rows='15' cols='40'></textarea><br />  <input type='submit' /> </form>"; }?></body></html>

Link to comment
Share on other sites

Right!Okay, that worked. It sent all the information in the right way with only one exception.When the text comes in my email it's all in a solid line with only spaces between, no text breaks. Off the top of your head, any way around this? If I have to live with it I will, just so long as it works now and I have the format to add more forms. (Thanks, by the way!)

Link to comment
Share on other sites

You should be able to add the html like so:mail( "someone@someplace.com", "Subject: $subject","$name<br /> $age<br /> $gender<br /> $message", "From: $email" );

Link to comment
Share on other sites

try this.mail( "someone@someplace.com", "Subject: $subject","$name\r\n $age\r\n $gender\r\n $message", "From: $email" );or$name = $_REQUEST['name'];$age = $_REQUEST['age']; $gender = $_REQUEST['gender']; $email = $_REQUEST['email']; $subject = $_REQUEST['subject']; $message = $_REQUEST['message']; $newline = "<br />";mail( "someone@someplace.com", "Subject: $subject","$name $newline $age $newline $gender $newline $message", "From: $email" ); (sorry but i can't test any of this just now, i'm just guessing :) )

Link to comment
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
×
×
  • Create New...