Jump to content

Need help with a form


tspx

Recommended Posts

Need help trying to get a form working. Tried to put this on a site, but when I hit submit, nothing happens.

 

Here's the form:

<form name="cform" method="post" action="contactformprocess.php">
                                    <p><label for="customer">Name:</label><br />
                					<input type="text" name="customer" id="customer" size="40"/></p>
                					 
                                    <p><label for="address">Email Address:</label><br />
                                    <input type="text" name="address" id="address" size="40" /><br /></p>
                                     
                                    <p><label for="landline">Telephone Number:</label><br />
                					<input type="text" name="landline" id="landline" size="40"/></p>
								 
                                    <p><label for="comment">Please tell us what you need:</label><br />
                					<textarea title="Tell Us About Your Idea" name="comment" id="comment" rows="5" cols="50" class="input"></textarea><br /></p>
								<p><input type="button" name="Submit" value="Submit" title="Sumbit" height="28" width="97" border="0" alt="Submit"></p>

                                </form>

 

and here's the PHP:

 

<?php

/* subject and email variables */

$emailSubject = 'Spark Inquiry';
$webMaster = '[email protected]';

/* Data Variables */

$name = $_POST['customer'];
$email = $_POST['address'];
$phone = $_POST['landline'];
$comments = $_POST['comment'];
$submit = $_POST['Submit'];

$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Phone: $phone <br>
Help: $help <br>
Comments: $comments <br>
EOD;

$headers = "$From: $email\r\n";
$headers .-"Content-type: text\html\r\n";
$success - mail($webMaster, $emailSubject, $body, $headers);

/* Redirect */

$theResults <<<EOD
<html>
<head>
<title>SparkMedia - Thanks!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #f1f1f1;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #666666;
text-decoration: none;
}
-->
</style>
</head>

<div>
  <div align="left">Thank you for your interest! Your email will be answered soon!</div>
</div>
</body>
</html>
EOD;
echo "$theResults";		

?>

 

Any help?

Link to comment
https://forums.phpfreaks.com/topic/230554-need-help-with-a-form/
Share on other sites

What does "nothing happens" mean? Does the browser attempt to load the PHP script? Do you get any error messages? Do you get a blank screen?

 

I do see two lines in that code that could be causing problems:

	$headers .-"Content-type: text\html\r\n";
$success - mail($webMaster, $emailSubject, $body, $headers);

 

Shouldn't that be:

	$headers .= "Content-type: text\html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);

Have a look at your generated HTML (view page source). Your page starts with a DOCTYPE, HTML open tag and HEAD section, then there is another DOCTYPE, HTML open tag and HEAD section INSIDE the BODY. In fact, there is a second BODY inside that BODY as well. The form you are having trouble with appears AFTER the closing  BODY and closing HTML tags.  I'm sure this confuses the browser no end. Clean up the code you generate and see if that fixes the form.

hey change your button type to "type='submit'" and that should fix your issue...

Edit:

Yeah just tested it... change your button type.... But now after the submit you're getting :

Parse error: syntax error, unexpected T_START_HEREDOC in D:\Hosting\7467142\html\spark\contactformprocess.php on line 32

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.