• Creating a form
    5 replies, posted
Hello facepunch. This is a new account but I have been on facepunch for years, so don't worry about my join date. Right back to buisness. I am trying to create a form for a website "[url]http://www.parismavintage.com/index-3.php?x=13&y=2[/url]" but I cannot quite get it to work. When I click submit it brings up an e-mail window, but I want it to just send one after filling the fields out. I know the HTML is disgusting, but I joined the company after they used a generated pile of crap, so for that I apologise. [code]<form id="form" action="MAILTO:info@parisma.co.uk" enctype="text/plain" method="post"> <table border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="width: 180px;"> <table border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="height: 31px;"><input class="input" onclick="this.value=''" type="text" value="Your name:" /></td> </tr> <tr> <td style="height: 32px;"><input class="input" onclick="this.value=''" type="text" value="Telephone:" /></td> </tr> <tr> <td><input class="input" onclick="this.value=''" type="text" value="E-mail:" /></td> </tr> </tbody> </table> </td> <td style="width: 180px;"> <table border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="height: 99px;"><textarea style="overflow: auto;" cols="40" rows="20">Message:</textarea></td> </tr> <tr> <td> <p><img src="images/spacer.gif" alt="" width="73" height="1" /><input src="images/but_reset.gif" type="reset" value="Reset" /><img src="images/spacer.gif" alt="" width="18" height="1" /><input src="images/but_submit.gif" type="submit" value="Send" /></p> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </form>[/code] If you need me to elaborate on any, feel free to ask, but I am still very new at HTML and CSS. If anyone can help me it would be greatfully appreciated.
I'm not a genius on the matter, but maybe you need a function file to process the input tables to output them to an email.
Elaborate?
Make the action attribute point to a file. Here I'll just put mine up (no captcha) Here's my form: [code] <form method="post" action="contactengine.php"> <label for="Name">Name:</label><br /> <input type="text" name="Name" id="Name" /> <label for="Tel">Telephone:</label> <input type="text" name="Tel" id="Tel" /> <label for="Email">Email:</label><br /> <input type="text" name="Email" id="Email" /></p> <label for="Message">Message:</label><br /> <textarea name="Message" rows="10" cols="40" id="Message"></textarea> <input type="submit" name="submit" value="Send" class="submit-button" /> </form> [/code] Here's contactengine: [code] <?php // email from can be any working email $EmailFrom = "EMAILSENTFROM@live.com"; $EmailTo = "EMAILTOBESENTTO@live.com"; $Subject = "Contact Me Submission"; $Name = Trim(stripslashes($_POST['Name'])); $Tel = Trim(stripslashes($_POST['Tel'])); $Email = Trim(stripslashes($_POST['Email'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Tel: "; $Body .= $Tel; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=thanks.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.php\">"; } ?> [/code]
Never done PHP, and I'm new to the back-end of the sites admin. Can you intergrate the PHP with the HTML?
[QUOTE=Bagel Bagel;28652319]Never done PHP, and I'm new to the back-end of the sites admin. Can you intergrate the PHP with the HTML?[/QUOTE] If you really want to: [php] <?php if(!empty($_POST['submit'])){ //Was the form submitted? //do things here }else{ ?> <form method="post" action="contact.php"><!--change this to the file name--> <label for="Name">Name:</label><br /> <input type="text" name="Name" id="Name" /> <label for="Tel">Telephone:</label> <input type="text" name="Tel" id="Tel" /> <label for="Email">Email:</label><br /> <input type="text" name="Email" id="Email" /></p> <label for="Message">Message:</label><br /> <textarea name="Message" rows="10" cols="40" id="Message"></textarea> <input type="submit" name="submit" value="Send" class="submit-button" /> </form> <? } ?> [/php]
Sorry, you need to Log In to post a reply to this thread.