Page 1 of 1

Contact u form error

Posted: Wed Sep 22, 2010 6:17 am
by dilipec2005
I was trying to create php based contact us form using only php.

I created following files but i was not able to submit the form. Please suggest me where I am going wrong.

Also I just want to use php. No java or other script.


Here is the code that i used

Code: Select all

<?php
if(isset($_POST['$name']))
{
$_POST['$name'];
$_POST['$contact'];
$_POST['$email'];
$_POST['$query'];

$from="$email";
$to="support@yoursitename.com";
$subject="Query from the site";
$message=" $name contacted you

his contact number is $contact
his email is $email

They inquired of
$query

";
$headers  = "From: $from\r\n";
$headers .= "Content-type: text\r\n";
mail($to, $subject, $message, $headers);

$msgToUser = "Thanks for contacting We Will get back to you soon

Admin
support@yoursitename.com";

include_once 'thanks.php'; 




}





else
{
$name="";
$contact="";
$email="";
$query="";
}

?>




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>


<form action="contact.php" method="post">

<p style="margin-bottom: -10">Your name: <input type="text" name="name" size="64"></p>
<p style="margin-bottom: -10">Your email: <input type="text" name="email" size="59"></p>
<p style="margin-bottom: -10">Contact Number: <input type="text" name="contact" size="20">
</p>
<p style="margin-bottom: -10">Comments:</p>
<p style="margin-bottom: -10"><textarea name="query" rows="10" cols="40"></textarea></p>
<p style="margin-bottom: -10"></p>

<input name="Submit" type="submit" value="Submit">

</form>


</body>
</html>
other file is just a thank you file

thnaks

but I already know how to contact me...

Posted: Wed Sep 22, 2010 7:02 am
by requinix

Code: Select all

if(isset($_POST['$name']))
{
$_POST['$name'];
$_POST['$contact'];
$_POST['$email'];
$_POST['$query'];
$s are only for variables. What you have inside the $_POST['...'] are not variables. They do not need $s.

Also, those last four lines do absolutely nothing. If you want variables for what was submitted from the form you need variable assignments, just like you what you do a couple lines down.