Jump to content

plz help: Contact form


Equilibrium

Recommended Posts

I wrote a small php script for a contact form in our website. As I am just a newbie, so as usual having few problem. I connected the php script successfully with the contact form(in a different page) but after filling up the contact form, when I am submitting the form, its showing me the whole php script instead of the only message I want to show(within EOD).

Here is the link of the contact form: http://aritrakundu.bizhat.com/contactus.php

 

Here is my php script:

<?php

/* Subject and Email Variables */

$emailSubject = 'Crazy PHP Scripting!';
$webMaster = '[email protected]';

/* Gathering data Variables */

$emailField = $_POST['email'];
$nameField = $_POST['name'];
$phonenumberField = $_POST['phonenumber'];
$websiteratingField = $_POST['Rating'];
$topicField = $_POST['commenttopic'];
$commentField = $_POST['comment'];

$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Phone Number: $phonenumber <br>
Website Rating: $Rating <br>
Topic: $commenttopic <br>
Comment: $comment <br>
EOD;

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

/* Rendered as HTML */

$theResults =<<<EOD
<!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>
<style type="text/css">
<!--
body {
background-color: #222;
}
#Layer1 {
position:absolute;
left:2px;
top:2px;
width:699px;
height:245px;
z-index:1;
background-color: #CCCCCC;
}
.style1 {color: #FF0000}
.style2 {color: #000000; }
-->
</style>
</head>

<body>
<div id="Layer1">
  <p> </p>
  <p align="center">  Message sent successfully. Our administrators will view your form and will get back to you within 48hrs.</p>
  <p align="center" class="style1">Thankyou for using our service</p>
  <p class="style1"> </p>
  <p align="center" class="style2"><a href="file:///C|/Documents and Settings/Aritra Kundu.ARITRA/My Documents/Project/index.php"><Go back to "Homepage"</a></p>
  <p align="center" class="style2"><a href="file:///C|/Documents and Settings/Aritra Kundu.ARITRA/My Documents/Project/contact us.php"><Go back to "Contact us"</a></p>
</div>
<p> </p>
</body>
</html>
EOD;
echo "$theResults";

?>

Link to comment
https://forums.phpfreaks.com/topic/190332-plz-help-contact-form/
Share on other sites

Figured out the problem. I gave the php page link in the action function instead of giving only the name of the php script and here is the working script.

 

<?php

/* Subject and Email Variables */



$emailSubject = 'Crazy PHP Scripting!';



$webMaster = '[email protected]';




/* Gathering data Variables */



$emailField = $_POST['email'];



$nameField = $_POST['name'];



$phonenumberField = $_POST['phonenumber'];



$websiteratingField = $_POST['Rating'];



$topicField = $_POST['commenttopic'];



$commentField = $_POST['comment'];






$body = <<<EOD
<br><hr><br>
Email: $emailField
Name: $nameField
Phone Number: $phonenumberField
Website Rating: $websiteratingField
Topic: $topicField
Comment: $commentField
EOD;



$headers = "From: $email\r\n";



$headers .= "Content-type: text/html\r\n";



$success = mail($webMaster, $emailSubject, $body, $headers);




/* Rendered as HTML */



$theResults =<<<EOD
<!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>
<style type="text/css">
<!--
body {



background-color: #222;
}
#Layer1 {



position:absolute;



left:2px;



top:2px;



width:699px;



height:245px;



z-index:1;



background-color: #CCCCCC;
}
.style1 {color: #FF0000}
.style2 {color: #000000; }
-->
</style>
</head>

<body>
<div id="Layer1">
  <p> </p>
  <p align="center">  Message sent successfully. Our administrators will view your form and will get back to you within 48hrs.</p>
  <p align="center" class="style1">Thankyou for using our service</p>
  <p class="style1"> </p>
  <p align="center" class="style2"><a href="file:///C|/Documents and Settings/Aritra Kundu.ARITRA/My Documents/Project/index.php"><Go back to "Homepage"</a></p>
  <p align="center" class="style2"><a href="file:///C|/Documents and Settings/Aritra Kundu.ARITRA/My Documents/Project/contact us.php"><Go back to "Contact us"</a></p>
</div>
<p> </p>
</body>
</html>
EOD;
echo "$theResults";

?>

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.