submit form not working
Posted: Thu Jun 02, 2011 5:29 pm
I have posted this on new boston forum as wel as php academy forum and no one can help. here is my entire php code and form on the same page.
[syntax=php] <?php
if (isset($_POST['name']) && isset($_POST['email']) && isset ($_POST['company']) && isset($_POST['message']))
{
$name=$_POST['name'];
$email=$_POST['email'];
$company=$_POST['company'];
$message=$_POST['message'];
if (!empty($name) && !empty($email) && !empty($company) && !empty($message))
{
if (strlen($name)>35 || strlen($email)>50 || strlen($company)>50 || strlen($message)>1000)
{echo 'Sorry, maxlength for some fields have been exceeded.';}
else
{
$to='test@test.com';
$subject = 'Input from Drill-Safe.';
$body = $name."\n".$message;
$headers = 'From: '.$email;
if (@mail($to, $subject, $body, $headers))
{echo 'Thanks for submitting to Drill-Safe.';}
else
{echo 'Sorry, an error has occurred. Please try again later.';}
}
}
else
{echo 'All fields are required.';}
}
?> [/syntax]
[syntax=xhtml]<form action="input.php" method="POST">
<label>NAME:<br /></label><input type="text" name="name" size="25" maxlength="35"><br><br>
<label>E-MAIL:<br /></label><input type="text" name="email" size="25" maxlength="50"><br><br>
<label>COMPANY<br /></label><input type="text" name="company" size="25" maxlength="50"><br><br>
<label>COMMENTS or QUESTIONS:<textarea rows="9" name="message" cols="60" maxlength="1000"></textarea></label><br><br>
<input type="submit" value="Send" name="submit">
</form>[/syntax]
I have also tried sending it to another php page, and nothin!
[syntax=php] <?php
if (isset($_POST['name']) && isset($_POST['email']) && isset ($_POST['company']) && isset($_POST['message']))
{
$name=$_POST['name'];
$email=$_POST['email'];
$company=$_POST['company'];
$message=$_POST['message'];
if (!empty($name) && !empty($email) && !empty($company) && !empty($message))
{
if (strlen($name)>35 || strlen($email)>50 || strlen($company)>50 || strlen($message)>1000)
{echo 'Sorry, maxlength for some fields have been exceeded.';}
else
{
$to='test@test.com';
$subject = 'Input from Drill-Safe.';
$body = $name."\n".$message;
$headers = 'From: '.$email;
if (@mail($to, $subject, $body, $headers))
{echo 'Thanks for submitting to Drill-Safe.';}
else
{echo 'Sorry, an error has occurred. Please try again later.';}
}
}
else
{echo 'All fields are required.';}
}
?> [/syntax]
[syntax=xhtml]<form action="input.php" method="POST">
<label>NAME:<br /></label><input type="text" name="name" size="25" maxlength="35"><br><br>
<label>E-MAIL:<br /></label><input type="text" name="email" size="25" maxlength="50"><br><br>
<label>COMPANY<br /></label><input type="text" name="company" size="25" maxlength="50"><br><br>
<label>COMMENTS or QUESTIONS:<textarea rows="9" name="message" cols="60" maxlength="1000"></textarea></label><br><br>
<input type="submit" value="Send" name="submit">
</form>[/syntax]
I have also tried sending it to another php page, and nothin!